MLpp
ml::ConjugateGradientLogisticRegression Class Reference

Conjugate gradient logistic regression, as described in Sec. 4 of Thomas P. Minka, "A comparison of numerical optimizers for logistic regression". More...

#include <LogisticRegression.hpp>

Inheritance diagram for ml::ConjugateGradientLogisticRegression:
Collaboration diagram for ml::ConjugateGradientLogisticRegression:

Public Member Functions

Result fit (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y) const override
 Fits the model and returns the result. More...
 
- Public Member Functions inherited from ml::AbstractLogisticRegression
 AbstractLogisticRegression ()
 Constructor setting default parameter values.
 
double lam () const
 Returns the regularisation parameter. More...
 
double absolute_tolerance () const
 Returns absolute tolerance for fitted weights.
 
double relative_tolerance () const
 Returns relative tolerance for fitted weights.
 
unsigned int maximum_steps () const
 Returns maximum number of steps allowed.
 
void set_lam (double lam)
 Sets the regularisation parameter. More...
 
void set_absolute_tolerance (double absolute_tolerance)
 Sets absolute tolerance for weight convergence. More...
 
void set_relative_tolerance (double relative_tolerance)
 Sets relative tolerance for weight convergence. More...
 
void set_maximum_steps (unsigned int maximum_steps)
 Sets maximum number of steps.
 
- Public Member Functions inherited from ml::LogisticRegression
virtual ~LogisticRegression ()
 Virtual destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from ml::LogisticRegression
static double probability (Eigen::Ref< const Eigen::VectorXd > x, double y, Eigen::Ref< const Eigen::VectorXd > w)
 Calculates the probability of label given model weights and feature vector. More...
 
static double log_likelihood (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y, Eigen::Ref< const Eigen::VectorXd > w, double lam)
 Calculates the posterior log-likelihood of data given model weights. More...
 
static void grad_log_likelihood (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y, Eigen::Ref< const Eigen::VectorXd > w, double lam, Eigen::Ref< Eigen::VectorXd > g)
 Calculates the gradient of the posterior log-likelihood of data given model weights, over those weights. More...
 
static void hessian_log_likelihood (Eigen::Ref< const Eigen::MatrixXd > X, Eigen::Ref< const Eigen::VectorXd > y, Eigen::Ref< const Eigen::VectorXd > w, double lam, Eigen::Ref< Eigen::MatrixXd > H)
 Calculates the Hessian of the posterior log-likelihood of data given model weights, over those weights. More...
 
- Protected Member Functions inherited from ml::AbstractLogisticRegression
bool weights_converged (Eigen::Ref< const Eigen::VectorXd > old_weights, Eigen::Ref< const Eigen::VectorXd > new_weights) const
 Check if weight fitting converged. More...
 

Detailed Description

Conjugate gradient logistic regression, as described in Sec. 4 of Thomas P. Minka, "A comparison of numerical optimizers for logistic regression".

Member Function Documentation

◆ fit()

Result ml::ConjugateGradientLogisticRegression::fit ( Eigen::Ref< const Eigen::MatrixXd >  X,
Eigen::Ref< const Eigen::VectorXd >  y 
) const
overridevirtual

Fits the model and returns the result.

If fitting with intercept is desired, include a row of 1's in the X values.

Parameters
XD x N matrix of X values, with data points in columns.
yY vector with length N. Values should be -1 or 1.
Exceptions
std::invalid_argumentif N or D are zero, or if dimensions of X and y do not match.
Returns
Result object.

Implements ml::LogisticRegression.


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