-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetrics.py
More file actions
24 lines (17 loc) · 699 Bytes
/
metrics.py
File metadata and controls
24 lines (17 loc) · 699 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
from sklearn import metrics
import seaborn as sns
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
plt.rcParams['figure.figsize'] = [8, 6]
def metric_scores(y_true, y_pred):
cm = metrics.confusion_matrix(y_true, y_pred)
ax = sns.heatmap(cm, annot = True, cmap = 'YlGnBu', fmt='.2f')
ax.set(title = "Confusion Matrix", xlabel = 'Predicted Labels', ylabel = 'True Labels')
cls_report = metrics.classification_report(y_true, y_pred)
print ("")
print (f"Accuracy : {metrics.accuracy_score(y_true, y_pred)*100 : .3f} %")
print ("")
print ("Classification Report : ")
print (cls_report)
plt.show()