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

Function confusion_matrix

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

Source from the content-addressed store, hash-verified

132
133
134def confusion_matrix(y_pred: Tensor, y_true: Tensor, **kwargs):
135 try:
136 y_pred = np.argmax(y_pred.detach().cpu().numpy(), axis=1)
137 return sklearn_confusion_matrix(
138 y_true.detach().cpu().numpy(), y_pred, labels=kwargs.get("labels"),
139 )
140 except Exception as e:
141 logger.error(e)
142

Callers

nothing calls this directly

Calls 1

detachMethod · 0.45

Tested by

no test coverage detected