![]() |
slope 6.0.1
|
Loss function interface. More...
#include <loss.h>

Public Member Functions | |
| virtual | ~Loss ()=default |
| Destructor for the Loss class. | |
| virtual double | loss (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y)=0 |
| Calculates the loss function. | |
| virtual double | dual (const Eigen::MatrixXd &theta, const Eigen::MatrixXd &y, const Eigen::VectorXd &w)=0 |
| Calculates the dual loss. | |
| Eigen::MatrixXd | residual (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Calculates the generalized residual. | |
| virtual Eigen::MatrixXd | hessianDiagonal (const Eigen::MatrixXd &eta)=0 |
| Calculates the hessian diagonal of the loss function. | |
| virtual void | updateWeightsAndWorkingResponse (Eigen::MatrixXd &w, Eigen::MatrixXd &z, const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Updates weights and working response. | |
| virtual Eigen::MatrixXd | preprocessResponse (const Eigen::MatrixXd &y)=0 |
| Preprocess response. | |
| virtual void | updateIntercept (Eigen::VectorXd &beta0, const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Updates the intercept with a gradient descent update. | |
| virtual Eigen::MatrixXd | link (const Eigen::MatrixXd &mu)=0 |
| The link function. | |
| virtual Eigen::MatrixXd | inverseLink (const Eigen::MatrixXd &eta)=0 |
| The inverse link function, also known as the mean function. | |
| virtual Eigen::MatrixXd | predict (const Eigen::MatrixXd &eta)=0 |
| Return predicted response. | |
| virtual double | deviance (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Computes deviance, which is 2 times the difference between the loglikelihood of the model and the loglikelihood of the null (intercept-only) model. | |
Protected Member Functions | |
| Loss (double lipschitz_constant) | |
| Constructs an loss function with specified Lipschitz constant. | |
Loss function interface.
This class defines the interface for an loss function, which is used in optimization algorithms. The loss function calculates the loss, dual, residual, and updates the weights and working response.
|
inlineexplicitprotected |
Constructs an loss function with specified Lipschitz constant.
| lipschitz_constant | The Lipschitz constant for the loss function |
The Lipschitz constant is used to ensure convergence in gradient-based optimization by bounding the rate of change of the gradient.
|
inlinevirtual |
|
pure virtual |
Calculates the dual loss.
This function calculates the dual function given the estimated parameters (theta) and the true values (y).
| theta | The estimated parameters. |
| y | The true values. |
| w | Weights. |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
|
pure virtual |
Calculates the hessian diagonal of the loss function.
This function calculates the hessian diagonal, with respect to the linear predictor eta. \(\frac{\partial^2 L}{\partial \eta^2}\)
| eta | Linear predictor. |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
|
pure virtual |
The inverse link function, also known as the mean function.
| eta | Mean |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
|
pure virtual |
The link function.
| mu | Mean. |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
|
pure virtual |
Calculates the loss function.
This function calculates the loss function given the predicted values (eta) and the true values (y).
| eta | The predicted values. |
| y | The true values. |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
|
pure virtual |
Return predicted response.
| eta | The linear predictor. |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
|
pure virtual |
Preprocess response.
| y | The response |
Implemented in slope::Logistic, slope::Multinomial, slope::Quadratic, and slope::Poisson.
| Eigen::MatrixXd slope::Loss::residual | ( | const Eigen::MatrixXd & | eta, |
| const Eigen::MatrixXd & | y | ||
| ) |
Calculates the generalized residual.
This function calculates the generalized residual given the linear predictor (eta) and the true values (y). The generalized residual is the same as the gradient of the loss function with respect to the linear predictor (eta).
| eta | Linear predictor. |
| y | Response. |
|
inlinevirtual |
Updates the intercept with a gradient descent update.
| beta0 | The current intercept. |
| eta | The current linear predictor. |
| y | The observed counts vector. |
Reimplemented in slope::Poisson.
|
virtual |
Updates weights and working response.
This function updates the weights and working response of the quadratic expansion of the loss function.
| w | Working weights. |
| z | Working response. |
| eta | Linear predictor. |
| y | Response. |
Reimplemented in slope::Quadratic.