-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
42 lines (29 loc) · 1.13 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from time import time
import numpy as np
from sklearn.metrics import roc_auc_score
from fastauc.auroc import AUROC
def main():
n = 1000000
m = 100000
repeat = 10
skl_t_list, fac_t_list, diff_list = [], [], []
for i in range(repeat):
y_pred = np.sort(np.random.random(n))[::-1]
y_true = np.random.random(n) > np.random.random()
y_true[:m] = True
t = time()
skl_auroc = roc_auc_score(y_true, y_pred)
skl_t_list.append(time() - t)
t = time()
fac_auroc = AUROC()(y_true, y_pred)
fac_t_list.append(time() - t)
diff_list.append(np.abs(skl_auroc - fac_auroc))
print(f"Scikit-learn: {skl_auroc:07.4f}, FastAUR: {fac_auroc:07.4f}")
print("\nFinal evaluation")
print(f"Run time statistics for Scikit-learn: "
f"avg = {np.mean(skl_t_list):.2e}, std = {np.std(skl_t_list):.2e}")
print(f"Run time statistics for FastAUC : "
f"avg = {np.mean(fac_t_list):.2e}, std = {np.std(fac_t_list):.2e}")
print(f"Diff: avg={np.mean(diff_list):.2e}, std={np.std(diff_list):.2e}")
if __name__ == '__main__':
main()