The Logistic class represents a logistic loss function.
More...
#include <logistic.h>
|
| double | loss (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y) override |
| | Calculates the loss for the logistic loss function.
|
| |
| double | dual (const Eigen::MatrixXd &theta, const Eigen::MatrixXd &y, const Eigen::VectorXd &w) override |
| | Calculates the dual for the logistic 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 | hessianDiagonal (const Eigen::MatrixXd &eta) override |
| | Calculates hessian diagonal.
|
| |
| Eigen::MatrixXd | preprocessResponse (const Eigen::MatrixXd &y) override |
| | Preprocesses the response for the quadratic model.
|
| |
| Eigen::MatrixXd | link (const Eigen::MatrixXd &mu) override |
| | The link function.
|
| |
| Eigen::MatrixXd | inverseLink (const Eigen::MatrixXd &eta) override |
| | The inverse link function, also known as the mean function.
|
| |
| Eigen::MatrixXd | predict (const Eigen::MatrixXd &eta) override |
| | Return predicted response, that is 0 or 1 depending on the predicted probabilities.
|
| |
|
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.
|
| |
|
| | 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 Logistic class represents a logistic loss function.
The logistic loss function is used for binary classification problems. It calculates the loss, dual, residual, and updates weights and working response.
Definition at line 18 of file logistic.h.
◆ Logistic()
| slope::Logistic::Logistic |
( |
| ) |
|
|
inlineexplicit |
◆ dual()
| double slope::Logistic::dual |
( |
const Eigen::MatrixXd & |
theta, |
|
|
const Eigen::MatrixXd & |
y, |
|
|
const Eigen::VectorXd & |
w |
|
) |
| |
|
overridevirtual |
Calculates the dual for the logistic loss function.
- Parameters
-
| theta | The dual variables. |
| y | The true labels. |
| w | Weights |
- Returns
- The dual value.
Implements slope::Loss.
◆ dualPoint()
| Eigen::MatrixXd slope::Logistic::dualPoint |
( |
const Eigen::MatrixXd & |
eta, |
|
|
const Eigen::MatrixXd & |
y, |
|
|
bool |
fit_intercept |
|
) |
| |
|
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.
- Parameters
-
| eta | Linear predictor. |
| y | Response. |
| fit_intercept | Whether the model has an unpenalized intercept. |
- Returns
- A candidate dual point before regularizer scaling.
Reimplemented from slope::Loss.
◆ hessianDiagonal()
| Eigen::MatrixXd slope::Logistic::hessianDiagonal |
( |
const Eigen::MatrixXd & |
eta | ) |
|
|
overridevirtual |
Calculates hessian diagonal.
- Parameters
-
- Returns
- A matrix of ones (n x m)
Implements slope::Loss.
◆ inverseLink()
| Eigen::MatrixXd slope::Logistic::inverseLink |
( |
const Eigen::MatrixXd & |
eta | ) |
|
|
overridevirtual |
The inverse link function, also known as the mean function.
- Parameters
-
- Returns
- \( \frac{1}{1 + \exp(-\eta)} \)
Implements slope::Loss.
◆ link()
| Eigen::MatrixXd slope::Logistic::link |
( |
const Eigen::MatrixXd & |
mu | ) |
|
|
overridevirtual |
The link function.
- Parameters
-
- Returns
- \( \log(\frac{\mu}{1 - \mu}) \)
Implements slope::Loss.
◆ loss()
| double slope::Logistic::loss |
( |
const Eigen::MatrixXd & |
eta, |
|
|
const Eigen::MatrixXd & |
y |
|
) |
| |
|
overridevirtual |
Calculates the loss for the logistic loss function.
- Parameters
-
| eta | The predicted values. |
| y | The true labels. |
- Returns
- The loss value.
Implements slope::Loss.
◆ predict()
| Eigen::MatrixXd slope::Logistic::predict |
( |
const Eigen::MatrixXd & |
eta | ) |
|
|
overridevirtual |
Return predicted response, that is 0 or 1 depending on the predicted probabilities.
- Parameters
-
- Returns
- The predicted response
Implements slope::Loss.
◆ preprocessResponse()
| Eigen::MatrixXd slope::Logistic::preprocessResponse |
( |
const Eigen::MatrixXd & |
y | ) |
|
|
overridevirtual |
Preprocesses the response for the quadratic model.
Checks if the response is in {0, 1} and converts it otherwise
- Parameters
-
| y | Response vector (in {0,1}) |
- Returns
- Modified response.
Implements slope::Loss.
The documentation for this class was generated from the following file: