MLPACK  1.0.7
linear_regression.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP
23 #define __MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP
24 
25 #include <mlpack/core.hpp>
26 
27 namespace mlpack {
28 namespace regression {
29 
36 {
37  public:
44  LinearRegression(const arma::mat& predictors,
45  const arma::vec& responses,
46  const double lambda = 0);
47 
53  LinearRegression(const std::string& filename);
54 
60  LinearRegression(const LinearRegression& linearRegression);
61 
66 
73  void Predict(const arma::mat& points, arma::vec& predictions) const;
74 
92  double ComputeError(const arma::mat& points,
93  const arma::vec& responses) const;
94 
96  const arma::vec& Parameters() const { return parameters; }
98  arma::vec& Parameters() { return parameters; }
99 
101  double Lambda() const { return lambda; }
103  double& Lambda() { return lambda; }
104 
105  private:
110  arma::vec parameters;
111 
116  double lambda;
117 };
118 
119 }; // namespace linear_regression
120 }; // namespace mlpack
121 
122 #endif // __MLPACK_METHODS_LINEAR_REGRESSCLIN_HPP
void Predict(const arma::mat &points, arma::vec &predictions) const
Calculate y_i for each data point in points.
A simple linear regression algorithm using ordinary least squares.
double & Lambda()
Modify the Tikhonov regularization parameter for ridge regression.
arma::vec parameters
The calculated B.
double ComputeError(const arma::mat &points, const arma::vec &responses) const
Calculate the L2 squared error on the given predictors and responses using this linear regression mod...
double Lambda() const
Return the Tikhonov regularization parameter for ridge regression.
double lambda
The Tikhonov regularization parameter for ridge regression (0 for linear regression).
const arma::vec & Parameters() const
Return the parameters (the b vector).
arma::vec & Parameters()
Modify the parameters (the b vector).