MLPACK  1.0.10
logistic_regression_function.hpp
Go to the documentation of this file.
1 
24 #ifndef __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP
25 #define __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP
26 
27 #include <mlpack/core.hpp>
28 
29 namespace mlpack {
30 namespace regression {
31 
38 {
39  public:
40  LogisticRegressionFunction(const arma::mat& predictors,
41  const arma::vec& responses,
42  const double lambda = 0);
43 
44  LogisticRegressionFunction(const arma::mat& predictors,
45  const arma::vec& responses,
46  const arma::mat& initialPoint,
47  const double lambda = 0);
48 
50  const arma::mat& InitialPoint() const { return initialPoint; }
52  arma::mat& InitialPoint() { return initialPoint; }
53 
55  const double& Lambda() const { return lambda; }
57  double& Lambda() { return lambda; }
58 
60  const arma::mat& Predictors() const { return predictors; }
62  const arma::vec& Responses() const { return responses; }
63 
75  double Evaluate(const arma::mat& parameters) const;
76 
91  double Evaluate(const arma::mat& parameters, const size_t i) const;
92 
100  void Gradient(const arma::mat& parameters, arma::mat& gradient) const;
101 
112  void Gradient(const arma::mat& parameters,
113  const size_t i,
114  arma::mat& gradient) const;
115 
117  const arma::mat& GetInitialPoint() const { return initialPoint; }
118 
120  size_t NumFunctions() const { return predictors.n_cols; }
121 
122  private:
124  arma::mat initialPoint;
126  const arma::mat& predictors;
128  const arma::vec& responses;
130  double lambda;
131 };
132 
133 }; // namespace regression
134 }; // namespace mlpack
135 
136 #endif // __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP
The log-likelihood function for the logistic regression objective function.
const arma::mat & GetInitialPoint() const
Return the initial point for the optimization.
const double & Lambda() const
Return the regularization parameter (lambda).
void Gradient(const arma::mat &parameters, arma::mat &gradient) const
Evaluate the gradient of the logistic regression log-likelihood function with the given parameters...
arma::mat initialPoint
The initial point, from which to start the optimization.
double & Lambda()
Modify the regularization parameter (lambda).
const arma::vec & Responses() const
Return the vector of responses.
arma::mat & InitialPoint()
Modify the initial point for the optimization.
size_t NumFunctions() const
Return the number of separable functions (the number of predictor points).
const arma::mat & predictors
The matrix of data points (predictors).
const arma::vec & responses
The vector of responses to the input data points.
const arma::mat & Predictors() const
Return the matrix of predictors.
const arma::mat & InitialPoint() const
Return the initial point for the optimization.
LogisticRegressionFunction(const arma::mat &predictors, const arma::vec &responses, const double lambda=0)
double lambda
The regularization parameter for L2-regularization.
double Evaluate(const arma::mat &parameters) const
Evaluate the logistic regression log-likelihood function with the given parameters.