15 #ifndef __MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP 16 #define __MLPACK_METHODS_LINEAR_REGRESSION_LINEAR_REGRESSION_HPP 21 namespace regression {
41 const arma::vec& responses,
44 const arma::vec& weights = arma::vec());
72 void Train(
const arma::mat& predictors,
73 const arma::vec& responses,
75 const arma::vec& weights = arma::vec());
83 void Predict(
const arma::mat& points, arma::vec& predictions)
const;
103 const arma::vec& responses)
const;
121 template<
typename Archive>
149 #endif // __MLPACK_METHODS_LINEAR_REGRESSION_HPP void Predict(const arma::mat &points, arma::vec &predictions) const
Calculate y_i for each data point in points.
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
A simple linear regression algorithm using ordinary least squares.
bool intercept
Indicates whether first parameter is intercept.
double & Lambda()
Modify the Tikhonov regularization parameter for ridge regression.
arma::vec parameters
The calculated B.
void Train(const arma::mat &predictors, const arma::vec &responses, const bool intercept=true, const arma::vec &weights=arma::vec())
Train the LinearRegression model on the given data.
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...
bool Intercept() const
Return whether or not an intercept term is used in the model.
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).
LinearRegression()
Empty constructor.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
arma::vec & Parameters()
Modify the parameters (the b vector).
void Serialize(Archive &ar, const unsigned int)
Serialize the model.