mlpack  2.0.1
logistic_regression_function.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP
17 #define __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP
18 
19 #include <mlpack/core.hpp>
20 
21 namespace mlpack {
22 namespace regression {
23 
29 template<typename MatType = arma::mat>
31 {
32  public:
34  const arma::Row<size_t>& responses,
35  const double lambda = 0);
36 
37  LogisticRegressionFunction(const MatType& predictors,
38  const arma::Row<size_t>& responses,
39  const arma::vec& initialPoint,
40  const double lambda = 0);
41 
43  const arma::mat& InitialPoint() const { return initialPoint; }
45  arma::mat& InitialPoint() { return initialPoint; }
46 
48  const double& Lambda() const { return lambda; }
50  double& Lambda() { return lambda; }
51 
53  const MatType& Predictors() const { return predictors; }
55  const arma::vec& Responses() const { return responses; }
56 
68  double Evaluate(const arma::mat& parameters) const;
69 
84  double Evaluate(const arma::mat& parameters, const size_t i) const;
85 
93  void Gradient(const arma::mat& parameters, arma::mat& gradient) const;
94 
105  void Gradient(const arma::mat& parameters,
106  const size_t i,
107  arma::mat& gradient) const;
108 
110  const arma::mat& GetInitialPoint() const { return initialPoint; }
111 
113  size_t NumFunctions() const { return predictors.n_cols; }
114 
115  private:
117  arma::mat initialPoint;
119  const MatType& predictors;
121  const arma::Row<size_t>& responses;
123  double lambda;
124 };
125 
126 } // namespace regression
127 } // namespace mlpack
128 
129 // Include implementation.
130 #include "logistic_regression_function_impl.hpp"
131 
132 #endif // __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP
The log-likelihood function for the logistic regression objective function.
void Gradient(const arma::mat &parameters, arma::mat &gradient) const
Evaluate the gradient of the logistic regression log-likelihood function with the given parameters...
Linear algebra utility functions, generally performed on matrices or vectors.
size_t NumFunctions() const
Return the number of separable functions (the number of predictor points).
arma::mat initialPoint
The initial point, from which to start the optimization.
const arma::mat & InitialPoint() const
Return the initial point for the optimization.
double Evaluate(const arma::mat &parameters) const
Evaluate the logistic regression log-likelihood function with the given parameters.
const MatType & predictors
The matrix of data points (predictors).
double & Lambda()
Modify the regularization parameter (lambda).
const arma::Row< size_t > & responses
The vector of responses to the input data points.
arma::mat & InitialPoint()
Modify the initial point for the optimization.
const double & Lambda() const
Return the regularization parameter (lambda).
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
const arma::vec & Responses() const
Return the vector of responses.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
const MatType & Predictors() const
Return the matrix of predictors.
double lambda
The regularization parameter for L2-regularization.
LogisticRegressionFunction(const MatType &predictors, const arma::Row< size_t > &responses, const double lambda=0)