Amol Kaushik commited on
Commit
552944f
·
1 Parent(s): 3d8051f

added f1 score

Browse files
Files changed (2) hide show
  1. results/score_board.png +2 -2
  2. results/score_board.py +75 -44
results/score_board.png CHANGED

Git LFS Details

  • SHA256: cb8b7c08c73beddad5ebf3c90ebd703b763df3d5abedb4b4a963e3bff0014f36
  • Pointer size: 131 Bytes
  • Size of remote file: 131 kB

Git LFS Details

  • SHA256: cea0f15a634aeeeac08cef8247837daed7334802cdbf48ff92ac4e1b08b86e30
  • Pointer size: 131 Bytes
  • Size of remote file: 233 kB
results/score_board.py CHANGED
@@ -1,16 +1,12 @@
1
  import matplotlib.pyplot as plt
2
 
3
 
4
- def create_score_board(weeks=None, scores=None, save_path=None, show=False):
5
  """
6
- Create a score board plot for R^2 scores over weeks.
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
- if weeks is None:
25
- weeks = [0, 1, 2, 3, 4, 5]
26
- if scores is None:
27
- # Week 0: Start, Week 1: A2 baseline, Week 2: A2 outlier removal
28
- # Week 3: A4 Random Forest, Week 4: A5 Weighted Ensemble, Week 5: A5b (champion retained)
29
- scores = [0, 0.52, 0.59, 0.65, 0.7204, 0.7204]
30
-
31
- # Create figure and axis
32
- fig, ax = plt.subplots(figsize=(8, 6))
33
-
34
- # Plot the data
35
- ax.plot(
36
- weeks,
37
- scores,
 
 
 
 
 
 
38
  marker='o',
39
  linestyle='-',
40
- color='b',
41
  linewidth=2,
42
- markersize=8
43
  )
44
-
45
- # Set labels and title
46
- ax.set_xlabel('Week', fontsize=12)
47
- ax.set_ylabel('R^2 Score', fontsize=12)
48
- ax.set_title(
49
- 'R^2 Score Progression Over Weeks',
50
  fontsize=14,
51
  fontweight='bold'
52
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
- # Set x-axis ticks to be exactly the weeks
55
- ax.set_xticks(weeks)
56
- ax.set_xticklabels([f'Week {w}' for w in weeks])
57
-
58
- # Add grid for better readability
59
- ax.grid(True, linestyle='--', alpha=0.7)
60
-
61
- # Annotate each point with its score
62
- for i, (x, y) in enumerate(zip(weeks, scores)):
63
- ax.annotate(
64
- f'{y:.2f}',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  (x, y),
66
  textcoords="offset points",
67
  xytext=(0, 10),
68
- ha='center'
 
69
  )
70
 
71
- # Adjust layout to prevent clipping
 
72
  fig.tight_layout()
73
 
74
  # Save the plot if save_path is provided
75
  if save_path is not None:
76
- # we save it into the main directory
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
- # Example usage with default data
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
+ # 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)