-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FutureWarn] Fix FutureWarning in
TAHIN
example. (dmlc#7418)
- Loading branch information
Showing
1 changed file
with
25 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,25 @@ | ||
import numpy as np | ||
import torch | ||
from sklearn.metrics import ( | ||
accuracy_score, | ||
average_precision_score, | ||
f1_score, | ||
log_loss, | ||
ndcg_score, | ||
roc_auc_score, | ||
) | ||
|
||
|
||
def evaluate_auc(pred, label): | ||
res = roc_auc_score(y_score=pred, y_true=label) | ||
return res | ||
|
||
|
||
def evaluate_acc(pred, label): | ||
res = [] | ||
for _value in pred: | ||
if _value >= 0.5: | ||
res.append(1) | ||
else: | ||
res.append(0) | ||
return accuracy_score(y_pred=res, y_true=label) | ||
|
||
|
||
def evaluate_f1_score(pred, label): | ||
res = [] | ||
for _value in pred: | ||
if _value >= 0.5: | ||
res.append(1) | ||
else: | ||
res.append(0) | ||
return f1_score(y_pred=res, y_true=label) | ||
|
||
|
||
def evaluate_logloss(pred, label): | ||
res = log_loss(y_true=label, y_pred=pred, eps=1e-7, normalize=True) | ||
return res | ||
from sklearn.metrics import accuracy_score, f1_score, log_loss, roc_auc_score | ||
|
||
|
||
def evaluate_auc(pred, label): | ||
res = roc_auc_score(y_score=pred, y_true=label) | ||
return res | ||
|
||
|
||
def evaluate_acc(pred, label): | ||
res = [] | ||
for _value in pred: | ||
res.append(1 if _value >= 0.5 else 0) | ||
return accuracy_score(y_pred=res, y_true=label) | ||
|
||
|
||
def evaluate_f1_score(pred, label): | ||
res = [] | ||
for _value in pred: | ||
res.append(1 if _value >= 0.5 else 0) | ||
return f1_score(y_pred=res, y_true=label) | ||
|
||
|
||
def evaluate_logloss(pred, label): | ||
res = log_loss(y_true=label, y_pred=pred, normalize=True) | ||
return res |