Spaces:
Sleeping
Sleeping
Amol Kaushik commited on
Commit ·
552944f
1
Parent(s): 3d8051f
added f1 score
Browse files- results/score_board.png +2 -2
- results/score_board.py +75 -44
results/score_board.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
results/score_board.py
CHANGED
|
@@ -1,16 +1,12 @@
|
|
| 1 |
import matplotlib.pyplot as plt
|
| 2 |
|
| 3 |
|
| 4 |
-
def create_score_board(
|
| 5 |
"""
|
| 6 |
-
Create a score board plot for R^2 scores over
|
| 7 |
|
| 8 |
Parameters
|
| 9 |
----------
|
| 10 |
-
weeks : list, optional
|
| 11 |
-
List of week numbers. Default is [0, 1, 2].
|
| 12 |
-
scores : list, optional
|
| 13 |
-
List of R^2 scores. Default is [0, 0.51, 0.59].
|
| 14 |
save_path : str, optional
|
| 15 |
Path to save the plot. If None, the plot is not saved.
|
| 16 |
show : bool, optional
|
|
@@ -21,60 +17,95 @@ def create_score_board(weeks=None, scores=None, save_path=None, show=False):
|
|
| 21 |
fig : matplotlib.figure.Figure
|
| 22 |
The generated figure object.
|
| 23 |
"""
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
marker='o',
|
| 39 |
linestyle='-',
|
| 40 |
-
color='
|
| 41 |
linewidth=2,
|
| 42 |
-
markersize=
|
| 43 |
)
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
ax.set_title(
|
| 49 |
-
'R^2 Score Progression Over Weeks',
|
| 50 |
fontsize=14,
|
| 51 |
fontweight='bold'
|
| 52 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
(x, y),
|
| 66 |
textcoords="offset points",
|
| 67 |
xytext=(0, 10),
|
| 68 |
-
ha='center'
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
-
# Adjust layout
|
|
|
|
| 72 |
fig.tight_layout()
|
| 73 |
|
| 74 |
# Save the plot if save_path is provided
|
| 75 |
if save_path is not None:
|
| 76 |
-
|
| 77 |
-
fig.savefig(save_path, dpi=300)
|
| 78 |
print(f"Plot saved to {save_path}")
|
| 79 |
|
| 80 |
# Show the plot if requested
|
|
@@ -85,5 +116,5 @@ def create_score_board(weeks=None, scores=None, save_path=None, show=False):
|
|
| 85 |
|
| 86 |
|
| 87 |
if __name__ == "__main__":
|
| 88 |
-
#
|
| 89 |
fig = create_score_board(save_path='score_board.png', show=True)
|
|
|
|
| 1 |
import matplotlib.pyplot as plt
|
| 2 |
|
| 3 |
|
| 4 |
+
def create_score_board(save_path=None, show=False):
|
| 5 |
"""
|
| 6 |
+
Create a score board plot for R^2 and F1 scores over assignments.
|
| 7 |
|
| 8 |
Parameters
|
| 9 |
----------
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
save_path : str, optional
|
| 11 |
Path to save the plot. If None, the plot is not saved.
|
| 12 |
show : bool, optional
|
|
|
|
| 17 |
fig : matplotlib.figure.Figure
|
| 18 |
The generated figure object.
|
| 19 |
"""
|
| 20 |
+
# Assignment progression
|
| 21 |
+
assignments = ['Start', 'A2', 'A3', 'A4', 'A5', 'A5b/A6']
|
| 22 |
+
|
| 23 |
+
# R² Score progression (Regression)
|
| 24 |
+
# Start=0, A2 baseline=0.52, A2 outliers=0.59, A4 RF=0.65, A5 Ensemble=0.7204, A5b retained
|
| 25 |
+
r2_scores = [0, 0.52, 0.59, 0.65, 0.7204, 0.7204]
|
| 26 |
+
|
| 27 |
+
# F1 Score progression (Classification)
|
| 28 |
+
# Start=0, A2=N/A(0), A3 LDA=0.57, A4 RF=0.6110, A5 Ensemble=0.6484, A6 retained
|
| 29 |
+
f1_scores = [0, 0, 0.57, 0.6110, 0.6484, 0.6484]
|
| 30 |
+
|
| 31 |
+
# Create figure with 2 subplots
|
| 32 |
+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))
|
| 33 |
+
|
| 34 |
+
x_pos = range(len(assignments))
|
| 35 |
+
|
| 36 |
+
# Plot R² scores
|
| 37 |
+
ax1.plot(
|
| 38 |
+
x_pos,
|
| 39 |
+
r2_scores,
|
| 40 |
marker='o',
|
| 41 |
linestyle='-',
|
| 42 |
+
color='#4361ee',
|
| 43 |
linewidth=2,
|
| 44 |
+
markersize=10
|
| 45 |
)
|
| 46 |
+
ax1.set_xlabel('Assignment', fontsize=12)
|
| 47 |
+
ax1.set_ylabel('R² Score', fontsize=12)
|
| 48 |
+
ax1.set_title(
|
| 49 |
+
'Regression: R² Score Progression',
|
|
|
|
|
|
|
| 50 |
fontsize=14,
|
| 51 |
fontweight='bold'
|
| 52 |
)
|
| 53 |
+
ax1.set_xticks(x_pos)
|
| 54 |
+
ax1.set_xticklabels(assignments)
|
| 55 |
+
ax1.set_ylim(0, 0.85)
|
| 56 |
+
ax1.grid(True, linestyle='--', alpha=0.7)
|
| 57 |
+
ax1.axhline(y=0.7204, color='green', linestyle=':', alpha=0.5, label='Champion')
|
| 58 |
+
|
| 59 |
+
for i, (x, y) in enumerate(zip(x_pos, r2_scores)):
|
| 60 |
+
ax1.annotate(
|
| 61 |
+
f'{y:.2f}' if y > 0 else '',
|
| 62 |
+
(x, y),
|
| 63 |
+
textcoords="offset points",
|
| 64 |
+
xytext=(0, 10),
|
| 65 |
+
ha='center',
|
| 66 |
+
fontweight='bold'
|
| 67 |
+
)
|
| 68 |
|
| 69 |
+
# Plot F1 scores
|
| 70 |
+
ax2.plot(
|
| 71 |
+
x_pos,
|
| 72 |
+
f1_scores,
|
| 73 |
+
marker='s',
|
| 74 |
+
linestyle='-',
|
| 75 |
+
color='#06d6a0',
|
| 76 |
+
linewidth=2,
|
| 77 |
+
markersize=10
|
| 78 |
+
)
|
| 79 |
+
ax2.set_xlabel('Assignment', fontsize=12)
|
| 80 |
+
ax2.set_ylabel('F1 Score (weighted)', fontsize=12)
|
| 81 |
+
ax2.set_title(
|
| 82 |
+
'Classification: F1 Score Progression',
|
| 83 |
+
fontsize=14,
|
| 84 |
+
fontweight='bold'
|
| 85 |
+
)
|
| 86 |
+
ax2.set_xticks(x_pos)
|
| 87 |
+
ax2.set_xticklabels(assignments)
|
| 88 |
+
ax2.set_ylim(0, 0.85)
|
| 89 |
+
ax2.grid(True, linestyle='--', alpha=0.7)
|
| 90 |
+
ax2.axhline(y=0.6484, color='green', linestyle=':', alpha=0.5, label='Champion')
|
| 91 |
+
|
| 92 |
+
for i, (x, y) in enumerate(zip(x_pos, f1_scores)):
|
| 93 |
+
ax2.annotate(
|
| 94 |
+
f'{y:.2f}' if y > 0 else '',
|
| 95 |
(x, y),
|
| 96 |
textcoords="offset points",
|
| 97 |
xytext=(0, 10),
|
| 98 |
+
ha='center',
|
| 99 |
+
fontweight='bold'
|
| 100 |
)
|
| 101 |
|
| 102 |
+
# Adjust layout
|
| 103 |
+
fig.suptitle('Model Performance Progression', fontsize=16, fontweight='bold', y=1.02)
|
| 104 |
fig.tight_layout()
|
| 105 |
|
| 106 |
# Save the plot if save_path is provided
|
| 107 |
if save_path is not None:
|
| 108 |
+
fig.savefig(save_path, dpi=300, bbox_inches='tight')
|
|
|
|
| 109 |
print(f"Plot saved to {save_path}")
|
| 110 |
|
| 111 |
# Show the plot if requested
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
| 119 |
+
# Generate the score board
|
| 120 |
fig = create_score_board(save_path='score_board.png', show=True)
|