24#ifndef MLPACK_METHODS_LARS_LARS_HPP
25#define MLPACK_METHODS_LARS_LARS_HPP
102 LARS(
const bool useCholesky =
false,
103 const double lambda1 = 0.0,
104 const double lambda2 = 0.0,
105 const double tolerance = 1e-16);
120 const arma::mat& gramMatrix,
121 const double lambda1 = 0.0,
122 const double lambda2 = 0.0,
123 const double tolerance = 1e-16);
141 const arma::rowvec& responses,
142 const bool transposeData =
true,
143 const bool useCholesky =
false,
144 const double lambda1 = 0.0,
145 const double lambda2 = 0.0,
146 const double tolerance = 1e-16);
165 const arma::rowvec& responses,
166 const bool transposeData,
167 const bool useCholesky,
168 const arma::mat& gramMatrix,
169 const double lambda1 = 0.0,
170 const double lambda2 = 0.0,
171 const double tolerance = 1e-16);
217 const arma::rowvec& responses,
219 const bool transposeData =
true);
236 const arma::rowvec& responses,
237 const bool transposeData =
true);
249 arma::rowvec& predictions,
250 const bool rowMajor =
false)
const;
253 const std::vector<size_t>&
ActiveSet()
const {
return activeSet; }
257 const std::vector<arma::vec>&
BetaPath()
const {
return betaPath; }
260 const arma::vec&
Beta()
const {
return betaPath.back(); }
264 const std::vector<double>&
LambdaPath()
const {
return lambdaPath; }
272 template<
typename Archive>
288 const arma::rowvec& y,
289 const bool rowMajor =
false);
293 arma::mat matGramInternal;
296 const arma::mat* matGram;
299 arma::mat matUtriCholFactor;
318 std::vector<arma::vec> betaPath;
321 std::vector<double> lambdaPath;
324 std::vector<size_t> activeSet;
327 std::vector<bool> isActive;
332 std::vector<size_t> ignoreSet;
335 std::vector<bool> isIgnored;
342 void Deactivate(
const size_t activeVarInd);
349 void Activate(
const size_t varInd);
356 void Ignore(
const size_t varInd);
359 void ComputeYHatDirection(
const arma::mat& matX,
360 const arma::vec& betaDirection,
361 arma::vec& yHatDirection);
364 void InterpolateBeta();
366 void CholeskyInsert(
const arma::vec& newX,
const arma::mat& X);
368 void CholeskyInsert(
double sqNormNewX,
const arma::vec& newGramCol);
370 void GivensRotate(
const arma::vec::fixed<2>& x,
371 arma::vec::fixed<2>& rotatedX,
374 void CholeskyDelete(
const size_t colToKill);
381#include "lars_impl.hpp"
An implementation of LARS, a stage-wise homotopy-based algorithm for l1-regularized linear regression...
double ComputeError(const arma::mat &matX, const arma::rowvec &y, const bool rowMajor=false)
Compute cost error of the given data matrix using the currently-trained LARS model.
LARS(const arma::mat &data, const arma::rowvec &responses, const bool transposeData, const bool useCholesky, const arma::mat &gramMatrix, const double lambda1=0.0, const double lambda2=0.0, const double tolerance=1e-16)
Set the parameters to LARS, pass in a precalculated Gram matrix, and run training.
LARS(const LARS &other)
Construct the LARS object by copying the given LARS object.
double Train(const arma::mat &data, const arma::rowvec &responses, const bool transposeData=true)
Run LARS.
const std::vector< size_t > & ActiveSet() const
Access the set of active dimensions.
LARS(const bool useCholesky=false, const double lambda1=0.0, const double lambda2=0.0, const double tolerance=1e-16)
Set the parameters to LARS.
double Train(const arma::mat &data, const arma::rowvec &responses, arma::vec &beta, const bool transposeData=true)
Run LARS.
LARS(const arma::mat &data, const arma::rowvec &responses, const bool transposeData=true, const bool useCholesky=false, const double lambda1=0.0, const double lambda2=0.0, const double tolerance=1e-16)
Set the parameters to LARS and run training.
LARS & operator=(const LARS &other)
Copy the given LARS object.
LARS(LARS &&other)
Construct the LARS object by taking ownership of the given LARS object.
LARS(const bool useCholesky, const arma::mat &gramMatrix, const double lambda1=0.0, const double lambda2=0.0, const double tolerance=1e-16)
Set the parameters to LARS, and pass in a precalculated Gram matrix.
const std::vector< arma::vec > & BetaPath() const
Access the set of coefficients after each iteration; the solution is the last element.
const arma::vec & Beta() const
Access the solution coefficients.
const arma::mat & MatUtriCholFactor() const
Access the upper triangular cholesky factor.
LARS & operator=(LARS &&other)
Take ownership of the given LARS object.
const std::vector< double > & LambdaPath() const
Access the set of values for lambda1 after each iteration; the solution is the last element.
void serialize(Archive &ar, const unsigned int)
Serialize the LARS model.
void Predict(const arma::mat &points, arma::rowvec &predictions, const bool rowMajor=false) const
Predict y_i for each data point in the given data matrix using the currently-trained LARS model.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.