sergiomar73
commited on
Commit
•
b82198f
1
Parent(s):
a7f0092
Update app.py
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ def compare_text(transcript, categories, threshold):
|
|
64 |
phrases = torch.stack(phrases_list)
|
65 |
cosine_scores = util.cos_sim(embeddings, phrases).numpy()
|
66 |
max_scores = np.max(cosine_scores, axis=1)
|
67 |
-
df_cosines[df_category.iloc[0,2]] = np.
|
68 |
for num_sentence, scores in enumerate(cosine_scores):
|
69 |
for num_phrase, score in enumerate(scores):
|
70 |
if score >= threshold:
|
@@ -73,14 +73,14 @@ def compare_text(transcript, categories, threshold):
|
|
73 |
'sentence': sentences[num_sentence],
|
74 |
'phrase': df_category.at[num_phrase,'example'],
|
75 |
'category': df_category.at[num_phrase,'label'],
|
76 |
-
'similarity': np.
|
77 |
}
|
78 |
df_results = df_results.append(new_row, ignore_index=True)
|
79 |
|
80 |
df_results = df_results.sort_values(['line','similarity'],ascending=[True,False])
|
81 |
|
82 |
df_summary = pd.DataFrame(df_cosines.max(numeric_only=True),columns=['similarity'])
|
83 |
-
df_summary['ok'] = np.where(df_summary['similarity'] > threshold, True, False)
|
84 |
|
85 |
fig = px.bar(
|
86 |
df_summary,
|
|
|
64 |
phrases = torch.stack(phrases_list)
|
65 |
cosine_scores = util.cos_sim(embeddings, phrases).numpy()
|
66 |
max_scores = np.max(cosine_scores, axis=1)
|
67 |
+
df_cosines[df_category.iloc[0,2]] = np.rint(max_scores * 1000) / 1000.0
|
68 |
for num_sentence, scores in enumerate(cosine_scores):
|
69 |
for num_phrase, score in enumerate(scores):
|
70 |
if score >= threshold:
|
|
|
73 |
'sentence': sentences[num_sentence],
|
74 |
'phrase': df_category.at[num_phrase,'example'],
|
75 |
'category': df_category.at[num_phrase,'label'],
|
76 |
+
'similarity': np.rint(score * 1000) / 1000.0
|
77 |
}
|
78 |
df_results = df_results.append(new_row, ignore_index=True)
|
79 |
|
80 |
df_results = df_results.sort_values(['line','similarity'],ascending=[True,False])
|
81 |
|
82 |
df_summary = pd.DataFrame(df_cosines.max(numeric_only=True),columns=['similarity'])
|
83 |
+
df_summary['ok'] = np.where(df_summary['similarity'] > threshold, True, False)
|
84 |
|
85 |
fig = px.bar(
|
86 |
df_summary,
|