forked from mbk2103/ResNet101-Implementation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluate_visualization.py
More file actions
27 lines (25 loc) · 872 Bytes
/
Copy pathevaluate_visualization.py
File metadata and controls
27 lines (25 loc) · 872 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
import torch
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import seaborn as sns
# Evaluation and Visualization class
class EvaluateVisualization:
@staticmethod
def plot_loss_curve(train_losses, val_losses):
plt.figure(figsize=(10, 5))
plt.plot(train_losses, label='Training Loss')
plt.plot(val_losses, label='Validation Loss')
plt.title('Training and Validation Loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show()
@staticmethod
def plot_confusion_matrix(y_true, y_pred, class_names):
conf_matrix = confusion_matrix(y_true, y_pred)
plt.figure(figsize=(8 ,8))
sns.heatmap(conf_matrix, annot=True, fmt="d", cmap="Oranges", xticklabels=class_names, yticklabels=class_names)
plt.title('Confusion Matrix')
plt.xlabel('Predicted')
plt.ylabel('True')
plt.show