13 #ifndef MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP 14 #define MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP 19 namespace regression {
38 const arma::rowvec& responses,
39 const double lambda = 0,
40 const bool intercept =
true);
52 const arma::rowvec& responses,
53 const arma::rowvec& weights,
54 const double lambda = 0,
55 const bool intercept =
true);
76 double Train(
const arma::mat& predictors,
77 const arma::rowvec& responses,
78 const bool intercept =
true);
93 double Train(
const arma::mat& predictors,
94 const arma::rowvec& responses,
95 const arma::rowvec& weights,
96 const bool intercept =
true);
104 void Predict(
const arma::mat& points, arma::rowvec& predictions)
const;
124 const arma::rowvec& responses)
const;
142 template<
typename Archive>
145 ar(CEREAL_NVP(parameters));
146 ar(CEREAL_NVP(lambda));
147 ar(CEREAL_NVP(intercept));
155 arma::vec parameters;
170 #endif // MLPACK_METHODS_LINEAR_REGRESSION_HPP double Train(const arma::mat &predictors, const arma::rowvec &responses, const bool intercept=true)
Train the LinearRegression model on the given data.
Definition: linear_regression.cpp:37
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
A simple linear regression algorithm using ordinary least squares.
Definition: linear_regression.hpp:26
The core includes that mlpack expects; standard C++ includes and Armadillo.
double & Lambda()
Modify the Tikhonov regularization parameter for ridge regression.
Definition: linear_regression.hpp:134
bool Intercept() const
Return whether or not an intercept term is used in the model.
Definition: linear_regression.hpp:137
double Lambda() const
Return the Tikhonov regularization parameter for ridge regression.
Definition: linear_regression.hpp:132
const arma::vec & Parameters() const
Return the parameters (the b vector).
Definition: linear_regression.hpp:127
LinearRegression()
Empty constructor.
Definition: linear_regression.hpp:62
void Predict(const arma::mat &points, arma::rowvec &predictions) const
Calculate y_i for each data point in points.
Definition: linear_regression.cpp:91
arma::vec & Parameters()
Modify the parameters (the b vector).
Definition: linear_regression.hpp:129
double ComputeError(const arma::mat &points, const arma::rowvec &responses) const
Calculate the L2 squared error on the given predictors and responses using this linear regression mod...
Definition: linear_regression.cpp:115
void serialize(Archive &ar, const uint32_t)
Serialize the model.
Definition: linear_regression.hpp:143