Skip to content

Commit 7a2cf40

Browse files
committed
STYLE code formatting
1 parent f31dded commit 7a2cf40

12 files changed

+1734
-931
lines changed

experiments/0.2-basic-experiment.ipynb

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -389,34 +389,41 @@
389389
" try:\n",
390390
"\n",
391391
" result = explanation_sensitivity_all_neighbors(\n",
392-
" dataset[\"data\"][0], \n",
392+
" dataset[\"data\"][0],\n",
393393
" results[dataset[\"name\"]][method][0],\n",
394394
" rankings,\n",
395395
" measure=\"euclidean\",\n",
396396
" normalization=False,\n",
397-
" #n_features=0.8,\n",
398-
" threshold=0.1\n",
397+
" # n_features=0.8,\n",
398+
" threshold=0.1,\n",
399399
" )\n",
400-
" \n",
401-
" df_length = dataset['data'][0].shape[0]\n",
402-
" for plot_idx in [int(num/10*df_length) for num in range(1,10,1)]:\n",
403-
" measure_distances, rank_distances, feature_distances = result(row_idx=plot_idx)\n",
404-
" \n",
400+
"\n",
401+
" df_length = dataset[\"data\"][0].shape[0]\n",
402+
" for plot_idx in [int(num / 10 * df_length) for num in range(1, 10, 1)]:\n",
403+
" measure_distances, rank_distances, feature_distances = result(\n",
404+
" row_idx=plot_idx\n",
405+
" )\n",
406+
"\n",
405407
" temp = pd.DataFrame()\n",
406-
" \n",
407-
" temp['Explanation distance'] = measure_distances\n",
408-
" temp['Absolute Rank distance'] = np.absolute(rank_distances)\n",
409-
" temp['Feature distance'] = feature_distances\n",
410-
" sns.scatterplot(data=temp, x=\"Explanation distance\", y=\"Absolute Rank distance\", hue=\"Feature distance\")\n",
411-
" leg = plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n",
408+
"\n",
409+
" temp[\"Explanation distance\"] = measure_distances\n",
410+
" temp[\"Absolute Rank distance\"] = np.absolute(rank_distances)\n",
411+
" temp[\"Feature distance\"] = feature_distances\n",
412+
" sns.scatterplot(\n",
413+
" data=temp,\n",
414+
" x=\"Explanation distance\",\n",
415+
" y=\"Absolute Rank distance\",\n",
416+
" hue=\"Feature distance\",\n",
417+
" )\n",
418+
" leg = plt.legend(loc=\"center left\", bbox_to_anchor=(1, 0.5))\n",
412419
" # plt.title(f'{method} and {dataset[\"name\"]} and rank={plot_idx}')\n",
413420
" # sns.move_legend(ax, \"upper left\", bbox_to_anchor=(1, 1))\n",
414-
" \n",
421+
"\n",
415422
" plt.savefig(\n",
416-
" f\"results/sensitivity-scatterplot-{dataset[\"name\"]}-{method}-{plot_idx}.pdf\",\n",
417-
" format=\"pdf\",\n",
418-
" bbox_inches=\"tight\",\n",
419-
" transparent=True\n",
423+
" f\"results/sensitivity-scatterplot-{dataset[\"name\"]}-{method}-{plot_idx}.pdf\",\n",
424+
" format=\"pdf\",\n",
425+
" bbox_inches=\"tight\",\n",
426+
" transparent=True,\n",
420427
" )\n",
421428
" plt.show()\n",
422429
" # plt.clf()\n",
@@ -646,12 +653,12 @@
646653
" # print(\"Unknown QoI\")\n",
647654
"\n",
648655
" # print(method[\"name\"], max_target)\n",
649-
" \n",
656+
"\n",
650657
" # for dataset in datasets:\n",
651658
" # rankings = scores_to_ordering(dataset[\"scorer\"](dataset[\"data\"][0]))\n",
652659
" # # try:\n",
653660
" # result = explanation_sensitivity_all_neighbors(\n",
654-
" # dataset[\"data\"][0], \n",
661+
" # dataset[\"data\"][0],\n",
655662
" # results[dataset[\"name\"]][method[\"name\"]][0],\n",
656663
" # rankings,\n",
657664
" # measure=\"euclidean\",\n",
@@ -664,17 +671,17 @@
664671
" # df_length = dataset['data'][0].shape[0]\n",
665672
" # for plot_idx in [int(num/10*df_length) for num in range(1,10,1)]:\n",
666673
" # measure_distances, rank_distances, feature_distances = result(row_idx=plot_idx)\n",
667-
" \n",
674+
"\n",
668675
" # temp = pd.DataFrame()\n",
669-
" \n",
676+
"\n",
670677
" # temp['Explanation distance'] = measure_distances\n",
671678
" # temp['Absolute Rank distance'] = np.absolute(rank_distances)\n",
672679
" # temp['Feature distance'] = feature_distances\n",
673680
" # sns.scatterplot(data=temp, x=\"Explanation distance\", y=\"Absolute Rank distance\", hue=\"Feature distance\")\n",
674681
" # leg = plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n",
675682
" # # plt.title(f'{method} and {dataset[\"name\"]} and rank={plot_idx}')\n",
676683
" # # sns.move_legend(ax, \"upper left\", bbox_to_anchor=(1, 1))\n",
677-
" \n",
684+
"\n",
678685
" # plt.savefig(\n",
679686
" # f\"results/sensitivity-scatterplot-{dataset[\"name\"]}-{method[\"name\"]}-{plot_idx}.pdf\",\n",
680687
" # format=\"pdf\",\n",
@@ -688,8 +695,8 @@
688695
" # # pass\n",
689696
" for dataset in datasets:\n",
690697
" print(method[\"name\"])\n",
691-
" print(\"\\t\",dataset[\"name\"])\n",
692-
" print(\"\\t\\t\",results[dataset[\"name\"]][method[\"name\"]][0].sum(axis=1).max())"
698+
" print(\"\\t\", dataset[\"name\"])\n",
699+
" print(\"\\t\\t\", results[dataset[\"name\"]][method[\"name\"]][0].sum(axis=1).max())"
693700
]
694701
},
695702
{
@@ -1678,10 +1685,10 @@
16781685
"evalue": "name 'dataset' is not defined",
16791686
"output_type": "error",
16801687
"traceback": [
1681-
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
1682-
"\u001B[0;31mNameError\u001B[0m Traceback (most recent call last)",
1683-
"Cell \u001B[0;32mIn[10], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m dataset[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mscorer\u001B[39m\u001B[38;5;124m\"\u001B[39m]\n",
1684-
"\u001B[0;31mNameError\u001B[0m: name 'dataset' is not defined"
1688+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
1689+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
1690+
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m dataset[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mscorer\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n",
1691+
"\u001b[0;31mNameError\u001b[0m: name 'dataset' is not defined"
16851692
]
16861693
}
16871694
],

0 commit comments

Comments
 (0)