-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathall_classification_experiments.py
172 lines (141 loc) · 4.58 KB
/
all_classification_experiments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Code to reproduce the classification experiments in the paper
from fair_dummies.cf_classification import run_experiment
# parameters are tuned on training set
# choose test=True to evaluate training performance
test = True
if test:
# test seed
random_state_train_test = 123456789
# repeat the experiments for num_experiments times
num_experiments = 20
else:
# train seed
random_state_train_test = 0
# repeat the experiments for num_experiments times
num_experiments = 10
test_methods = []
dataset_names = []
batch_size = []
lr = []
steps = []
mu_val = []
second_scale = []
epochs = []
model_type = []
################################################################################
## Fairness-unaware baseline methods
################################################################################
test_methods += ['Baseline']
dataset_names += ['nursery']
batch_size += [32]
lr += [0.1]
steps += [1]
mu_val += [0.0]
second_scale += [0.0]
epochs += [20]
model_type += ["linear_model"]
test_methods += ['Baseline']
dataset_names += ['nursery']
batch_size += [32]
lr += [0.001]
steps += [1]
mu_val += [0.0]
second_scale += [0.0]
epochs += [100]
model_type += ["deep_model"]
################################################################################
# HGR EO Penalty
# paper: Fairness-Aware Learning for Continuous Attributes and Treatments,
# J. Mary, C. Calauzènes, N. El Karoui, ICML 2019
################################################################################
test_methods += ['HGR']
dataset_names += ['nursery']
batch_size += [128]
lr += [0.001]
steps += [1]
mu_val += [0.98]
second_scale += [0.0]
epochs += [50]
model_type += ["linear_model"]
test_methods += ['HGR']
dataset_names += ['nursery']
batch_size += [128]
lr += [0.001]
steps += [1]
mu_val += [0.98]
second_scale += [0.0]
epochs += [50]
model_type += ["deep_model"]
###############################################################################
# Adversarial Debiasing EO Penalty
# paper: Mitigating Unwanted Biases with Adversarial Learning,
# Zhang, B.H., Lemoine, B. and Mitchell, M., AAAI/ACM Conference on AI, Ethics,
# and Society, 2018
###############################################################################
test_methods += ['AdversarialDebiasing']
dataset_names += ['nursery']
batch_size += [32]
lr += [0.5]
steps += [2]
mu_val += [0.999999]
second_scale += [0.0]
epochs += [40]
model_type += ["deep_model"]
test_methods += ['AdversarialDebiasing']
dataset_names += ['nursery']
batch_size += [32]
lr += [0.5]
steps += [1]
mu_val += [0.999999]
second_scale += [0.0]
epochs += [200]
model_type += ["linear_model"]
################################################################################
# Fair Dummies EO Penalty (proposed method)
# Paper: Achieving Equalized Odds by Resampling Sensitive Attributes,
# Y. Romano, S. Bates, and E. J. Candès, 2020
################################################################################
test_methods += ['FairDummies']
dataset_names += ['nursery']
batch_size += [32]
lr += [0.5]
steps += [1] #60
mu_val += [0.99999]
second_scale += [0.01]
epochs += [50]
model_type += ["linear_model"]
test_methods += ['FairDummies']
dataset_names += ['nursery']
batch_size += [32]
lr += [0.5]
steps += [2]
mu_val += [0.9]
second_scale += [0.00001]
epochs += [50]
model_type += ["deep_model"]
for exp_id in range(8):
cur_test_method = test_methods[exp_id]
cur_dataset_name = dataset_names[exp_id]
cur_batch_size = batch_size[exp_id]
cur_lr_loss = lr[exp_id]
cur_lr_dis = lr[exp_id]
cur_loss_steps = steps[exp_id]
cur_dis_steps = steps[exp_id]
cur_mu_val = mu_val[exp_id]
cur_epochs = epochs[exp_id]
cur_random_state = random_state_train_test
cur_model_type = model_type[exp_id]
cur_second_scale = second_scale[exp_id]
run_experiment(cur_test_method,
cur_dataset_name,
cur_batch_size,
cur_lr_loss,
cur_lr_dis,
cur_loss_steps,
cur_dis_steps,
cur_mu_val,
cur_epochs,
cur_model_type,
random_state_train_test,
cur_second_scale,
num_experiments)