sh1gechan commited on
Commit
1926e3c
1 Parent(s): e6bcb8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -143,37 +143,41 @@ def filter_queries(query: str, filtered_df: pd.DataFrame):
143
  def filter_models(
144
  df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, add_special_tokens_query: list, num_few_shots_query: list, show_deleted: bool, show_merges: bool, show_flagged: bool
145
  ) -> pd.DataFrame:
146
- print(f"filter_models called with: type_query={type_query}, size_query={size_query}, precision_query={precision_query}")
147
  print(f"Initial df shape: {df.shape}")
 
148
 
149
- # 各フィルタリング操作の後にprint文を追加
150
  if show_deleted:
151
  filtered_df = df
152
  else:
153
  filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
154
  print(f"After deletion filter: {filtered_df.shape}")
 
155
 
156
  type_emoji = [t[0] for t in type_query]
157
- filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
158
  print(f"After type filter: {filtered_df.shape}")
 
159
 
160
- # filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
161
- # print(f"After precision filter: {filtered_df.shape}")
 
162
 
163
- filtered_df = filtered_df.loc[df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
164
  print(f"After add_special_tokens filter: {filtered_df.shape}")
 
165
 
166
- filtered_df = filtered_df.loc[df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
167
  print(f"After num_few_shots filter: {filtered_df.shape}")
 
168
 
169
  numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
170
- params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
171
  mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
172
  filtered_df = filtered_df.loc[mask]
173
  print(f"After size filter: {filtered_df.shape}")
 
174
 
175
- print("Filtered dataframe head:")
176
- print(filtered_df.head())
177
  return filtered_df
178
 
179
  leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
@@ -261,7 +265,7 @@ with demo:
261
  value=leaderboard_df[
262
  [c.name for c in fields(AutoEvalColumn) if c.never_hidden]
263
  + shown_columns.value
264
- ].to_dict('records'), # DataFrameを辞書のリストに変換
265
  headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
266
  datatype=TYPES,
267
  elem_id="leaderboard-table",
 
143
  def filter_models(
144
  df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, add_special_tokens_query: list, num_few_shots_query: list, show_deleted: bool, show_merges: bool, show_flagged: bool
145
  ) -> pd.DataFrame:
146
+ print(f"filter_models called with: type_query={type_query}, size_query={size_query}, precision_query={precision_query}, add_special_tokens_query={add_special_tokens_query}, num_few_shots_query={num_few_shots_query}")
147
  print(f"Initial df shape: {df.shape}")
148
+ print(f"Initial df content:\n{df}")
149
 
 
150
  if show_deleted:
151
  filtered_df = df
152
  else:
153
  filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
154
  print(f"After deletion filter: {filtered_df.shape}")
155
+ print(f"After deletion filter content:\n{filtered_df}")
156
 
157
  type_emoji = [t[0] for t in type_query]
158
+ filtered_df = filtered_df.loc[filtered_df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
159
  print(f"After type filter: {filtered_df.shape}")
160
+ print(f"After type filter content:\n{filtered_df}")
161
 
162
+ filtered_df = filtered_df.loc[filtered_df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
163
+ print(f"After precision filter: {filtered_df.shape}")
164
+ print(f"After precision filter content:\n{filtered_df}")
165
 
166
+ filtered_df = filtered_df.loc[filtered_df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
167
  print(f"After add_special_tokens filter: {filtered_df.shape}")
168
+ print(f"After add_special_tokens filter content:\n{filtered_df}")
169
 
170
+ filtered_df = filtered_df.loc[filtered_df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
171
  print(f"After num_few_shots filter: {filtered_df.shape}")
172
+ print(f"After num_few_shots filter content:\n{filtered_df}")
173
 
174
  numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
175
+ params_column = pd.to_numeric(filtered_df[AutoEvalColumn.params.name], errors="coerce")
176
  mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
177
  filtered_df = filtered_df.loc[mask]
178
  print(f"After size filter: {filtered_df.shape}")
179
+ print(f"After size filter content:\n{filtered_df}")
180
 
 
 
181
  return filtered_df
182
 
183
  leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
 
265
  value=leaderboard_df[
266
  [c.name for c in fields(AutoEvalColumn) if c.never_hidden]
267
  + shown_columns.value
268
+ ],
269
  headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
270
  datatype=TYPES,
271
  elem_id="leaderboard-table",