Valeriy Sinyukov
commited on
Commit
·
bd0a951
1
Parent(s):
ce32a21
Don't show categories with less then 1% confidence
Browse files- results.py +7 -6
results.py
CHANGED
@@ -4,19 +4,20 @@ import pandas as pd
|
|
4 |
from languages import en, ru
|
5 |
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
certs = results[certainty_init].to_numpy()
|
9 |
cum_certs = certs.cumsum()
|
10 |
do_no_show = cum_certs < top_k
|
11 |
first_not_to_show_id = np.argmin(do_no_show) + 1
|
12 |
results = results.iloc[:first_not_to_show_id]
|
|
|
13 |
return results
|
14 |
|
15 |
|
16 |
-
category_init = "label"
|
17 |
-
certainty_init = "score"
|
18 |
-
|
19 |
-
|
20 |
def process_keys(results: pd.DataFrame, lang):
|
21 |
category = {en: "Category", ru: "Категория"}
|
22 |
certainty = {en: "Certainty", ru: "Уверенность"}
|
@@ -121,7 +122,7 @@ def process_results(results, lang):
|
|
121 |
results = pd.DataFrame(results)
|
122 |
results = process_categories(results, lang)
|
123 |
results = results.groupby(by=category_init, as_index=False).sum()
|
124 |
-
results = results.sort_values(by=[certainty_init],ascending=False)
|
125 |
results = filter_results(results)
|
126 |
results = process_certainities(results)
|
127 |
results = process_keys(results, lang)
|
|
|
4 |
from languages import en, ru
|
5 |
|
6 |
|
7 |
+
category_init = "label"
|
8 |
+
certainty_init = "score"
|
9 |
+
|
10 |
+
|
11 |
+
def filter_results(results: pd.DataFrame, top_k=0.95):
|
12 |
certs = results[certainty_init].to_numpy()
|
13 |
cum_certs = certs.cumsum()
|
14 |
do_no_show = cum_certs < top_k
|
15 |
first_not_to_show_id = np.argmin(do_no_show) + 1
|
16 |
results = results.iloc[:first_not_to_show_id]
|
17 |
+
results = results[results[certainty_init] >= 0.01]
|
18 |
return results
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
21 |
def process_keys(results: pd.DataFrame, lang):
|
22 |
category = {en: "Category", ru: "Категория"}
|
23 |
certainty = {en: "Certainty", ru: "Уверенность"}
|
|
|
122 |
results = pd.DataFrame(results)
|
123 |
results = process_categories(results, lang)
|
124 |
results = results.groupby(by=category_init, as_index=False).sum()
|
125 |
+
results = results.sort_values(by=[certainty_init], ascending=False)
|
126 |
results = filter_results(results)
|
127 |
results = process_certainities(results)
|
128 |
results = process_keys(results, lang)
|