14#ifndef MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP
15#define MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP
18#include <ensmallen.hpp>
38template<
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);
133 template<
typename OptimizerType = ens::L_BFGS,
typename... CallbackTypes>
134 double Train(
const MatType& predictors,
135 const arma::Row<size_t>& responses,
136 CallbackTypes&&... callbacks);
156 template<
typename OptimizerType,
typename... CallbackTypes>
157 double Train(
const MatType& predictors,
158 const arma::Row<size_t>& responses,
159 OptimizerType& optimizer,
160 CallbackTypes&&... callbacks);
163 const arma::rowvec&
Parameters()
const {
return parameters; }
168 const double&
Lambda()
const {
return lambda; }
183 template<
typename VecType>
185 const double decisionBoundary = 0.5)
const;
199 arma::Row<size_t>& labels,
200 const double decisionBoundary = 0.5)
const;
209 arma::mat& probabilities)
const;
226 const arma::Row<size_t>& responses,
227 const double decisionBoundary = 0.5)
const;
238 const arma::Row<size_t>& responses)
const;
241 template<
typename Archive>
246 arma::rowvec parameters;
255#include "logistic_regression_impl.hpp"
The LogisticRegression class implements an L2-regularized logistic regression model,...
LogisticRegression(const MatType &predictors, const arma::Row< size_t > &responses, const double lambda=0)
Construct the LogisticRegression class with the given labeled training data.
void Classify(const MatType &dataset, arma::Row< size_t > &labels, const double decisionBoundary=0.5) const
Classify the given points, returning the predicted labels for each point.
LogisticRegression(const MatType &predictors, const arma::Row< size_t > &responses, const arma::rowvec &initialPoint, const double lambda=0)
Construct the LogisticRegression class with the given labeled training data.
LogisticRegression(const size_t dimensionality=0, const double lambda=0)
Construct the LogisticRegression class without performing any training.
const double & Lambda() const
Return the lambda value for L2-regularization.
double & Lambda()
Modify the lambda value for L2-regularization.
const arma::rowvec & Parameters() const
Return the parameters (the b vector).
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...
size_t Classify(const VecType &point, const double decisionBoundary=0.5) const
Classify the given point.
arma::rowvec & Parameters()
Modify the parameters (the b vector).
LogisticRegression(const MatType &predictors, const arma::Row< size_t > &responses, OptimizerType &optimizer, const double lambda)
Construct the LogisticRegression class with the given labeled training data.
void Classify(const MatType &dataset, arma::mat &probabilities) const
Classify the given points, returning class probabilities for each point.
double ComputeError(const MatType &predictors, const arma::Row< size_t > &responses) const
Compute the error of the model.
double Train(const MatType &predictors, const arma::Row< size_t > &responses, CallbackTypes &&... callbacks)
Train the LogisticRegression model on the given input data.
double Train(const MatType &predictors, const arma::Row< size_t > &responses, OptimizerType &optimizer, CallbackTypes &&... callbacks)
Train the LogisticRegression model with the given instantiated optimizer.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.