24 #ifndef MLPACK_METHODS_LARS_LARS_HPP
25 #define MLPACK_METHODS_LARS_LARS_HPP
30 namespace regression {
102 LARS(
const bool useCholesky,
103 const double lambda1 = 0.0,
104 const double lambda2 = 0.0,
105 const double tolerance = 1e-16);
119 LARS(
const bool useCholesky,
120 const arma::mat& gramMatrix,
121 const double lambda1 = 0.0,
122 const double lambda2 = 0.0,
123 const double tolerance = 1e-16);
139 void Train(
const arma::mat& data,
140 const arma::vec& responses,
142 const bool transposeData =
true);
153 void Predict(
const arma::mat& points,
154 arma::vec& predictions,
155 const bool rowMajor =
false)
const;
158 const std::vector<size_t>&
ActiveSet()
const {
return activeSet; }
162 const std::vector<arma::vec>&
BetaPath()
const {
return betaPath; }
166 const std::vector<double>&
LambdaPath()
const {
return lambdaPath; }
174 template<
typename Archive>
175 void Serialize(Archive& ar,
const unsigned int );
179 arma::mat matGramInternal;
182 const arma::mat* matGram;
185 arma::mat matUtriCholFactor;
204 std::vector<arma::vec> betaPath;
207 std::vector<double> lambdaPath;
210 std::vector<size_t> activeSet;
213 std::vector<bool> isActive;
218 std::vector<size_t> ignoreSet;
221 std::vector<bool> isIgnored;
228 void Deactivate(
const size_t activeVarInd);
235 void Activate(
const size_t varInd);
242 void Ignore(
const size_t varInd);
245 void ComputeYHatDirection(
const arma::mat& matX,
246 const arma::vec& betaDirection,
247 arma::vec& yHatDirection);
250 void InterpolateBeta();
252 void CholeskyInsert(
const arma::vec& newX,
const arma::mat& X);
254 void CholeskyInsert(
double sqNormNewX,
const arma::vec& newGramCol);
256 void GivensRotate(
const arma::vec::fixed<2>& x,
257 arma::vec::fixed<2>& rotatedX,
260 void CholeskyDelete(
const size_t colToKill);
267 #include "lars_impl.hpp"
void Serialize(Archive &ar, const unsigned int)
Serialize the LARS model.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const std::vector< double > & LambdaPath() const
Access the set of values for lambda1 after each iteration; the solution is the last element...
const std::vector< size_t > & ActiveSet() const
Access the set of active dimensions.
An implementation of LARS, a stage-wise homotopy-based algorithm for l1-regularized linear regression...
LARS(const bool useCholesky, const double lambda1=0.0, const double lambda2=0.0, const double tolerance=1e-16)
Set the parameters to LARS.
void Predict(const arma::mat &points, arma::vec &predictions, const bool rowMajor=false) const
Predict y_i for each data point in the given data matrix, using the currently-trained LARS model (so ...
void Train(const arma::mat &data, const arma::vec &responses, arma::vec &beta, const bool transposeData=true)
Run LARS.
const std::vector< arma::vec > & BetaPath() const
Access the set of coefficients after each iteration; the solution is the last element.
const arma::mat & MatUtriCholFactor() const
Access the upper triangular cholesky factor.