![]() |
slope 6.5.4
|
The Multinomial class represents a multinomial logistic regression loss function. More...
#include <multinomial.h>


Public Member Functions | |
| double | loss (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) override |
| Calculates the loss for the multinomial loss function. | |
| double | dual (const Eigen::MatrixXd &theta, const Eigen::MatrixXd &y, const Eigen::VectorXd &w) override |
| Calculates the dual for the multinomial loss function. | |
| Eigen::MatrixXd | dualPoint (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y, bool fit_intercept) override |
| Constructs a dual candidate from a linear predictor. | |
| Eigen::MatrixXd | preprocessResponse (const Eigen::MatrixXd &y) override |
| Preprocesses the response for the Multinomial model. | |
| Eigen::MatrixXd | hessianDiagonal (const Eigen::MatrixXd &eta) override |
| Calculates the hessian diagonal. | |
| Eigen::MatrixXd | link (const Eigen::MatrixXd &mu) override |
| The link function. | |
| Eigen::MatrixXd | inverseLink (const Eigen::MatrixXd &eta) override |
| The inverse link function. | |
| Eigen::MatrixXd | predict (const Eigen::MatrixXd &eta) override |
| Return predicted response, which is an integer class label based on the predicted probabilities. | |
Public Member Functions inherited from slope::Loss | |
| virtual | ~Loss ()=default |
| Destructor for the Loss class. | |
| Eigen::MatrixXd | residual (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Calculates the generalized residual. | |
| virtual void | updateWeightsAndWorkingResponse (Eigen::MatrixXd &w, Eigen::MatrixXd &z, const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Updates weights and working response. | |
| virtual void | updateIntercept (Eigen::VectorXd &beta0, const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) |
| Updates the intercept with a gradient descent update. | |
| 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. | |
Additional Inherited Members | |
Protected Member Functions inherited from slope::Loss | |
| Loss (double lipschitz_constant) | |
| Constructs an loss function with specified Lipschitz constant. | |
| Eigen::MatrixXd | domainSafePoint (const Eigen::MatrixXd &mean, const Eigen::MatrixXd &y, double lower, double upper) const |
| Enforces scalar intercept stationarity without leaving a mean domain. | |
The Multinomial class represents a multinomial logistic regression loss function.
The multinomial loss function is used for multi-class classification problems. It calculates the loss, dual, residual, and updates weights and working response. It uses the non-redundant formulation of the loss with \( K - 1\) columns in the resulting response matrix.
Definition at line 21 of file multinomial.h.
|
inlineexplicit |
Definition at line 24 of file multinomial.h.
|
overridevirtual |
Calculates the dual for the multinomial loss function.
| theta | The dual variables (n x m matrix). |
| y | The true labels (n x m matrix). |
| w | The weights vector. |
Implements slope::Loss.
|
overridevirtual |
Constructs a dual candidate from a linear predictor.
When an intercept is fitted, the candidate must satisfy the corresponding zero-sum constraint. Losses with restricted conjugate domains override this method to preserve those domains while enforcing the constraint.
| eta | Linear predictor. |
| y | Response. |
| fit_intercept | Whether the model has an unpenalized intercept. |
Reimplemented from slope::Loss.
|
overridevirtual |
Calculates the hessian diagonal.
| eta | Linear predictor |
Implements slope::Loss.
|
overridevirtual |
The inverse link function.
| eta |
Implements slope::Loss.
|
overridevirtual |
The link function.
| mu | Mean. |
Implements slope::Loss.
|
overridevirtual |
Calculates the loss for the multinomial loss function.
| eta | The predicted values (n x m matrix of linear predictors). |
| y | The true labels (n x m matrix of one-hot encoded class memberships). |
Implements slope::Loss.
|
overridevirtual |
Return predicted response, which is an integer class label based on the predicted probabilities.
| eta | The linear predictor |
Implements slope::Loss.
|
overridevirtual |
Preprocesses the response for the Multinomial model.
| y | Vector of class labels (n x 1). Each entry is an integer representing the class label from 0 to m. |
Implements slope::Loss.