slope 6.1.1
Loading...
Searching...
No Matches
slope::Logistic Class Reference

The Logistic class represents a logistic loss function. More...

#include <logistic.h>

Inheritance diagram for slope::Logistic:
Collaboration diagram for slope::Logistic:

Public Member Functions

double loss (const Eigen::MatrixXd &eta, const Eigen::MatrixXd &y)
 Calculates the loss for the logistic loss function.
 
double dual (const Eigen::MatrixXd &theta, const Eigen::MatrixXd &y, const Eigen::VectorXd &w)
 Calculates the dual for the logistic loss function.
 
Eigen::MatrixXd hessianDiagonal (const Eigen::MatrixXd &eta)
 Calculates hessian diagonal.
 
Eigen::MatrixXd preprocessResponse (const Eigen::MatrixXd &y)
 Preprocesses the response for the quadratic model.
 
Eigen::MatrixXd link (const Eigen::MatrixXd &mu)
 The link function.
 
Eigen::MatrixXd inverseLink (const Eigen::MatrixXd &eta)
 The inverse link function, also known as the mean function.
 
Eigen::MatrixXd predict (const Eigen::MatrixXd &eta)
 Return predicted response, that is 0 or 1 depending 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Logistic()

slope::Logistic::Logistic ( )
inlineexplicit

Definition at line 21 of file logistic.h.

Member Function Documentation

◆ dual()

double slope::Logistic::dual ( const Eigen::MatrixXd &  theta,
const Eigen::MatrixXd &  y,
const Eigen::VectorXd &  w 
)
virtual

Calculates the dual for the logistic loss function.

Parameters
thetaThe dual variables.
yThe true labels.
wWeights
Returns
The dual value.

Implements slope::Loss.

◆ hessianDiagonal()

Eigen::MatrixXd slope::Logistic::hessianDiagonal ( const Eigen::MatrixXd &  eta)
virtual

Calculates hessian diagonal.

Parameters
etaLinear predictor
Returns
A matrix of ones (n x m)

Implements slope::Loss.

◆ inverseLink()

Eigen::MatrixXd slope::Logistic::inverseLink ( const Eigen::MatrixXd &  eta)
virtual

The inverse link function, also known as the mean function.

Parameters
etaMean
Returns
\( \frac{1}{1 + \exp(-\eta)} \)

Implements slope::Loss.

◆ link()

Eigen::MatrixXd slope::Logistic::link ( const Eigen::MatrixXd &  mu)
virtual

The link function.

Parameters
muMean
Returns
\( \log(\frac{\mu}{1 - \mu}) \)

Implements slope::Loss.

◆ loss()

double slope::Logistic::loss ( const Eigen::MatrixXd &  eta,
const Eigen::MatrixXd &  y 
)
virtual

Calculates the loss for the logistic loss function.

Parameters
etaThe predicted values.
yThe true labels.
Returns
The loss value.

Implements slope::Loss.

◆ predict()

Eigen::MatrixXd slope::Logistic::predict ( const Eigen::MatrixXd &  eta)
virtual

Return predicted response, that is 0 or 1 depending on the predicted probabilities.

Parameters
etaThe linear predictor
Returns
The predicted response

Implements slope::Loss.

◆ preprocessResponse()

Eigen::MatrixXd slope::Logistic::preprocessResponse ( const Eigen::MatrixXd &  y)
virtual

Preprocesses the response for the quadratic model.

Checks if the response is in {0, 1} and converts it otherwise

Parameters
yResponse vector (in {0,1})
Returns
Modified response.

Implements slope::Loss.


The documentation for this class was generated from the following file: