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);
75 void Train(
const arma::mat& predictors,
76 const arma::rowvec& responses,
77 const bool intercept =
true);
91 void Train(
const arma::mat& predictors,
92 const arma::rowvec& responses,
93 const arma::rowvec& weights,
94 const bool intercept =
true);
102 void Predict(
const arma::mat& points, arma::rowvec& predictions)
const;
122 const arma::rowvec& responses)
const;
140 template<
typename Archive>
143 ar & BOOST_SERIALIZATION_NVP(parameters);
144 ar & BOOST_SERIALIZATION_NVP(lambda);
145 ar & BOOST_SERIALIZATION_NVP(intercept);
153 arma::vec parameters;
168 #endif // MLPACK_METHODS_LINEAR_REGRESSION_HPP void Predict(const arma::mat &points, arma::rowvec &predictions) const
Calculate y_i for each data point in points.
arma::vec & Parameters()
Modify the parameters (the b vector).
A simple linear regression algorithm using ordinary least squares.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Train(const arma::mat &predictors, const arma::rowvec &responses, const bool intercept=true)
Train the LinearRegression model on the given data.
const arma::vec & Parameters() const
Return the parameters (the b vector).
double Lambda() const
Return the Tikhonov regularization parameter for ridge regression.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
double & Lambda()
Modify the Tikhonov regularization parameter for ridge regression.
LinearRegression()
Empty constructor.
bool Intercept() const
Return whether or not an intercept term is used in the model.
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...