-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41706da
commit 8f0da14
Showing
9 changed files
with
177 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import pandas as pd | ||
|
||
metric_map = { | ||
'electricity': ['mae', 'mse'], | ||
'traffic': ['mae', 'mse'], | ||
'mimic_iii': ['auc', 'accuracy', 'cross_entropy'] | ||
} | ||
|
||
datasets = ['electricity', 'traffic', 'mimic_iii'] | ||
models = ['DLinear', 'MICN', 'LSTM', 'Crossformer'] | ||
attr_methods = ['feature_ablation', 'occlusion', 'augmented_occlusion', 'feature_permutation', 'winIT'] | ||
|
||
short_form = { | ||
'feature_ablation': 'FA', | ||
'occlusion':'FO', | ||
'augmented_occlusion': 'AFO', | ||
'feature_permutation': 'FP', | ||
'winIT': 'WinIT' | ||
} | ||
|
||
# for dataset in datasets: | ||
# print(dataset) | ||
# tsr_better_comp = 0 | ||
# tsr_better_suff = 0 | ||
# comp_count = suff_count = 0 | ||
|
||
# for attr_method in attr_methods: | ||
# for model in models: # , 'Crossformer' | ||
# df = pd.read_csv(f'results/{dataset}_{model}/{attr_method}.csv') | ||
# df = df[df['area']==0.05] | ||
|
||
# df_tsr = pd.read_csv(f'results/{dataset}_{model}/tsr_{attr_method}.csv') | ||
# df_tsr = df_tsr[df_tsr['area']==0.05] | ||
|
||
# for metric in metric_map[dataset]: | ||
# [comp, suff] = df[df['metric']==metric][['comp', 'suff']].values[0] | ||
# # print(comp, suff) | ||
|
||
# [tsr_comp, tsr_suff] = df_tsr[df_tsr['metric']==metric][['comp', 'suff']].values[0] | ||
# # print(tsr_comp, tsr_suff) | ||
|
||
# if metric in ['accuracy', 'auc']: | ||
# if comp > tsr_comp: tsr_better_comp +=1 | ||
# if suff < tsr_suff: tsr_better_suff += 1 | ||
# else: | ||
# if comp < tsr_comp: tsr_better_comp +=1 | ||
# if suff > tsr_suff: tsr_better_suff += 1 | ||
# comp_count +=1 | ||
# suff_count +=1 | ||
# break | ||
|
||
# print(f'TSR better for: comp {tsr_better_comp}, suff {tsr_better_suff}. Total cases: {suff_count}') | ||
# print(f'TSR improve comprehensiveness on {100.0* tsr_better_comp/comp_count:0.4f}\%, \ | ||
# and sufficiency on {tsr_better_suff*100.0/suff_count:0.4f}\% cases.\n') | ||
|
||
def reduce_df(df:pd.DataFrame): | ||
# df[df['area']==0.05] | ||
return df.groupby('metric').aggregate('mean')[['comp', 'suff']].reset_index() | ||
|
||
def print_row(item): | ||
print(f'& {item:0.4g} ', end='') | ||
|
||
for dataset in datasets: | ||
print(f'printing latex table for {dataset} dataset.\n') | ||
print(f" & {' & '.join(models)} & {' & '.join(models)} \\\\ \\hline") | ||
|
||
tsr_better_comp = 0 | ||
tsr_better_suff = 0 | ||
comp_count = suff_count = 0 | ||
|
||
for attr_method in attr_methods: | ||
print(f'{short_form[attr_method]} ', end='') | ||
for model in models: | ||
df = pd.read_csv(f'results/{dataset}_{model}/{attr_method}.csv') | ||
df = reduce_df(df) | ||
|
||
for metric in metric_map[dataset]: | ||
[comp, _] = df[df['metric']==metric][['comp', 'suff']].values[0] | ||
if metric in ['auc', 'accuracy']: | ||
comp = 1- comp | ||
break | ||
print_row(comp) | ||
|
||
for model in models: | ||
df = pd.read_csv(f'results/{dataset}_{model}/{attr_method}.csv') | ||
df = reduce_df(df) | ||
for metric in metric_map[dataset]: | ||
[_, suff] = df[df['metric']==metric][['comp', 'suff']].values[0] | ||
if metric in ['auc', 'accuracy']: | ||
suff = 1- suff | ||
break | ||
print_row(suff) | ||
print('\\\\') | ||
|
||
print('\\hline') | ||
for attr_method in attr_methods: | ||
if attr_method == 'winIT': continue | ||
print(f'WTSR+{short_form[attr_method]} ', end='') | ||
for model in models: | ||
df_tsr = pd.read_csv(f'results/{dataset}_{model}/tsr_{attr_method}.csv') | ||
df_tsr = reduce_df(df_tsr) | ||
|
||
for metric in metric_map[dataset]: | ||
[tsr_comp, _] = df_tsr[df_tsr['metric']==metric][['comp', 'suff']].values[0] | ||
if metric in ['auc', 'accuracy']: | ||
tsr_comp = 1- tsr_comp | ||
break | ||
|
||
print_row(tsr_comp) | ||
|
||
for model in models: | ||
df_tsr = pd.read_csv(f'results/{dataset}_{model}/tsr_{attr_method}.csv') | ||
df_tsr = reduce_df(df_tsr) | ||
|
||
for metric in metric_map[dataset]: | ||
[_, tsr_suff] = df_tsr[df_tsr['metric']==metric][['comp', 'suff']].values[0] | ||
if metric in ['auc', 'accuracy']: | ||
tsr_suff = 1- tsr_suff | ||
break | ||
print_row(tsr_suff) | ||
|
||
print('\\\\') | ||
print('\\hline\n\n') | ||
# break | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
metric,area,comp,suff | ||
mae,0.05,11.820683,11.788181 | ||
mae,0.075,13.516388,10.315534 | ||
mae,0.1,14.248765,9.522623 | ||
mae,0.15,15.422024,7.927388 | ||
mse,0.05,10.148638,9.057515 | ||
mse,0.075,12.760038,7.038268 | ||
mse,0.1,13.971034,6.098217 | ||
mse,0.15,16.04396,4.389713 |
9 changes: 9 additions & 0 deletions
9
results/electricity_DLinear/tsr_integrated_gradients_orig.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
metric,area,comp,suff | ||
mae,0.05,1.486402,12.089916 | ||
mae,0.075,1.663017,11.305623 | ||
mae,0.1,1.829393,10.807415 | ||
mae,0.15,2.307418,9.467468 | ||
mse,0.05,0.206225,9.598049 | ||
mse,0.075,0.239076,8.608364 | ||
mse,0.1,0.271157,7.933516 | ||
mse,0.15,0.375217,5.939165 |
51 changes: 0 additions & 51 deletions
51
results/national_illness_Transformer/interpretations_test.csv
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
results/national_illness_Transformer/interpretations_val.csv
This file was deleted.
Oops, something went wrong.