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

Class MSELoss

numpy_ml/trees/losses.py:33–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32
33class MSELoss:
34 def __call__(self, y, y_pred):
35 return np.mean((y - y_pred) ** 2)
36
37 def base_estimator(self):
38 return MeanBaseEstimator()
39
40 def grad(self, y, y_pred):
41 return -2 / len(y) * (y - y_pred)
42
43 def line_search(self, y, y_pred, h_pred):
44 # TODO: revise this
45 Lp = np.sum((y - y_pred) * h_pred)
46 Lpp = np.sum(h_pred * h_pred)
47
48 # if we perfectly fit the residuals, use max step size
49 return 1 if np.sum(Lpp) == 0 else Lp / Lpp
50
51
52class CrossEntropyLoss:

Callers 1

fitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected