thinkwee commited on
Commit
3d06da8
·
1 Parent(s): 8735f85

exact python match

Browse files
Files changed (2) hide show
  1. charts.js +41 -20
  2. data.js +0 -0
charts.js CHANGED
@@ -80,6 +80,14 @@ document.querySelectorAll('.nav-tab').forEach(tab => {
80
  // ============================================================================
81
  // SCALING ANALYSIS - 3 Charts with animated dimension switching
82
  // ============================================================================
 
 
 
 
 
 
 
 
83
  function initScalingCharts() {
84
  const scenarios = ['mimic', '10k', 'globem'];
85
 
@@ -103,31 +111,32 @@ function initScalingCharts() {
103
  width: 2
104
  },
105
  marker: {
106
- size: 5,
107
  color: DDR_DATA.modelColors[model] || '#888'
108
  },
109
- hovertemplate: `<b>${model}</b><br>Turn: %{x}<br>Accuracy: %{y:.1f}%<extra></extra>`
110
  });
111
  });
112
 
113
- // Calculate Y-axis range (similar to Python: round to nearest 5)
114
- const allAccuracies = models.flatMap(m => data[m].accuracy);
115
- const yMin = Math.max(0, Math.floor(Math.min(...allAccuracies) / 5) * 5);
116
- const yMax = (Math.floor(Math.max(...allAccuracies) / 5) + 1) * 5 + 5;
117
 
118
  const layout = {
119
  ...darkLayout,
120
  xaxis: {
121
  ...darkLayout.xaxis,
122
  title: { text: 'Number of Interaction Turns', font: { size: 11, color: '#e2e8f0' } },
123
- dtick: 5, // 5 turn intervals
124
- range: [0, Math.max(...models.flatMap(m => data[m].turns)) + 2]
 
125
  },
126
  yaxis: {
127
  ...darkLayout.yaxis,
128
  title: { text: 'Accuracy (%)', font: { size: 11, color: '#e2e8f0' } },
129
  dtick: 5, // 5% intervals
130
- range: [yMin, yMax]
 
131
  },
132
  showlegend: true
133
  };
@@ -173,25 +182,35 @@ function updateScalingCharts(dimension) {
173
  newY.push(modelData.accuracy);
174
  });
175
 
 
 
176
  // Calculate proper axis settings for each dimension
177
  const xAxisSettings = {
178
  'turn': {
179
- dtick: 5,
 
180
  tickformat: null,
181
- range: [0, Math.max(...newX.flat()) + 2]
 
182
  },
183
  'token': {
184
- dtick: 5000,
 
185
  tickformat: ',.0f',
186
- range: [0, Math.max(...newX.flat()) * 1.05]
 
187
  },
188
  'cost': {
 
189
  dtick: null, // auto for log scale
190
- tickformat: '$.2f',
191
- range: null // auto for log scale
 
192
  }
193
  };
194
 
 
 
195
  // Animate the transition
