13 #ifndef MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP 14 #define MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP 22 namespace regression {
33 template<
typename MatType = arma::mat>
53 const arma::Row<size_t>& responses,
73 const arma::Row<size_t>& responses,
74 const arma::vec& initialPoint,
101 template<
template<
typename>
class OptimizerType>
121 void Train(
const MatType& predictors,
122 const arma::Row<size_t>& responses);
166 void Predict(
const MatType& predictors,
167 arma::Row<size_t>& responses,
168 const double decisionBoundary = 0.5)
const;
181 template<
typename VecType>
182 size_t Classify(
const VecType& point,
183 const double decisionBoundary = 0.5)
const;
196 void Classify(
const MatType& dataset,
197 arma::Row<size_t>& labels,
198 const double decisionBoundary = 0.5)
const;
206 void Classify(
const MatType& dataset,
207 arma::mat& probabilities)
const;
224 const arma::Row<size_t>& responses,
225 const double decisionBoundary = 0.5)
const;
236 const arma::Row<size_t>& responses)
const;
239 template<
typename Archive>
240 void Serialize(Archive& ar,
const unsigned int );
253 #include "logistic_regression_impl.hpp" 255 #endif // MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP void Predict(const MatType &predictors, arma::Row< size_t > &responses, const double decisionBoundary=0.5) const
Predict the responses to a given set of predictors.
The log-likelihood function for the logistic regression objective function.
Linear algebra utility functions, generally performed on matrices or vectors.
void Train(const MatType &predictors, const arma::Row< size_t > &responses)
Train the LogisticRegression model on the given input data.
void Serialize(Archive &ar, const unsigned int)
Serialize the model.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const double & Lambda() const
Return the lambda value for L2-regularization.
double ComputeError(const MatType &predictors, const arma::Row< size_t > &responses) const
Compute the error of the model.
double ComputeAccuracy(const MatType &predictors, const arma::Row< size_t > &responses, const double decisionBoundary=0.5) const
Compute the accuracy of the model on the given predictors and responses, optionally using the given d...
double & Lambda()
Modify the lambda value for L2-regularization.
const arma::vec & Parameters() const
Return the parameters (the b vector).
double lambda
L2-regularization penalty parameter.
arma::vec & Parameters()
Modify the parameters (the b vector).
LogisticRegression(const MatType &predictors, const arma::Row< size_t > &responses, const double lambda=0)
Construct the LogisticRegression class with the given labeled training data.
The generic L-BFGS optimizer, which uses a back-tracking line search algorithm to minimize a function...
arma::vec parameters
Vector of trained parameters (size: dimensionality plus one).
size_t Classify(const VecType &point, const double decisionBoundary=0.5) const
Classify the given point.
The LogisticRegression class implements an L2-regularized logistic regression model, and supports training with multiple optimizers and classification.