mlpack  master
Public Member Functions | Private Attributes | List of all members
mlpack::regression::LogisticRegressionFunction< MatType > Class Template Reference

The log-likelihood function for the logistic regression objective function. More...

Public Member Functions

 LogisticRegressionFunction (const MatType &predictors, const arma::Row< size_t > &responses, const double lambda=0)
 
 LogisticRegressionFunction (const MatType &predictors, const arma::Row< size_t > &responses, const arma::vec &initialPoint, const double lambda=0)
 
double Evaluate (const arma::mat &parameters) const
 Evaluate the logistic regression log-likelihood function with the given parameters. More...
 
double Evaluate (const arma::mat &parameters, const size_t i) const
 Evaluate the logistic regression log-likelihood function with the given parameters, but using only one data point. More...
 
const arma::mat & GetInitialPoint () const
 Return the initial point for the optimization. More...
 
void Gradient (const arma::mat &parameters, arma::mat &gradient) const
 Evaluate the gradient of the logistic regression log-likelihood function with the given parameters. More...
 
void Gradient (const arma::mat &parameters, const size_t i, arma::mat &gradient) const
 Evaluate the gradient of the logistic regression log-likelihood function with the given parameters, and with respect to only one point in the dataset. More...
 
const arma::mat & InitialPoint () const
 Return the initial point for the optimization. More...
 
arma::mat & InitialPoint ()
 Modify the initial point for the optimization. More...
 
const double & Lambda () const
 Return the regularization parameter (lambda). More...
 
double & Lambda ()
 Modify the regularization parameter (lambda). More...
 
size_t NumFunctions () const
 Return the number of separable functions (the number of predictor points). More...
 
const MatType & Predictors () const
 Return the matrix of predictors. More...
 
const arma::vec & Responses () const
 Return the vector of responses. More...
 

Private Attributes

arma::mat initialPoint
 The initial point, from which to start the optimization. More...
 
double lambda
 The regularization parameter for L2-regularization. More...
 
const MatType & predictors
 The matrix of data points (predictors). More...
 
const arma::Row< size_t > & responses
 The vector of responses to the input data points. More...
 

Detailed Description

template<typename MatType = arma::mat>
class mlpack::regression::LogisticRegressionFunction< MatType >

The log-likelihood function for the logistic regression objective function.

This is used by various mlpack optimizers to train a logistic regression model.

Definition at line 28 of file logistic_regression_function.hpp.

Constructor & Destructor Documentation

template<typename MatType = arma::mat>
mlpack::regression::LogisticRegressionFunction< MatType >::LogisticRegressionFunction ( const MatType &  predictors,
const arma::Row< size_t > &  responses,
const double  lambda = 0 
)
template<typename MatType = arma::mat>
mlpack::regression::LogisticRegressionFunction< MatType >::LogisticRegressionFunction ( const MatType &  predictors,
const arma::Row< size_t > &  responses,
const arma::vec &  initialPoint,
const double  lambda = 0 
)

Member Function Documentation

template<typename MatType = arma::mat>
double mlpack::regression::LogisticRegressionFunction< MatType >::Evaluate ( const arma::mat &  parameters) const

Evaluate the logistic regression log-likelihood function with the given parameters.

Note that if a point has 0 probability of being classified directly with the given parameters, then Evaluate() will return nan (this is kind of a corner case and should not happen for reasonable models).

The optimum (minimum) of this function is 0.0, and occurs when each point is classified correctly with very high probability.

Parameters
parametersVector of logistic regression parameters.

Referenced by mlpack::regression::LogisticRegressionFunction< MatType >::Responses().

template<typename MatType = arma::mat>
double mlpack::regression::LogisticRegressionFunction< MatType >::Evaluate ( const arma::mat &  parameters,
const size_t  i 
) const

Evaluate the logistic regression log-likelihood function with the given parameters, but using only one data point.

This is useful for optimizers such as SGD, which require a separable objective function. Note that if the point has 0 probability of being classified correctly with the given parameters, then Evaluate() will return nan (this is kind of a corner case and should not happen for reasonable models).

The optimum (minimum) of this function is 0.0, and occurs when the point is classified correctly with very high probability.

Parameters
parametersVector of logistic regression parameters.
iIndex of point to use for objective function evaluation.
template<typename MatType = arma::mat>
const arma::mat& mlpack::regression::LogisticRegressionFunction< MatType >::GetInitialPoint ( ) const
inline

