MLPACK  1.0.10
logistic_regression.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP
24 #define __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP
25 
26 #include <mlpack/core.hpp>
28 
30 
31 namespace mlpack {
32 namespace regression {
33 
34 template<
35  template<typename> class OptimizerType = mlpack::optimization::L_BFGS
36 >
38 {
39  public:
50  LogisticRegression(const arma::mat& predictors,
51  const arma::vec& responses,
52  const double lambda = 0);
53 
65  LogisticRegression(const arma::mat& predictors,
66  const arma::vec& responses,
67  const arma::mat& initialPoint,
68  const double lambda = 0);
69 
81  LogisticRegression(OptimizerType<LogisticRegressionFunction>& optimizer);
82 
92  LogisticRegression(const arma::vec& parameters, const double lambda = 0);
93 
95  const arma::vec& Parameters() const { return parameters; }
97  arma::vec& Parameters() { return parameters; }
98 
100  const double& Lambda() const { return lambda; }
102  double& Lambda() { return lambda; }
103 
115  void Predict(const arma::mat& predictors,
116  arma::vec& responses,
117  const double decisionBoundary = 0.5) const;
118 
133  double ComputeAccuracy(const arma::mat& predictors,
134  const arma::vec& responses,
135  const double decisionBoundary = 0.5) const;
136 
145  double ComputeError(const arma::mat& predictors,
146  const arma::vec& responses) const;
147 
148  // Returns a string representation of this object.
149  std::string ToString() const;
150 
151  private:
153  arma::vec parameters;
155  double lambda;
156 };
157 
158 }; // namespace regression
159 }; // namespace mlpack
160 
161 // Include implementation.
162 #include "logistic_regression_impl.hpp"
163 
164 #endif // __MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_HPP