14 #ifndef MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP 15 #define MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP 23 namespace regression {
38 template<
typename MatType = arma::mat>
58 const arma::Row<size_t>& responses,
59 const double lambda = 0);
78 const arma::Row<size_t>& responses,
79 const arma::rowvec& initialPoint,
80 const double lambda = 0);
93 const double lambda = 0);
110 template<
typename OptimizerType>
112 const arma::Row<size_t>& responses,
113 OptimizerType& optimizer,
114 const double lambda);
129 template<
typename OptimizerType = mlpack::optimization::L_BFGS>
130 void Train(
const MatType& predictors,
131 const arma::Row<size_t>& responses);
149 template<
typename OptimizerType>
150 void Train(
const MatType& predictors,
151 const arma::Row<size_t>& responses,
152 OptimizerType& optimizer);
155 const arma::rowvec&
Parameters()
const {
return parameters; }
160 const double&
Lambda()
const {
return lambda; }
175 template<
typename VecType>
176 size_t Classify(
const VecType& point,
177 const double decisionBoundary = 0.5)
const;
190 void Classify(
const MatType& dataset,
191 arma::Row<size_t>& labels,
192 const double decisionBoundary = 0.5)
const;
200 void Classify(
const MatType& dataset,
201 arma::mat& probabilities)
const;
218 const arma::Row<size_t>& responses,
219 const double decisionBoundary = 0.5)
const;
230 const arma::Row<size_t>& responses)
const;
233 template<
typename Archive>
234 void serialize(Archive& ar,
const unsigned int );
238 arma::rowvec parameters;
247 #include "logistic_regression_impl.hpp" 249 #endif // MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t Classify(const VecType &point, const double decisionBoundary=0.5) const
Classify the given point.
LogisticRegression(const MatType &predictors, const arma::Row< size_t > &responses, const double lambda=0)
Construct the LogisticRegression class with the given labeled training data.
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...
arma::rowvec & Parameters()
Modify the parameters (the b vector).
double ComputeError(const MatType &predictors, const arma::Row< size_t > &responses) const
Compute the error of the model.
const double & Lambda() const
Return the lambda value for L2-regularization.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
double & Lambda()
Modify the lambda value for L2-regularization.
const arma::rowvec & Parameters() const
Return the parameters (the b vector).
void Train(const MatType &predictors, const arma::Row< size_t > &responses)
Train the LogisticRegression model on the given input data.
The LogisticRegression class implements an L2-regularized logistic regression model, and supports training with multiple optimizers and classification.