Koshti10 commited on
Commit
10d2879
1 Parent(s): aa96db8

Update src/trend_utils.py

Browse files
Files changed (1) hide show
  1. src/trend_utils.py +26 -10
src/trend_utils.py CHANGED
@@ -169,6 +169,7 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
169
  open_dip = plot_kwargs['open_dip']
170
  comm_dip = plot_kwargs['comm_dip']
171
  height = plot_kwargs['height']
 
172
 
173
  mobile_view = True if plot_kwargs['mobile_view'] else False
174
 
@@ -204,8 +205,18 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
204
  hover_name="model",
205
  size=marker_size,
206
  size_max=40, # Max size of the circles
207
- template="plotly_white")
208
-
 
 
 
 
 
 
 
 
 
 
209
 
210
  # Sort dataframes for line plotting
211
  df_open = df[df['model'].isin(open_model_list)].sort_values(by='Release date')
@@ -252,7 +263,7 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
252
  mode='markers',
253
  line=dict(color='rgba(255,255,255,0)', width=0), # Fully transparent line
254
  hovertext=[
255
- f"Version: {version} released on {date.strftime("%d %b %Y")}, last updated on: {update_date.strftime("%d %b %Y")}"
256
  for _ in range(100)
257
  ], # Unique hovertext for all points
258
  hoverinfo="text",
@@ -273,13 +284,13 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
273
  benchmark_tick_texts = []
274
  for i in range(len(benchmark_tickvals)):
275
  if i == 0:
276
- benchmark_tick_texts.append(f"<br><span style='font-size:7px;'><b>{benchmark_ticks[benchmark_tickvals[i]]}</b></span>")
277
  else:
278
  date_diff = (benchmark_tickvals[i] - benchmark_tickvals[i - 1]).days
279
- if date_diff <= 60:
280
- benchmark_tick_texts.append(f"<br><br><span style='font-size:7px;'><b>{benchmark_ticks[benchmark_tickvals[i]]}</b></span>")
281
  else:
282
- benchmark_tick_texts.append(f"<br><span style='font-size:7px;'><b>{benchmark_ticks[benchmark_tickvals[i]]}</b></span>")
283
  fig.update_xaxes(
284
  tickvals=filtered_custom_tickvals + benchmark_tickvals, # Use filtered_custom_tickvals
285
  ticktext=[f"{date.strftime('%b')}<br>{date.strftime('%y')}" for date in filtered_custom_tickvals] +
@@ -331,6 +342,10 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
331
  )
332
  )
333
 
 
 
 
 
334
  return fig
335
 
336
  def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) -> go.Figure:
@@ -359,11 +374,12 @@ def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) ->
359
 
360
  if mobile_view:
361
  height = 450
 
362
  else:
363
  height = 1000
 
364
 
365
-
366
- plot_kwargs = {'height': height, 'open_dip': 0, 'comm_dip': 0,
367
  'mobile_view': mobile_view}
368
 
369
  benchmark_ticks = {}
@@ -391,7 +407,7 @@ def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) ->
391
  temp_ver = temp_ver.replace('_multimodal', '')
392
  benchmark_ticks[pd.to_datetime(ver['release_date'])] = temp_ver ## MM benchmark dates considered after v1.6 (incl.)
393
  benchmark_update[pd.to_datetime(ver['last_updated'])] = temp_ver
394
-
395
  fig = get_plot(df, start_date=START_DATE, end_date=datetime.now().strftime('%Y-%m-%d'), benchmark_ticks=benchmark_ticks, benchmark_update=benchmark_update, **plot_kwargs)
396
 
397
  return fig
 
169
  open_dip = plot_kwargs['open_dip']
170
  comm_dip = plot_kwargs['comm_dip']
171
  height = plot_kwargs['height']
172
+ width = plot_kwargs['width']
173
 
174
  mobile_view = True if plot_kwargs['mobile_view'] else False
175
 
 
205
  hover_name="model",
206
  size=marker_size,
207
  size_max=40, # Max size of the circles
208
+ template="plotly_white",
209
+ hover_data={ # Customize hover information
210
+ "Release date": True, # Show the release date
211
+ "clemscore": True, # Show the clemscore
212
+ "Model Type": True # Show the model type
213
+ },
214
+ custom_data=["model", "Release date", "clemscore"] # Specify custom data columns for hover
215
+ )
216
+
217
+ fig.update_traces(
218
+ hovertemplate='Model Name: %{customdata[0]}<br>Release date: %{customdata[1]}<br>Clemscore: %{customdata[2]}<br>'
219
+ )
220
 
221
  # Sort dataframes for line plotting
222
  df_open = df[df['model'].isin(open_model_list)].sort_values(by='Release date')
 
263
  mode='markers',
264
  line=dict(color='rgba(255,255,255,0)', width=0), # Fully transparent line
265
  hovertext=[
266
+ f"Version: {version} released on {date.strftime('%d %b %Y')}, last updated on: {update_date.strftime('%d %b %Y')}"
267
  for _ in range(100)
268
  ], # Unique hovertext for all points
269
  hoverinfo="text",
 
284
  benchmark_tick_texts = []
285
  for i in range(len(benchmark_tickvals)):
286
  if i == 0:
287
+ benchmark_tick_texts.append(f"<br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
288
  else:
289
  date_diff = (benchmark_tickvals[i] - benchmark_tickvals[i - 1]).days
290
+ if date_diff <= 75:
291
+ benchmark_tick_texts.append(f"<br><br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
292
  else:
293
+ benchmark_tick_texts.append(f"<br><br><b>{benchmark_ticks[benchmark_tickvals[i]]}</b>")
294
  fig.update_xaxes(
295
  tickvals=filtered_custom_tickvals + benchmark_tickvals, # Use filtered_custom_tickvals
296
  ticktext=[f"{date.strftime('%b')}<br>{date.strftime('%y')}" for date in filtered_custom_tickvals] +
 
342
  )
343
  )
344
 
345
+ if width:
346
+ print("Custom Seting the Width :")
347
+ fig.update_layout(width=width)
348
+
349
  return fig
350
 
351
  def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) -> go.Figure:
 
374
 
375
  if mobile_view:
376
  height = 450
377
+ width = 375
378
  else:
379
  height = 1000
380
+ width = None
381
 
382
+ plot_kwargs = {'height': height, 'width': width, 'open_dip': 0, 'comm_dip': 0,
 
383
  'mobile_view': mobile_view}
384
 
385
  benchmark_ticks = {}
 
407
  temp_ver = temp_ver.replace('_multimodal', '')
408
  benchmark_ticks[pd.to_datetime(ver['release_date'])] = temp_ver ## MM benchmark dates considered after v1.6 (incl.)
409
  benchmark_update[pd.to_datetime(ver['last_updated'])] = temp_ver
410
+
411
  fig = get_plot(df, start_date=START_DATE, end_date=datetime.now().strftime('%Y-%m-%d'), benchmark_ticks=benchmark_ticks, benchmark_update=benchmark_update, **plot_kwargs)
412
 
413
  return fig