| load_adult_data |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/dataset.py code served (permissive licence) · get_code("f0a20ecb976a4b4e") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import pandas as pd
import numpy as np
import os
import tempfile
# Create temporary directory with mock data files
temp_dir = tempfile.mkdtemp()
# Create mock adult.data file
adult_data_content = """25,Private,226802,11th,7,Never-married,Machine-operator,Own-child,Black,Male,0,0,40,United-States,<=50K
38,Private,89814,HS-grad,9,Married-civ-spouse,Farming-fishing,Husband,White,Male,0,0,50,United-States,<=50K
28,Local-gov,336951,Assoc-acdm,12,Married-civ-spouse,Protective-serv,Husband,White,Male,0,0,40,United-States,>50K
44,Private,160323,Some-college,10,Married-civ-spouse,Machine-operator,Husband,Black,Male,7688,0,40,United-States,>50K
18,Private,103497,Some-college,10,Never-married,Adm-clerical,Own-child,White,Female,0,0,30,United-States,<=50K
"""
adult_test_content = """age,workclass,fnlwgt,education,education_num,marital-status,occupation,relationship,race,sex,capital_gain,capital_loss,hours_per_week,native-country,target
35,Private,284582,Some-college,10,Married-civ-spouse,Exec-managerial,Husband,White,Male,0,0,40,United-States,>50K
42,Private,159449,Bachelors,13,Married-civ-spouse,Exec-managerial,Husband,White,Male,5178,0,40,United-States,>50K
40,Private,193524,Doctorate,16,Married-civ-spouse,Prof-specialty,Husband,Asian-Pac-Islander,Male,0,0,60,United-States,>50K
30,Private,141297,Bachelors,13,Married-civ-spouse,Prof-specialty,Wife,White,Female,0,0,40,United-States,>50K
"""
with open(os.path.join(temp_dir, 'adult.data'), 'w') as f:
f.write(adult_data_content)
with open(os.path.join(temp_dir, 'adult.test'), 'w') as f:
f.write(adult_test_content)
ARGS = {
'path': temp_dir,
'sensitive_attribute': 'sex'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_german_data |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/dataset.py code served (permissive licence) · get_code("831fffb30d05aae1") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import pandas as pd
import os
import tempfile
# Create a temporary directory and minimal german.data file
temp_dir = tempfile.mkdtemp()
# Create a minimal german.data file with the required format
# 20 space-separated values per line (matching the 20 column_names)
german_data_content = """A91 13 A34 A43 1169 A65 A75 4 A93 A101 4 A121 67 A143 A152 2 A173 1 A192 A201 1
A92 24 A32 A40 5951 A61 A73 2 A92 A103 2 A122 22 A143 A152 1 A172 1 A191 A202 2
A91 12 A34 A46 2096 A61 A74 2 A93 A101 3 A121 49 A142 A152 1 A173 2 A191 A202 1
A93 18 A32 A42 7882 A61 A71 4 A92 A103 4 A122 45 A143 A151 2 A172 1 A192 A201 1
"""
data_path = os.path.join(temp_dir, 'german.data')
with open(data_path, 'w') as f:
f.write(german_data_content)
ARGS = {
'path': temp_dir,
'sensitive_attribute': 'sex'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| load_jigsaw_text_data |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/dataset.py code served (permissive licence) · get_code("6efc0a57d5e4e72d") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import os
import pickle
import tempfile
import pandas as pd
import numpy as np
# Create a temporary directory and mock pickle file
temp_dir = tempfile.mkdtemp()
# Create mock data that matches what the function expects
X = np.random.randn(10, 50).astype(np.float32) # 10 samples, 50 features
y = np.random.randint(0, 2, size=10) # Binary labels
s = pd.DataFrame({
'gender': np.random.choice(['male', 'female'], size=10),
'race_or_ethnicity': np.random.choice(['white', 'black', 'asian'], size=10)
})
# Write mock data to pickle file
pkl_path = os.path.join(temp_dir, 'processed_text_features.pkl')
with open(pkl_path, 'wb') as f:
pickle.dump(X, f)
pickle.dump(y, f)
pickle.dump(s, f)
ARGS = {
'path': temp_dir,
'sensitive_attribute': 'sex'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple — a tuple output has no array shape of its own; none is stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_epoch |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/ffb_tabular_adv_gr.py code served (permissive licence) · get_code("e44410ab58a2a6a1") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned AdvFairNet. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
torch.manual_seed(0)
# Small stand-in model that outputs (y_hat, s_hat)
class AdvFairNet(nn.Module):
def __init__(self):
super().__init__()
self.fc = nn.Linear(4, 8)
self.clf_head = nn.Linear(8, 3) # classification output
self.adv_head = nn.Linear(8, 2) # adversarial (sensitive attr) output
def forward(self, X):
hidden = self.fc(X)
y_hat = self.clf_head(hidden)
s_hat = self.adv_head(hidden)
return y_hat, s_hat
# Create model
advfairnet = AdvFairNet()
# Create data loader as list of (X, y, s) tuples
# X: batch of 2 samples, 4 features
# y: batch of 2 classification labels (3 classes)
# s: batch of 2 sensitive attribute labels (2 classes)
data_loader = [
(torch.randn(2, 4), torch.randint(0, 3, (2,)), torch.randint(0, 2, (2,))),
(torch.randn(2, 4), torch.randint(0, 3, (2,)), torch.randint(0, 2, (2,))),
]
# Loss functions
clf_criterion = nn.CrossEntropyLoss()
adv_criterion = nn.CrossEntropyLoss()
# Optimizer
optimizer = torch.optim.SGD(advfairnet.parameters(), lr=0.01)
# Device (CPU only)
device = torch.device('cpu')
# Config with lambda parameter
class Args:
lam = 0.5
args = Args()
# Create global args reference for the function
import sys
sys.modules[__name__].args = args
ARGS = {
'advfairnet': advfairnet,
'data_loader': data_loader,
'clf_criterion': clf_criterion,
'adv_criterion': adv_criterion,
'optimizer': optimizer,
'device': device,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type AdvFairNet — a AdvFairNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a AdvFairNet output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_step |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/ffb_image_diffdp.py code served (permissive licence) · get_code("ec995a87fb3aa08f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.optim as optim
torch.manual_seed(0)
# Define a simple model that returns (h, output)
class SimpleModel(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(4, 8)
self.fc2 = nn.Linear(8, 3)
def forward(self, data):
h = self.fc1(data)
output = self.fc2(h)
return h, output
# Create model
model = SimpleModel()
# Create tiny tensors
data = torch.randn(2, 4) # batch size 2, feature dim 4
target = torch.randint(0, 3, (2,)) # batch size 2, 3 classes
sensitive = torch.randint(0, 2, (2,)) # batch size 2, binary sensitive attribute
# Create optimizer
optimizer = optim.SGD(model.parameters(), lr=0.01)
# Create scheduler
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.9)
# Create loss criteria
clf_criterion = nn.CrossEntropyLoss()
fair_criterion = nn.CrossEntropyLoss()
# Lambda for fairness loss weight
lam = 0.1
# Device (CPU only)
device = torch.device('cpu')
# Args dict (optional)
args = None
ARGS = {
'model': model,
'data': data,
'target': target,
'sensitive': sensitive,
'scheduler': scheduler,
'optimizer': optimizer,
'clf_criterion': clf_criterion,
'fair_criterion': fair_criterion,
'lam': lam,
'device': device,
'args': args
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_step |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/ffb_image_diffeodd.py code served (permissive licence) · get_code("a6a63d55993a1803") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.optim as optim
torch.manual_seed(0)
# Define a simple model that returns (h, output)
class SimpleModel(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(4, 8)
self.fc2 = nn.Linear(8, 3)
def forward(self, x):
h = self.fc1(x)
output = self.fc2(h)
return h, output
# Define a classification criterion
clf_criterion = nn.CrossEntropyLoss()
# Define a fairness criterion (takes output, sensitive, target)
class FairnessCriterion(nn.Module):
def forward(self, output, sensitive, target):
# Simple stand-in: compute a small penalty based on output variance
return torch.mean(torch.var(output, dim=0))
fair_criterion = FairnessCriterion()
# Create model, optimizer, scheduler
model = SimpleModel()
optimizer = optim.SGD(model.parameters(), lr=0.01)
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.1)
# Create tiny tensors
batch_size = 2
data = torch.randn(batch_size, 4) # batch_size=2, input_dim=4
target = torch.randint(0, 3, (batch_size,)) # 3 classes
sensitive = torch.randint(0, 2, (batch_size,)) # binary sensitive attribute
# Device and lambda
device = 'cpu'
lam = 0.5
# Optional args
args = None
# Construct ARGS dictionary
ARGS = {
'model': model,
'data': data,
'target': target,
'sensitive': sensitive,
'scheduler': scheduler,
'optimizer': optimizer,
'clf_criterion': clf_criterion,
'fair_criterion': fair_criterion,
'lam': lam,
'device': device,
'args': args
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_step |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/ffb_image_erm.py code served (permissive licence) · get_code("fdec6b87d8ff457b") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.optim as optim
torch.manual_seed(0)
# Define a simple model with forward() that returns (h, output)
class SimpleModel(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(4, 8)
self.fc2 = nn.Linear(8, 3)
def forward(self, x):
h = self.fc1(x)
output = self.fc2(h)
return h, output
# Create instances
model = SimpleModel()
device = torch.device('cpu')
# Create tiny tensors (batch size 2)
data = torch.randn(2, 4) # batch of 2, input dim 4
target = torch.randint(0, 3, (2,)) # batch of 2, 3 classes
sensitive = torch.randint(0, 2, (2,)) # batch of 2, binary sensitive attribute
# Create optimizer
optimizer = optim.SGD(model.parameters(), lr=0.01)
# Create scheduler
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.9)
# Create loss criterion
criterion = nn.CrossEntropyLoss()
# Create args dict (can be None or a simple namespace-like object)
class ArgsStandIn:
pass
args = ArgsStandIn()
ARGS = {
'model': model,
'data': data,
'target': target,
'sensitive': sensitive,
'scheduler': scheduler,
'optimizer': optimizer,
'criterion': criterion,
'device': device,
'args': args
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_step |
Ran ran on a synthesized input |
ahxt/fair_fairness_benchmark/src/ffb_tabular_adv_gr.py code served (permissive licence) · get_code("4313a3b250fe0838") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
import torch.nn as nn
import torch.optim as optim
torch.manual_seed(0)
# Define a simple model that takes data and returns y_hat and s_hat
class FairnessModel(nn.Module):
def __init__(self):
super().__init__()
self.classifier = nn.Linear(4, 3) # 4 input features -> 3 classes
self.sensitive_predictor = nn.Linear(4, 2) # 4 input features -> 2 sensitive groups
def forward(self, data):
y_hat = self.classifier(data)
s_hat = self.sensitive_predictor(data)
return y_hat, s_hat
# Create model instance
model = FairnessModel()
# Create tiny tensors for batch processing
batch_size = 2
input_dim = 4
num_classes = 3
num_sensitive_groups = 2
data = torch.randn(batch_size, input_dim)
target = torch.randint(0, num_classes, (batch_size,))
sensitive = torch.randint(0, num_sensitive_groups, (batch_size,))
# Create loss functions
clf_criterion = nn.CrossEntropyLoss()
adv_criterion = nn.CrossEntropyLoss()
# Create optimizer
optimizer = optim.SGD(model.parameters(), lr=0.01)
# Create scheduler
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.1)
# Lambda parameter for balancing losses
lam = 0.5
# Device (CPU only)
device = 'cpu'
# Args dict (optional args parameter)
args_opt = None
# Build the ARGS dict with all parameters
ARGS = {
'model': model,
'data': data,
'target': target,
'sensitive': sensitive,
'clf_criterion': clf_criterion,
'adv_criterion': adv_criterion,
'optimizer': optimizer,
'scheduler': scheduler,
'lam': lam,
'device': device,
'args': args_opt
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| train_epoch |
Not yet run unverified (harvested, no recorded run) |
ahxt/fair_fairness_benchmark/src/ffb_tabular_diffdp.py code served (permissive licence) · get_code("7403ecdd83befa98") How it ran |