Skip to content

Commit

Permalink
control experiment analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
jayadevbhaskaran committed May 26, 2019
1 parent 663d5cc commit ada6832
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
print(results)
np.savetxt(Config.RESULTS_FILE, np.array(results),
header="t prob f-m (models: logreg lstm bert)")
print("\n")
###############################################################################
#Ad-hoc analysis for gender differences in SST-2 train dataset
train = pd.read_csv(Config.TSV_TRAIN, sep="\t", header=None, names=["idx", "class", "dummy", "text"])
Expand All @@ -51,6 +52,7 @@
f_list.append(item['_1'])
break
print(len(f_list), np.mean(f_list))
print("\n")

'''
for p in Config.PROFESSIONS:
Expand All @@ -68,7 +70,6 @@
map1 = {}
map2 = {}
for p in Config.PROFESSIONS:
print(p)
male0 = preds0[20*i:20*(i+1)]
male1 = preds1[20*i:20*(i+1)]
male2 = preds2[20*i:20*(i+1)]
Expand All @@ -79,10 +80,18 @@

#print(np.mean(female0 + male0), np.mean(female0) - np.mean(male0), "\n")
#print(np.mean(female1 + male1), np.mean(female1) - np.mean(male1), "\n")
print(np.mean(female2 + male2), np.mean(female2) - np.mean(male2), "\n")
print(p, np.mean(female2 + male2), np.mean(female2) - np.mean(male2))

i = i+1

control_preds = []
control = preds2_with_control[-40:]
male_c = control[:20]
female_c = control[20:]
print("control", np.mean(female_c + male_c), np.mean(female_c) - np.mean(male_c))
print("\n")
###############################################################################
'''
sentences = utils.get_sentences()
args0 = np.argsort(preds0)
args1 = np.argsort(preds1)
Expand All @@ -93,6 +102,7 @@
for i in range(10):
print(sentences[args2[799 - i]])
'''
###############################################################################
for noun in Config.MALE_NOUNS:
noun_preds = []
Expand Down
2 changes: 1 addition & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def ttest(preds):
female_probs = preds[n:]
(t, prob) = ttest_rel(male_probs, female_probs)
diff = np.mean(female_probs) - np.mean(male_probs)
print(np.mean(male_probs), np.mean(female_probs), diff, prob)
#print(np.mean(male_probs), np.mean(female_probs), diff, prob)
return (t, prob, diff)

def glove2dict(src_filename):
Expand Down

0 comments on commit ada6832

Please sign in to comment.