SYNOPSIS

Public Member Functions

LogisticRegression (const arma::mat &predictors, const arma::vec &responses, const double lambda=0)

Construct the LogisticRegression class with the given labeled training data. LogisticRegression (const arma::mat &predictors, const arma::vec &responses, const arma::mat &initialPoint, const double lambda=0)

Construct the LogisticRegression class with the given labeled training data. LogisticRegression (OptimizerType< LogisticRegressionFunction > &optimizer)

Construct the LogisticRegression class with the given labeled training data. LogisticRegression (const arma::vec &parameters, const double lambda=0)

Construct a logistic regression model from the given parameters, without performing any training. double ComputeAccuracy (const arma::mat &predictors, const arma::vec &responses, const double decisionBoundary=0.5) const

Compute the accuracy of the model on the given predictors and responses, optionally using the given decision boundary. double ComputeError (const arma::mat &predictors, const arma::vec &responses) const

Compute the error of the model. const double & Lambda () const

Return the lambda value for L2-regularization. double & Lambda ()

Modify the lambda value for L2-regularization. const arma::vec & Parameters () const

Return the parameters (the b vector). arma::vec & Parameters ()

Modify the parameters (the b vector). void Predict (const arma::mat &predictors, arma::vec &responses, const double decisionBoundary=0.5) const

Predict the responses to a given set of predictors. std::string ToString () const

Private Attributes

double lambda

L2-regularization penalty parameter. arma::vec parameters

Vector of trained parameters.

Detailed Description

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS>class mlpack::regression::LogisticRegression< OptimizerType >

Definition at line 37 of file logistic_regression.hpp.

Constructor & Destructor Documentation

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::\fBLogisticRegression\fP (const arma::mat &predictors, const arma::vec &responses, const doublelambda = \fC0\fP)

Construct the LogisticRegression class with the given labeled training data. This will train the model. Optionally, specify lambda, which is the penalty parameter for L2-regularization. If not specified, it is set to 0, which results in standard (unregularized) logistic regression.

Parameters:

predictors Input training variables.

responses Outputs resulting from input training variables.

lambda L2-regularization parameter.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::\fBLogisticRegression\fP (const arma::mat &predictors, const arma::vec &responses, const arma::mat &initialPoint, const doublelambda = \fC0\fP)

Construct the LogisticRegression class with the given labeled training data. This will train the model. Optionally, specify lambda, which is the penalty parameter for L2-regularization. If not specified, it is set to 0, which results in standard (unregularized) logistic regression.

Parameters:

predictors Input training variables.

responses Outputs results from input training variables.

initialPoint Initial model to train with.

lambda L2-regularization parameter.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::\fBLogisticRegression\fP (OptimizerType< \fBLogisticRegressionFunction\fP > &optimizer)

Construct the LogisticRegression class with the given labeled training data. This will train the model. This overload takes an already instantiated optimizer (which holds the LogisticRegressionFunction error function, which must also be instantiated), so that the optimizer can be configured before the training is run by this constructor. The predictors and responses and initial point are all taken from the error function contained in the optimizer.

Parameters:

optimizer Instantiated optimizer with instantiated error function.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::\fBLogisticRegression\fP (const arma::vec ¶meters, const doublelambda = \fC0\fP)

Construct a logistic regression model from the given parameters, without performing any training. The lambda parameter is used for the ComputeAccuracy() and ComputeError() functions; this constructor does not train the model itself.

Parameters:

parameters Parameters making up the model.

lambda L2-regularization penalty parameter.

Member Function Documentation

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> double \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::ComputeAccuracy (const arma::mat &predictors, const arma::vec &responses, const doubledecisionBoundary = \fC0.5\fP) const

Compute the accuracy of the model on the given predictors and responses, optionally using the given decision boundary. The responses should be either 0 or 1. Logistic regression returns a value between 0 and 1. If the value is greater than the decision boundary, the response is taken to be 1; otherwise, it is 0. By default, the decision boundary is 0.5.

The accuracy is returned as a percentage, between 0 and 100.

Parameters:

predictors Input predictors.

responses Vector of responses.

decisionBoundary Decision boundary (default 0.5).

Returns:

Percentage of responses that are predicted correctly.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> double \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::ComputeError (const arma::mat &predictors, const arma::vec &responses) const

Compute the error of the model. This returns the negative objective function of the logistic regression log-likelihood function. For the model to be optimal, the negative log-likelihood function should be minimized.

Parameters:

predictors Input predictors.

responses Vector of responses.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> const double& \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::Lambda () const\fC [inline]\fP

Return the lambda value for L2-regularization.

Definition at line 100 of file logistic_regression.hpp.

References mlpack::regression::LogisticRegression< OptimizerType >::lambda.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> double& \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::Lambda ()\fC [inline]\fP

Modify the lambda value for L2-regularization.

Definition at line 102 of file logistic_regression.hpp.

References mlpack::regression::LogisticRegression< OptimizerType >::lambda.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> const arma::vec& \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::Parameters () const\fC [inline]\fP

Return the parameters (the b vector).

Definition at line 95 of file logistic_regression.hpp.

References mlpack::regression::LogisticRegression< OptimizerType >::parameters.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> arma::vec& \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::Parameters ()\fC [inline]\fP

Modify the parameters (the b vector).

Definition at line 97 of file logistic_regression.hpp.

References mlpack::regression::LogisticRegression< OptimizerType >::parameters.

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> void \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::Predict (const arma::mat &predictors, arma::vec &responses, const doubledecisionBoundary = \fC0.5\fP) const

Predict the responses to a given set of predictors. The responses will be either 0 or 1. Optionally, specify the decision boundary; logistic regression returns a value between 0 and 1. If the value is greater than the decision boundary, the response is taken to be 1; otherwise, it is 0. By default the decision boundary is 0.5.

Parameters:

predictors Input predictors.

responses Vector to put output predictions of responses into.

decisionBoundary Decision boundary (default 0.5).

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> std::string \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::ToString () const

Member Data Documentation

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> double \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::lambda\fC [private]\fP

L2-regularization penalty parameter.

Definition at line 155 of file logistic_regression.hpp.

Referenced by mlpack::regression::LogisticRegression< OptimizerType >::Lambda().

template<template< typename > class OptimizerType = mlpack::optimization::L_BFGS> arma::vec \fBmlpack::regression::LogisticRegression\fP< OptimizerType >::parameters\fC [private]\fP

Vector of trained parameters.

Definition at line 153 of file logistic_regression.hpp.

Referenced by mlpack::regression::LogisticRegression< OptimizerType >::Parameters().

Author

Generated automatically by Doxygen for MLPACK from the source code.