-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmetrics.py
More file actions
28 lines (22 loc) · 839 Bytes
/
metrics.py
File metadata and controls
28 lines (22 loc) · 839 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
import matplotlib.pyplot as plt
import numpy as np
models = ["Baseline RF", "Depth-Adaptive RF"]
train_accuracies = [96.15, 92.79]
test_accuracies = [83.15, 86.52]
x = np.arange(len(models))
width = 0.35
fig, ax = plt.subplots(figsize=(8,5))
rects1 = ax.bar(x - width/2, train_accuracies, width, label='Train Accuracy')
rects2 = ax.bar(x + width/2, test_accuracies, width, label='Test Accuracy')
ax.set_ylabel('Accuracy (%)')
ax.set_xlabel('Model')
ax.set_title('Training vs. Test Accuracy for Random Forest Models')
ax.set_xticks(x)
ax.set_xticklabels(models)
ax.legend()
ax.set_ylim(0, 100)
for rect in rects1 + rects2:
height = rect.get_height()
ax.annotate(f'{height:.2f}%', xy=(rect.get_x() + rect.get_width()/2, height), xytext=(0,3), textcoords="offset points", ha='center', va='bottom')
plt.tight_layout()
plt.show()