Losses and criteria#
Losses, scores, complexity measures and information criteria.
All losses are to be minimized. Non-finite predictions give an infinite loss, so that invalid expressions are never selected.
Examples#
>>> import numpy as np
>>> from eqdisco.fitness import mse, r2, complexity
>>> from eqdisco.expr import Expression
>>> y = np.array([1.0, 2.0, 3.0]); yhat = np.array([1.1, 1.9, 3.2])
>>> round(mse(y, yhat), 4), round(r2(y, yhat), 4)
(0.02, 0.97)
>>> e = Expression.from_string("7*x0^2 + 3*x0 + 5")
>>> complexity(e, "size"), complexity(e, "recursive")
(10, 17.0)
Losses, complexity measures, information criteria and description length.
Functions#
|
Mean squared error \(\frac1N\sum_k (y_k-\hat y_k)^2\). |
|
Root mean squared error. |
|
MSE normalized by the variance of |
|
Mean absolute error. |
|
Coefficient of determination \(R^2 = 1 - \mathrm{SSE}/\mathrm{SST}\). |
|
Largest absolute residual. |
|
Huber loss; |
|
Binary cross-entropy of probabilities |
|
Share of wrongly classified samples (labels compared directly). |
|
One minus the balanced accuracy (mean recall over the classes). |
|
Resolve a loss given by name or as a callable |
|
Complexity \(C(f)\) of an expression. |
|
Maximized Gaussian log-likelihood for residual sum of squares |
|
Akaike information criterion \(2k - 2\ln\hat L\) (Gaussian errors). |
|
AIC with the small-sample correction of Hurvich and Tsai. |
|
Bayesian information criterion \(k\ln N - 2\ln\hat L\) (Gaussian errors). |
|
|
|
Two-part description length (in nats) of data and model. |
|
Absolute errors per sample (the cases of lexicase selection); inf if invalid. |
Constants#
Regression losses available by name. |
|
Names accepted by |