Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import time
|
|
6 |
|
7 |
from sklearn.model_selection import train_test_split
|
8 |
from sklearn.metrics import accuracy_score
|
|
|
9 |
|
10 |
# Load and prepare data
|
11 |
data = pd.read_csv("parkinsons.data")
|
@@ -30,9 +31,11 @@ def run_dare_demo(delete_index=25):
|
|
30 |
|
31 |
y_pred = model.predict(X_test)
|
32 |
acc_before = accuracy_score(y_test, y_pred)
|
|
|
33 |
|
34 |
logs += f"✅ Initial training completed in {train_time:.4f} seconds\n"
|
35 |
-
logs += f"🎯 Accuracy before unlearning: {acc_before:.4f}\n"
|
|
|
36 |
|
37 |
# Delete a data point
|
38 |
try:
|
@@ -41,9 +44,11 @@ def run_dare_demo(delete_index=25):
|
|
41 |
delete_time = time.perf_counter() - start_del
|
42 |
y_pred_after = model.predict(X_test.astype(np.float32))
|
43 |
acc_after = accuracy_score(y_test, y_pred_after)
|
|
|
44 |
|
45 |
logs += f"\n🧽 Deleted index {delete_index} in {delete_time:.5f} seconds\n"
|
46 |
-
logs += f"🎯 Accuracy after unlearning: {acc_after:.4f}\n"
|
|
|
47 |
except Exception as e:
|
48 |
logs += f"\n⚠️ Error during unlearning: {str(e)}\n"
|
49 |
|
@@ -59,10 +64,12 @@ def run_dare_demo(delete_index=25):
|
|
59 |
|
60 |
y_pred_retrain = retrain_model.predict(X_test)
|
61 |
acc_retrain = accuracy_score(y_test, y_pred_retrain)
|
|
|
62 |
|
63 |
|
64 |
logs += f"\n🔁 Retraining completed in {retrain_time:.5f} seconds (without index {delete_index})\n"
|
65 |
-
logs += f"🎯 Accuracy after retraining: {acc_retrain:.4f}\n"
|
|
|
66 |
except Exception as e:
|
67 |
logs += f"\n⚠️ Error during retraining: {str(e)}\n"
|
68 |
|
|
|
6 |
|
7 |
from sklearn.model_selection import train_test_split
|
8 |
from sklearn.metrics import accuracy_score
|
9 |
+
from sklearn.metrics import f1_score
|
10 |
|
11 |
# Load and prepare data
|
12 |
data = pd.read_csv("parkinsons.data")
|
|
|
31 |
|
32 |
y_pred = model.predict(X_test)
|
33 |
acc_before = accuracy_score(y_test, y_pred)
|
34 |
+
f1_before = f1_score(y_test, y_pred, average='macro')
|
35 |
|
36 |
logs += f"✅ Initial training completed in {train_time:.4f} seconds\n"
|
37 |
+
#logs += f"🎯 Accuracy before unlearning: {acc_before:.4f}\n"
|
38 |
+
logs += f"🎯 F1-score before unlearning: {f1_before:.4f}\n"
|
39 |
|
40 |
# Delete a data point
|
41 |
try:
|
|
|
44 |
delete_time = time.perf_counter() - start_del
|
45 |
y_pred_after = model.predict(X_test.astype(np.float32))
|
46 |
acc_after = accuracy_score(y_test, y_pred_after)
|
47 |
+
f1_after = f1_score(y_test, y_pred_after, average='macro')
|
48 |
|
49 |
logs += f"\n🧽 Deleted index {delete_index} in {delete_time:.5f} seconds\n"
|
50 |
+
#logs += f"🎯 Accuracy after unlearning: {acc_after:.4f}\n"
|
51 |
+
logs += f"🎯 F1-score after unlearning: {acc_after:.4f}\n"
|
52 |
except Exception as e:
|
53 |
logs += f"\n⚠️ Error during unlearning: {str(e)}\n"
|
54 |
|
|
|
64 |
|
65 |
y_pred_retrain = retrain_model.predict(X_test)
|
66 |
acc_retrain = accuracy_score(y_test, y_pred_retrain)
|
67 |
+
f1_unlearn = f1_score(y_test, y_pred_retrain, average='macro')
|
68 |
|
69 |
|
70 |
logs += f"\n🔁 Retraining completed in {retrain_time:.5f} seconds (without index {delete_index})\n"
|
71 |
+
#logs += f"🎯 Accuracy after retraining: {acc_retrain:.4f}\n"
|
72 |
+
logs += f"🎯 F1-score after retraining: {f1_unlearn:.4f}\n"
|
73 |
except Exception as e:
|
74 |
logs += f"\n⚠️ Error during retraining: {str(e)}\n"
|
75 |
|