mlpack
1.0.12
|
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. More... | |
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. More... | |
LogisticRegression (OptimizerType< LogisticRegressionFunction > &optimizer) | |
Construct the LogisticRegression class with the given labeled training data. More... | |
LogisticRegression (const arma::vec ¶meters, const double lambda=0) | |
Construct a logistic regression model from the given parameters, without performing any training. More... | |
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. More... | |
double | ComputeError (const arma::mat &predictors, const arma::vec &responses) const |
Compute the error of the model. More... | |
const double & | Lambda () const |
Return the lambda value for L2-regularization. More... | |
double & | Lambda () |
Modify the lambda value for L2-regularization. More... | |
const arma::vec & | Parameters () const |
Return the parameters (the b vector). More... | |
arma::vec & | Parameters () |
Modify the parameters (the b vector). More... | |
void | Predict (const arma::mat &predictors, arma::vec &responses, const double decisionBoundary=0.5) const |
Predict the responses to a given set of predictors. More... | |
std::string | ToString () const |
Private Attributes | |
double | lambda |
L2-regularization penalty parameter. More... | |
arma::vec | parameters |
Vector of trained parameters. More... | |
Definition at line 29 of file logistic_regression.hpp.
mlpack::regression::LogisticRegression< OptimizerType >::LogisticRegression | ( | const arma::mat & | predictors, |
const arma::vec & | responses, | ||
const double | lambda = 0 |
||
) |
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.
predictors | Input training variables. |
responses | Outputs resulting from input training variables. |
lambda | L2-regularization parameter. |
mlpack::regression::LogisticRegression< OptimizerType >::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.
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.
predictors | Input training variables. |
responses | Outputs results from input training variables. |
initialPoint | Initial model to train with. |
lambda | L2-regularization parameter. |
mlpack::regression::LogisticRegression< OptimizerType >::LogisticRegression | ( | OptimizerType< LogisticRegressionFunction > & | 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.
optimizer | Instantiated optimizer with instantiated error function. |
mlpack::regression::LogisticRegression< OptimizerType >::LogisticRegression | ( | const arma::vec & | parameters, |
const double | lambda = 0 |
||
) |
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 making up the model. |
lambda | L2-regularization penalty parameter. |
double mlpack::regression::LogisticRegression< OptimizerType >::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.
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.
predictors | Input predictors. |
responses | Vector of responses. |
decisionBoundary | Decision boundary (default 0.5). |
double mlpack::regression::LogisticRegression< 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.
predictors | Input predictors. |
responses | Vector of responses. |
|
inline |
Return the lambda value for L2-regularization.
Definition at line 92 of file logistic_regression.hpp.
References mlpack::regression::LogisticRegression< OptimizerType >::lambda.
|
inline |
Modify the lambda value for L2-regularization.
Definition at line 94 of file logistic_regression.hpp.
References mlpack::regression::LogisticRegression< OptimizerType >::lambda.
|
inline |
Return the parameters (the b vector).
Definition at line 87 of file logistic_regression.hpp.
References mlpack::regression::LogisticRegression< OptimizerType >::parameters.
|
inline |
Modify the parameters (the b vector).
Definition at line 89 of file logistic_regression.hpp.
References mlpack::regression::LogisticRegression< OptimizerType >::parameters.
void mlpack::regression::LogisticRegression< OptimizerType >::Predict | ( | const arma::mat & | predictors, |
arma::vec & | responses, | ||
const double | decisionBoundary = 0.5 |
||
) | 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.
predictors | Input predictors. |
responses | Vector to put output predictions of responses into. |
decisionBoundary | Decision boundary (default 0.5). |
std::string mlpack::regression::LogisticRegression< OptimizerType >::ToString | ( | ) | const |
|
private |
L2-regularization penalty parameter.
Definition at line 147 of file logistic_regression.hpp.
Referenced by mlpack::regression::LogisticRegression< OptimizerType >::Lambda().
|
private |
Vector of trained parameters.
Definition at line 145 of file logistic_regression.hpp.
Referenced by mlpack::regression::LogisticRegression< OptimizerType >::Parameters().