Valeriy Sinyukov
commited on
Commit
·
a1ad5de
1
Parent(s):
53bf7b2
Filter results
Browse files- results.py +7 -2
results.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
|
| 3 |
from languages import en, ru
|
| 4 |
|
| 5 |
|
| 6 |
-
def filter_results(results):
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
return results
|
| 9 |
|
| 10 |
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
from languages import en, ru
|
| 5 |
|
| 6 |
|
| 7 |
+
def filter_results(results : pd.DataFrame, top_k=0.95):
|
| 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 |
|