MCPcopy
hub / github.com/appvision-ai/fast-bert / roc_auc

Function roc_auc

fast_bert/metrics.py:77–91  ·  view source on GitHub ↗
(y_pred: Tensor, y_true: Tensor, **kwargs)

Source from the content-addressed store, hash-verified

75
76
77def roc_auc(y_pred: Tensor, y_true: Tensor, **kwargs):
78 # ROC-AUC calcualation
79 # Compute ROC curve and ROC area for each class
80 fpr = dict()
81 tpr = dict()
82 roc_auc = dict()
83
84 y_true = y_true.detach().cpu().numpy()
85 y_pred = y_pred.detach().cpu().numpy()
86
87 # Compute micro-average ROC curve and ROC area
88 fpr["micro"], tpr["micro"], _ = roc_curve(y_true.ravel(), y_pred.ravel())
89 roc_auc["micro"] = auc(fpr["micro"], tpr["micro"])
90
91 return roc_auc["micro"]
92
93
94def Hamming_loss(

Callers

nothing calls this directly

Calls 1

detachMethod · 0.45

Tested by

no test coverage detected