-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluationfile.py
More file actions
28 lines (21 loc) · 807 Bytes
/
evaluationfile.py
File metadata and controls
28 lines (21 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, classification_report
def evaluate_models(models,X_test, y_test):
results = {}
for name, model in models.items():
print(f"Evaluating: {name}")
y_pred = model.predict(X_test)
acc = accuracy_score(y_test, y_pred)
prec = precision_score(y_test, y_pred)
rec = recall_score(y_test, y_pred)
f1 = f1_score(y_test, y_pred)
print(f"Accuracy: {acc:.4f}")
print(f"Precison: {prec:.4f}")
print(f"Recall: {rec:.4f}")
print(f"F1 Score: {f1:.4f}")
results[name] = {
"accuracy": acc,
"precison": prec,
"recall": rec,
"f1_score": f1
}
return results