Koshti10 commited on
Commit
55ef912
·
verified ·
1 Parent(s): d20b1b4

Upload trend_utils.py

Browse files
Files changed (1) hide show
  1. src/trend_utils.py +11 -15
src/trend_utils.py CHANGED
@@ -87,13 +87,13 @@ def populate_list(df: pd.DataFrame, abs_diff: float) -> list:
87
  return l
88
 
89
 
90
- def get_models_to_display(result_df: pd.DataFrame, open_diff: float = -0.5, comm_diff: float = -10) -> tuple:
91
  """Retrieve models to display based on clemscore differences.
92
 
93
  Args:
94
  result_df (pd.DataFrame): DataFrame containing model data.
95
- open_diff (float, optional): Threshold for open models. Defaults to -0.5.
96
- comm_diff (float, optional): Threshold for commercial models. Defaults to -10.
97
 
98
  Returns:
99
  tuple: Two lists of model names (open and commercial).
@@ -103,8 +103,8 @@ def get_models_to_display(result_df: pd.DataFrame, open_diff: float = -0.5, comm
103
 
104
  open_model_df = open_model_df.sort_values(by='release_date', ascending=True)
105
  comm_model_df = comm_model_df.sort_values(by='release_date', ascending=True)
106
- open_models = populate_list(open_model_df, open_diff)
107
- comm_models = populate_list(comm_model_df, comm_diff)
108
  return open_models, comm_models
109
 
110
 
@@ -154,20 +154,18 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
154
  benchmark_ticks (dict, optional): Custom benchmark ticks for the version dates. Defaults to {}.
155
 
156
  Keyword Args:
157
- open_diff (float, optional): Threshold for open models' clemscore differences. Max dip in clemscore allowed to be considered in trend.
158
- comm_diff (float, optional): Threshold for commercial models' clemscore differences. Max dip in clemscore allowed to be considered in trend.
159
  height (int, optional): Height of the plot in pixels. Adjusted for mobile or desktop views.
160
- width (int, optional): Width of the plot in pixels. Adjusted for mobile or desktop views.
161
  mobile_view (bool, optional): Flag to indicate if the plot should be optimized for mobile display. Defaults to False.
162
 
163
  Returns:
164
  go.Figure: The generated plot.
165
  """
166
 
167
- open_diff = plot_kwargs['open_diff']
168
- comm_diff = plot_kwargs['comm_diff']
169
  height = plot_kwargs['height']
170
- width = plot_kwargs['width']
171
 
172
  mobile_view = True if plot_kwargs['mobile_view'] else False
173
 
@@ -176,7 +174,7 @@ def get_plot(df: pd.DataFrame, start_date: str = '2023-06-01', end_date: str = '
176
  df['Release date'] = pd.to_datetime(df['release_date'], format='ISO8601')
177
  # Filter out data before April 2023
178
  df = df[df['Release date'] >= pd.to_datetime(start_date)]
179
- open_model_list, comm_model_list = get_models_to_display(df, open_diff, comm_diff)
180
  models_to_display = open_model_list + comm_model_list
181
  print(f"open_model_list: {open_model_list}, comm_model_list: {comm_model_list}")
182
 
@@ -334,12 +332,10 @@ def get_final_trend_plot(benchmark: str = "Text", mobile_view: bool = False) ->
334
 
335
  if mobile_view:
336
  height = 450
337
- width = 300
338
  else:
339
  height = 1000
340
- width = 1450
341
 
342
- plot_kwargs = {'height': height, 'width': width, 'open_diff': -0.5, 'comm_diff': -5,
343
  'mobile_view': mobile_view}
344
 
345
  if benchmark == "Text":
 
87
  return l
88
 
89
 
90
+ def get_models_to_display(result_df: pd.DataFrame, open_dip: float = -0.5, comm_dip: float = -10) -> tuple:
91
  """Retrieve models to display based on clemscore differences.
92
 
93
  Args:
94
  result_df (pd.DataFrame): DataFrame containing model data.
95
+ open_dip (float, optional): Threshold for open models. Defaults to -0.5.
96
+ comm_dip (float, optional): Threshold for commercial models. Defaults to -10.
97
 
98
  Returns:
99
  tuple: Two lists of model names (open and commercial).
 
103
 
104
  open_model_df = open_model_df.sort_values(by='release_date', ascending=True)
105
  comm_model_df = comm_model_df.sort_values(by='release_date', ascending=True)
106
+ open_models = populate_list(open_model_df, open_dip)
107
+ comm_models = populate_list(comm_model_df, comm_dip)
108
  return open_models, comm_models
109
 
110
 
 
154
  benchmark_ticks (dict, optional): Custom benchmark ticks for the version dates. Defaults to {}.
155
 
156
  Keyword Args:
157
+ open_dip (float, optional): Threshold for open models' clemscore differences. Max dip in clemscore allowed to be considered in trend.
158
+ comm_dip (float, optional): Threshold for commercial models' clemscore differences. Max dip in clemscore allowed to be considered in trend.
159
  height (int, optional): Height of the plot in pixels. Adjusted for mobile or desktop views.
 
160
  mobile_view (bool, optional): Flag to indicate if the plot should be optimized for mobile display. Defaults to False.
161
 
162
  Returns:
163
  go.Figure: The generated plot.
164
  """
165
 
166
+ open_dip = plot_kwargs['open_dip']
167
+ comm_dip = plot_kwargs['comm_dip']
168
  height = plot_kwargs['height']
 
169
 
170
  mobile_view = True if plot_kwargs['mobile_view'] else False
171
 
 
174
  df['Release date'] = pd.to_datetime(df['release_date'], format='ISO8601')
175
  # Filter out data before April 2023
176
  df = df[df['Release date'] >= pd.to_datetime(start_date)]
177
+ open_model_list, comm_model_list = get_models_to_display(df, open_dip, comm_dip)
178
  models_to_display = open_model_list + comm_model_list
179
  print(f"open_model_list: {open_model_list}, comm_model_list: {comm_model_list}")
180
 
 
332
 
333
  if mobile_view:
334
  height = 450
 
335
  else:
336
  height = 1000
 
337
 
338
+ plot_kwargs = {'height': height, 'open_dip': -0.5, 'comm_dip': -5,
339
  'mobile_view': mobile_view}
340
 
341
  if benchmark == "Text":