Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
AmanPriyanshu committed Nov 26, 2024
1 parent 0f1c3fc commit 96179d7
Show file tree
Hide file tree
Showing 120 changed files with 27,520 additions and 7,542 deletions.
7 changes: 4 additions & 3 deletions data/base_model_and_unlearnt_histogram_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def retrain_without_indices(index_to_forget, path="data.json"):
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.fit(X, y, epochs=EPOCHS, batch_size=32)
y_pred = model.predict(X).flatten()
return y_pred, y
return y_pred, y, d['X'][index_to_forget], d['y'][index_to_forget]

def compute_retrained_performance(y_pred, y_true, index_to_forget, df_og, feature_cols):
df = df_og.copy(deep=True)
Expand All @@ -138,8 +138,9 @@ def compute_retrained_performance(y_pred, y_true, index_to_forget, df_og, featur
with open("marginalized_info.json", "r") as f:
marginalized_indices = json.load(f)['common_indices']
for index_to_forget in tqdm(marginalized_indices, desc="re-traininig all"):
y_pred, y_true = retrain_without_indices(index_to_forget)
y_pred, y_true, forget_X, forget_y = retrain_without_indices(index_to_forget)
sample_to_forget = row_dict = df.loc[index_to_forget].to_dict()
performance_histogram = compute_retrained_performance(y_pred=y_pred, y_true=y_true, index_to_forget=index_to_forget, df_og=df, feature_cols=feature_cols)
os.makedirs("retrained", exist_ok=True)
with open(os.path.join("retrained", str(index_to_forget)+".json"), "w") as f:
json.dump(performance_histogram, f, indent=4)
json.dump({'forget_x':forget_X, 'forget_y': forget_y, 'sample': sample_to_forget,'performance':performance_histogram}, f, indent=4)
144 changes: 72 additions & 72 deletions data/base_performance_histogram.json
Original file line number Diff line number Diff line change
@@ -1,184 +1,184 @@
{
"age": {
"17-26": {
"loss": 0.051240859386999224,
"loss": 0.052678897332658875,
"acc": 0.9821917808219178
},
"26-33": {
"loss": 0.27041748189394665,
"acc": 0.8781115879828326
"loss": 0.27288303983355916,
"acc": 0.8729613733905579
},
"33-41": {
"loss": 0.39001377190620184,
"acc": 0.7986476333583772
"loss": 0.38182574483951304,
"acc": 0.8076634109691961
},
"41-50": {
"loss": 0.4099295268600277,
"acc": 0.7878787878787878
"loss": 0.4123311698735872,
"acc": 0.7942583732057417
},
"50-90": {
"loss": 0.4007212291807004,
"loss": 0.39737440538172314,
"acc": 0.804147465437788
}
},
"education": {
" 10th": {
"loss": 0.15442406374218823,
"acc": 0.9398907103825137
"loss": 0.16179051134466285,
"acc": 0.9344262295081968
},
" 11th": {
"loss": 0.09284835698024084,
"loss": 0.08319262311316451,
"acc": 0.9644444444444444
},
" 12th": {
"loss": 0.07713217726520309,
"acc": 0.9489795918367347
"loss": 0.07729278562845926,
"acc": 0.9591836734693877
},
" 1st-4th": {
"loss": 3.109512790312883e-06,
"loss": 4.1961405126915015e-06,
"acc": 1.0
},
" 5th-6th": {
"loss": 0.04634025600288818,
"loss": 0.055755930431614274,
"acc": 0.9838709677419355
},
" 7th-8th": {
"loss": 0.1172992790352354,
"loss": 0.11635318072190608,
"acc": 0.9574468085106383
},
" 9th": {
"loss": 0.03440367994981172,
"loss": 0.03264394899094795,
"acc": 0.991304347826087
},
" Assoc-acdm": {
"loss": 0.2645481015961495,
"acc": 0.8737373737373737
"loss": 0.28066555761946,
"acc": 0.8636363636363636
},
" Assoc-voc": {
"loss": 0.2979500833359779,
"acc": 0.8461538461538461
"loss": 0.30675732921884685,
"acc": 0.8424908424908425
},
" Bachelors": {
"loss": 0.4324400384364892,
"loss": 0.43210803722854135,
"acc": 0.7958214624881291
},
" Doctorate": {
"loss": 0.3422559894057432,
"acc": 0.8701298701298701
"loss": 0.3402048345491816,
"acc": 0.8571428571428571
},
" HS-grad": {
"loss": 0.30569025560153323,
"acc": 0.8440499040307101
"loss": 0.30611814707346224,
"acc": 0.8459692898272553
},
" Masters": {
"loss": 0.41242290810315724,
"acc": 0.8130081300813008
"loss": 0.4005202294017226,
"acc": 0.8238482384823849
},
" Preschool": {
"loss": 3.0369389513072536e-05,
"loss": 7.749499951873964e-06,
"acc": 1.0
},
" Prof-school": {
"loss": 0.36169087872617467,
"loss": 0.3397570489837095,
"acc": 0.8448275862068966
},
" Some-college": {
"loss": 0.28150561103933797,
"acc": 0.8511784511784511
"loss": 0.27763037176094724,
"acc": 0.857912457912458
}
},
"education-num": {
"1-9": {
"loss": 0.24384121817545865,
"acc": 0.8786127167630058
"loss": 0.24395369247805393,
"acc": 0.8799727983679021
},
"10-13": {
"loss": 0.38653560192938496,
"acc": 0.8149606299212598
"loss": 0.38997788352168744,
"acc": 0.812992125984252
},
"13-16": {
"loss": 0.3923379113995436,
"acc": 0.8274021352313167
"loss": 0.37971450994952477,
"acc": 0.8327402135231317
},
"9-10": {
"loss": 0.28150561103933797,
"acc": 0.8511784511784511
"loss": 0.27763037176094724,
"acc": 0.857912457912458
}
},
"relationship": {
" Husband": {
"loss": 0.5196957910928894,
"acc": 0.7277992277992278
"loss": 0.5122563110259905,
"acc": 0.733976833976834
},
" Not-in-family": {
"loss": 0.20726895885968977,
"acc": 0.9159318048206937
"loss": 0.21298396453974294,
"acc": 0.9124044679600235
},
" Other-relative": {
"loss": 0.047252537852945205,
"acc": 0.9775280898876404
"loss": 0.03319852292365772,
"acc": 0.9887640449438202
},
" Own-child": {
"loss": 0.029080193060659714,
"acc": 0.9901864573110893
"loss": 0.030865689368054724,
"acc": 0.9892051030421982
},
" Unmarried": {
"loss": 0.09290493261087591,
"acc": 0.9629629629629629
"loss": 0.09912052204105681,
"acc": 0.9672364672364673
},
" Wife": {
"loss": 0.4438120791428075,
"loss": 0.4394444424315351,
"acc": 0.7857142857142857
}
},
"race": {
" Amer-Indian-Eskimo": {
"loss": 0.11869445904340692,
"acc": 0.9436619718309859
"loss": 0.09928612538032491,
"acc": 0.971830985915493
},
" Asian-Pac-Islander": {
"loss": 0.220362317334322,
"acc": 0.9119170984455959
"loss": 0.25514663047969033,
"acc": 0.9015544041450777
},
" Black": {
"loss": 0.1106528640313722,
"acc": 0.9482470784641068
"loss": 0.09989086831861993,
"acc": 0.9532554257095158
},
" Other": {
"loss": 0.05414615102217648,
"loss": 0.0549805946248221,
"acc": 0.9818181818181818
},
" White": {
"loss": 0.3261585057017809,
"acc": 0.838398283875581
"loss": 0.3250489065623637,
"acc": 0.8403646764390418
}
},
"gender": {
" Female": {
"loss": 0.15153519236517307,
"acc": 0.9360301034807149
"loss": 0.1531230703989047,
"acc": 0.9355597365945437
},
" Male": {
"loss": 0.36994600994665233,
"acc": 0.81281349749202
"loss": 0.36751826563009254,
"acc": 0.8162334701322389
}
},
"hours-per-week": {
"1-35": {
"loss": 0.12829014087537155,
"acc": 0.9436619718309859
"loss": 0.1330939054036506,
"acc": 0.9414381022979985
},
"35-40": {
"loss": 0.30326515234592605,
"acc": 0.8497948879772799
"loss": 0.2975705455598675,
"acc": 0.8526349005995583
},
"40-50": {
"loss": 0.40556491409449363,
"acc": 0.8019559902200489
"loss": 0.4011194354560321,
"acc": 0.8068459657701712
},
"50-99": {
"loss": 0.40809413451801135,
"acc": 0.788787483702738
"loss": 0.42080374986747604,
"acc": 0.7913950456323338
}
}
}
6 changes: 6 additions & 0 deletions data/indexer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
import json

files = [int(i[:-5]) for i in sorted(list(os.listdir("retrained")))]
with open(os.path.join("retrained", "index.json"), "w") as f:
json.dump({"indices": files}, f, indent=4)
Loading

0 comments on commit 96179d7

Please sign in to comment.