196
  Plotly.animate(`scaling-${scenario}`, {
197
  data: newX.map((x, i) => ({ x, y: newY[i] })),
@@ -199,10 +218,11 @@ function updateScalingCharts(dimension) {
199
  layout: {
200
  xaxis: {
201
  title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
202
- type: dimension === 'cost' ? 'log' : 'linear',
203
- dtick: xAxisSettings[dimension].dtick,
204
- tickformat: xAxisSettings[dimension].tickformat,
205
- range: xAxisSettings[dimension].range,
 
206
  exponentformat: 'none'
207
  }
208
  }
@@ -218,12 +238,13 @@ function updateScalingCharts(dimension) {
218
  models.forEach((model, i) => {
219
  const hoverFormat = dimension === 'token' ? '%{x:,.0f}' : (dimension === 'cost' ? '$%{x:.4f}' : '%{x}');
220
  Plotly.restyle(`scaling-${scenario}`, {
221
- hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: ${hoverFormat}<br>Accuracy: %{y:.1f}%<extra></extra>`
222
  }, [i]);
223
  });
224
  });
225
  }
226
 
 
227
  // Dimension toggle event listeners
228
  document.querySelectorAll('.dim-btn:not(.probing-dim)').forEach(btn => {
229
  btn.addEventListener('click', () => {
 
80
  // ============================================================================
81
  // SCALING ANALYSIS - 3 Charts with animated dimension switching
82
  // ============================================================================
83
+
84
+ // Exact axis ranges from Python scripts
85
+ const SCALING_Y_RANGES = {
86
+ 'mimic': [5, 40], // Python: y_min=5, y_max=40
87
+ '10k': [0, 85], // Python: y_min=0, y_max=85
88
+ 'globem': [0, 50] // Python: y_min=0, y_max=50
89
+ };
90
+
91
  function initScalingCharts() {
92
  const scenarios = ['mimic', '10k', 'globem'];
93
 
 
111
  width: 2
112
  },
113
  marker: {
114
+ size: 6,
115
  color: DDR_DATA.modelColors[model] || '#888'
116
  },
117
+ hovertemplate: `<b>${model}</b><br>Turn: %{x}<br>Accuracy: %{y:.2f}%<extra></extra>`
118
  });
119
  });
120
 
121
+ // Use exact Y-axis range from Python
122
+ const yRange = SCALING_Y_RANGES[scenario] || [0, 100];
123
+ const maxTurn = Math.max(...models.flatMap(m => data[m].turns));
 
124
 
125
  const layout = {
126
  ...darkLayout,
127
  xaxis: {
128
  ...darkLayout.xaxis,
129
  title: { text: 'Number of Interaction Turns', font: { size: 11, color: '#e2e8f0' } },
130
+ dtick: 10, // 10 turn intervals (matching Python's auto)
131
+ range: [0, maxTurn + 5],
132
+ tick0: 0
133
  },
134
  yaxis: {
135
  ...darkLayout.yaxis,
136
  title: { text: 'Accuracy (%)', font: { size: 11, color: '#e2e8f0' } },
137
  dtick: 5, // 5% intervals
138
+ range: yRange,
139
+ tick0: yRange[0]
140
  },
141
  showlegend: true
142
  };
 
182
  newY.push(modelData.accuracy);
183
  });
184
 
185
+ const maxX = Math.max(...newX.flat());
186
+
187
  // Calculate proper axis settings for each dimension
188
  const xAxisSettings = {
189
  'turn': {
190
+ type: 'linear',
191
+ dtick: 10,
192
  tickformat: null,
193
+ range: [0, maxX + 5],
194
+ tick0: 0
195
  },
196
  'token': {
197
+ type: 'linear',
198
+ dtick: 10000,
199
  tickformat: ',.0f',
200
+ range: [0, maxX * 1.05],
201
+ tick0: 0
202
  },
203
  'cost': {
204
+ type: 'log',
205
  dtick: null, // auto for log scale
206
+ tickformat: '$.3f',
207
+ range: null, // auto for log scale
208
+ tick0: null
209
  }
210
  };
211
 
212
+ const settings = xAxisSettings[dimension];
213
+
214
  // Animate the transition
215
  Plotly.animate(`scaling-${scenario}`, {
216
  data: newX.map((x, i) => ({ x, y: newY[i] })),
 
218
  layout: {
219
  xaxis: {
220
  title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
221
+ type: settings.type,
222
+ dtick: settings.dtick,
223
+ tickformat: settings.tickformat,
224
+ range: settings.range,
225
+ tick0: settings.tick0,
226
  exponentformat: 'none'
227
  }
228
  }
 
238
  models.forEach((model, i) => {
239
  const hoverFormat = dimension === 'token' ? '%{x:,.0f}' : (dimension === 'cost' ? '$%{x:.4f}' : '%{x}');
240
  Plotly.restyle(`scaling-${scenario}`, {
241
+ hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: ${hoverFormat}<br>Accuracy: %{y:.2f}%<extra></extra>`
242
  }, [i]);
243
  });
244
  });
245
  }
246
 
247
+
248
  // Dimension toggle event listeners
249
  document.querySelectorAll('.dim-btn:not(.probing-dim)').forEach(btn => {
250
  btn.addEventListener('click', () => {
data.js CHANGED
The diff for this file is too large to render. See raw diff