MCPcopy
hub / github.com/ddbourgin/numpy-ml / CrossEntropyLoss

Class CrossEntropyLoss

numpy_ml/trees/losses.py:52–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51
52class CrossEntropyLoss:
53 def __call__(self, y, y_pred):
54 eps = np.finfo(float).eps
55 return -np.sum(y * np.log(y_pred + eps))
56
57 def base_estimator(self):
58 return ClassProbEstimator()
59
60 def grad(self, y, y_pred):
61 eps = np.finfo(float).eps
62 return -y * 1 / (y_pred + eps)
63
64 def line_search(self, y, y_pred, h_pred):
65 raise NotImplementedError

Callers 1

fitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected