YchKhan commited on
Commit
0e5b659
1 Parent(s): 5ffe869

Update classification.py

Browse files
Files changed (1) hide show
  1. classification.py +5 -5
classification.py CHANGED
@@ -178,17 +178,17 @@ def match_categories(df, category_df, treshold=0.45):
178
  if isinstance(ebd_content, torch.Tensor):
179
  cos_scores = util.cos_sim(ebd_content, torch.stack(list(category_df['Embeddings']), dim=0))[0]
180
  high_score_indices = [i for i, score in enumerate(cos_scores) if score > treshold]
181
- categories_list.append([category_df.loc[index, 'description'] for index in high_score_indices])
182
- experts_list.append([category_df.loc[index, 'experts'] for index in high_score_indices])
183
- topic_list.append([category_df.loc[index, 'topic'] for index in high_score_indices])
184
- scores_list.append([float(cos_scores[index]) for index in high_score_indices])
185
  for j in high_score_indices:
186
  df.loc[index, category_df.loc[j, 'topic']] = float(cos_scores[j])
187
  else:
188
  categories_list.append(np.nan)
189
  experts_list.append(np.nan)
190
  topic_list.append(np.nan)
191
- scores_list.append('pas interessant')
192
  df["Description"] = categories_list
193
  df["Expert"] = experts_list
194
  df["Topic"] = topic_list
 
178
  if isinstance(ebd_content, torch.Tensor):
179
  cos_scores = util.cos_sim(ebd_content, torch.stack(list(category_df['Embeddings']), dim=0))[0]
180
  high_score_indices = [i for i, score in enumerate(cos_scores) if score > treshold]
181
+ categories_list.append("@~@".join([category_df.loc[index, 'description'] for index in high_score_indices]))
182
+ experts_list.append("@~@".join([category_df.loc[index, 'experts'] for index in high_score_indices]))
183
+ topic_list.append("@~@".join([category_df.loc[index, 'topic'] for index in high_score_indices]))
184
+ scores_list.append("@~@".join([float(cos_scores[index]) for index in high_score_indices]))
185
  for j in high_score_indices:
186
  df.loc[index, category_df.loc[j, 'topic']] = float(cos_scores[j])
187
  else:
188
  categories_list.append(np.nan)
189
  experts_list.append(np.nan)
190
  topic_list.append(np.nan)
191
+ scores_list.append(np.nan)
192
  df["Description"] = categories_list
193
  df["Expert"] = experts_list
194
  df["Topic"] = topic_list