Return the initial point for the optimization.

Definition at line 108 of file logistic_regression_function.hpp.

References mlpack::regression::LogisticRegressionFunction< MatType >::initialPoint.

template<typename MatType = arma::mat>
void mlpack::regression::LogisticRegressionFunction< MatType >::Gradient ( const arma::mat &  parameters,
arma::mat &  gradient 
) const

Evaluate the gradient of the logistic regression log-likelihood function with the given parameters.

Parameters
parametersVector of logistic regression parameters.
gradientVector to output gradient into.

Referenced by mlpack::regression::LogisticRegressionFunction< MatType >::Responses().

template<typename MatType = arma::mat>
void mlpack::regression::LogisticRegressionFunction< MatType >::Gradient ( const arma::mat &  parameters,
const size_t  i,
arma::mat &  gradient 
) const

Evaluate the gradient of the logistic regression log-likelihood function with the given parameters, and with respect to only one point in the dataset.

This is useful for optimizers such as SGD, which require a separable objective function.

Parameters
parametersVector of logistic regression parameters.
iIndex of points to use for objective function gradient evaluation.
gradientVector to output gradient into.
template<typename MatType = arma::mat>
const arma::mat& mlpack::regression::LogisticRegressionFunction< MatType >::InitialPoint ( ) const
inline

Return the initial point for the optimization.

Definition at line 41 of file logistic_regression_function.hpp.

References mlpack::regression::LogisticRegressionFunction< MatType >::initialPoint.

template<typename MatType = arma::mat>
arma::mat& mlpack::regression::LogisticRegressionFunction< MatType >::InitialPoint ( )
inline

Modify the initial point for the optimization.

Definition at line 43 of file logistic_regression_function.hpp.

References mlpack::regression::LogisticRegressionFunction< MatType >::initialPoint.

template<typename MatType = arma::mat>
const double& mlpack::regression::LogisticRegressionFunction< MatType >::Lambda ( ) const
inline

Return the regularization parameter (lambda).

Definition at line 46 of file logistic_regression_function.hpp.

References mlpack::regression::LogisticRegressionFunction< MatType >::lambda.

template<typename MatType = arma::mat>
double& mlpack::regression::LogisticRegressionFunction< MatType >::Lambda ( )
inline

Modify the regularization parameter (lambda).

Definition at line 48 of file logistic_regression_function.hpp.

References mlpack::regression::LogisticRegressionFunction< MatType >::lambda.

template<typename MatType = arma::mat>
size_t mlpack::regression::LogisticRegressionFunction< MatType >::NumFunctions ( ) const
inline

Return the number of separable functions (the number of predictor points).

Definition at line 111 of file logistic_regression_function.hpp.

template<typename MatType = arma::mat>
const MatType& mlpack::regression::LogisticRegressionFunction< MatType >::Predictors ( ) const
inline

Return the matrix of predictors.

Definition at line 51 of file logistic_regression_function.hpp.

References mlpack::regression::LogisticRegressionFunction< MatType >::predictors.

template<typename MatType = arma::mat>
const arma::vec& mlpack::regression::LogisticRegressionFunction< MatType >::Responses ( ) const
inline

Member Data Documentation

template<typename MatType = arma::mat>
arma::mat mlpack::regression::LogisticRegressionFunction< MatType >::initialPoint
private
template<typename MatType = arma::mat>
double mlpack::regression::LogisticRegressionFunction< MatType >::lambda
private

The regularization parameter for L2-regularization.

Definition at line 121 of file logistic_regression_function.hpp.

Referenced by mlpack::regression::LogisticRegressionFunction< MatType >::Lambda().

template<typename MatType = arma::mat>
const MatType& mlpack::regression::LogisticRegressionFunction< MatType >::predictors
private

The matrix of data points (predictors).

Definition at line 117 of file logistic_regression_function.hpp.

Referenced by mlpack::regression::LogisticRegressionFunction< MatType >::Predictors().

template<typename MatType = arma::mat>
const arma::Row<size_t>& mlpack::regression::LogisticRegressionFunction< MatType >::responses
private

The vector of responses to the input data points.

Definition at line 119 of file logistic_regression_function.hpp.

Referenced by mlpack::regression::LogisticRegressionFunction< MatType >::Responses().


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