(p, l)
| 46 | |
| 47 | |
| 48 | def calc_threshold(p, l): |
| 49 | trials = [(i) * (1. / 100.) for i in range(100)] |
| 50 | best_acc = float('-inf') |
| 51 | best_thresh = 0 |
| 52 | for t in trials: |
| 53 | acc = ((apply_threshold(p, t).argmax(-1) == l).astype(float)).mean() |
| 54 | if acc > best_acc: |
| 55 | best_acc = acc |
| 56 | best_thresh = t |
| 57 | return best_thresh |
| 58 | |
| 59 | |
| 60 | def apply_threshold(preds, t): |
no test coverage detected