-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add auc calculation, swarm latest fix
- Loading branch information
Showing
4 changed files
with
174 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "52f2e02a-69de-40fa-8b08-5b7f26f5066a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"id": "117d9a6b-d855-4d74-b591-0cb4c6e57920", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Shape of train_acc: (12, 210)\n", | ||
"Shape of test_acc: (12, 210)\n", | ||
"Individual AUCs for each client:\n", | ||
"Client 1 - Training AUC: 190.15625, Testing AUC: 55.803525641025644\n", | ||
"Client 2 - Training AUC: 186.25, Testing AUC: 55.803525641025644\n", | ||
"Client 3 - Training AUC: 184.515625, Testing AUC: 55.803525641025644\n", | ||
"Client 4 - Training AUC: 184.03125, Testing AUC: 55.803525641025644\n", | ||
"Client 5 - Training AUC: 180.234375, Testing AUC: 40.629852744310575\n", | ||
"Client 6 - Training AUC: 181.984375, Testing AUC: 40.629852744310575\n", | ||
"Client 7 - Training AUC: 181.09375, Testing AUC: 40.629852744310575\n", | ||
"Client 8 - Training AUC: 177.28125, Testing AUC: 40.629852744310575\n", | ||
"Client 9 - Training AUC: 186.03125, Testing AUC: 60.72624798711756\n", | ||
"Client 10 - Training AUC: 178.59375, Testing AUC: 60.72624798711756\n", | ||
"Client 11 - Training AUC: 187.078125, Testing AUC: 60.72624798711756\n", | ||
"Client 12 - Training AUC: 181.203125, Testing AUC: 60.72624798711756\n", | ||
"\n", | ||
"Summary Statistics for Training AUC:\n", | ||
"Mean: 183.20442708333334, Median: 183.0078125, Standard Deviation: 3.6299101215838543\n", | ||
"\n", | ||
"Summary Statistics for Testing AUC:\n", | ||
"Mean: 52.386542124151255, Median: 55.803525641025644, Standard Deviation: 8.552703576636738\n", | ||
"\n", | ||
"Training Accuracies for each client and round:\n", | ||
"[[0.1875 0.125 0.25 ... 1. 1. 1. ]\n", | ||
" [0.09375 0.1875 0.28125 ... 1. 1. 0.96875]\n", | ||
" [0.15625 0.15625 0.25 ... 1. 1. 1. ]\n", | ||
" ...\n", | ||
" [0.1875 0.15625 0.28125 ... 1. 1. 1. ]\n", | ||
" [0.15625 0.21875 0.34375 ... 1. 1. 1. ]\n", | ||
" [0.1875 0.125 0.3125 ... 0.9375 1. 0.96875]]\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"train_acc = np.load('./train_accs.npy')\n", | ||
"test_acc = np.load('./test_accs.npy')\n", | ||
"\n", | ||
"print(\"Shape of train_acc:\", train_acc.shape)\n", | ||
"print(\"Shape of test_acc:\", test_acc.shape)\n", | ||
"\n", | ||
"# Ensure the arrays have the expected shape (12 clients, 210 epochs)\n", | ||
"if train_acc.shape[1] != 210 or test_acc.shape[1] != 210:\n", | ||
" raise ValueError(\"The accuracy arrays must have 210 epochs. Ensure shape is (num_clients, 210).\")\n", | ||
"\n", | ||
"train_auc = [np.trapz(train_acc[i, :]) for i in range(train_acc.shape[0])]\n", | ||
"test_auc = [np.trapz(test_acc[i, :]) for i in range(test_acc.shape[0])]\n", | ||
"\n", | ||
"print(\"Individual AUCs for each client:\")\n", | ||
"for i, (t_auc, te_auc) in enumerate(zip(train_auc, test_auc)):\n", | ||
" print(f\"Client {i+1} - Training AUC: {t_auc}, Testing AUC: {te_auc}\")\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1b8625b5-ab58-4f90-b099-0c9f7a83356c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"train_auc_mean = np.mean(train_auc)\n", | ||
"train_auc_median = np.median(train_auc)\n", | ||
"train_auc_std = np.std(train_auc)\n", | ||
"\n", | ||
"test_auc_mean = np.mean(test_auc)\n", | ||
"test_auc_median = np.median(test_auc)\n", | ||
"test_auc_std = np.std(test_auc)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "dd040a6b-7804-4b13-b516-52c3ff1e486c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(\"\\nSummary Statistics for Training AUC:\")\n", | ||
"print(f\"Mean: {train_auc_mean}, Median: {train_auc_median}, Standard Deviation: {train_auc_std}\")\n", | ||
"\n", | ||
"print(\"\\nSummary Statistics for Testing AUC:\")\n", | ||
"print(f\"Mean: {test_auc_mean}, Median: {test_auc_median}, Standard Deviation: {test_auc_std}\")\n", | ||
"\n", | ||
"print(\"\\nTraining Accuracies for each client and round:\")\n", | ||
"print(train_acc)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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