[mlpack-svn] r10702 - mlpack/trunk/src/mlpack/methods/lars
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Sun Dec 11 15:38:49 EST 2011
Author: niche
Date: 2011-12-11 15:38:49 -0500 (Sun, 11 Dec 2011)
New Revision: 10702
Modified:
mlpack/trunk/src/mlpack/methods/lars/lars.cpp
mlpack/trunk/src/mlpack/methods/lars/lars.hpp
mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp
Log:
cleaned up lars
Modified: mlpack/trunk/src/mlpack/methods/lars/lars.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/lars/lars.cpp 2011-12-11 19:12:53 UTC (rev 10701)
+++ mlpack/trunk/src/mlpack/methods/lars/lars.cpp 2011-12-11 20:38:49 UTC (rev 10702)
@@ -70,75 +70,11 @@
}
}
-
void LARS::ComputeXty()
{
- matXTy = trans(matX) * y;
+ vecXTy = trans(matX) * y;
}
- /*
-void LARS::UpdateX(const std::vector<int>& colInds, const mat& matNewCols)
-{
- for (u32 i = 0; i < colInds.size(); i++)
- matX.col(colInds[i]) = matNewCols.col(i);
-
- if (!useCholesky)
- UpdateGram(colInds);
-
- UpdateXty(colInds);
-}
-
-void LARS::UpdateGram(const std::vector<int>& colInds)
-{
- for (std::vector<int>::const_iterator i = colInds.begin();
- i != colInds.end(); ++i)
- {
- for (std::vector<int>::const_iterator j = colInds.begin();
- j != colInds.end(); ++j)
- {
- matGram(*i, *j) = dot(matX.col(*i), matX.col(*j));
- }
- }
-
- if (elasticNet)
- {
- for (std::vector<int>::const_iterator i = colInds.begin();
- i != colInds.end(); ++i)
- {
- matGram(*i, *i) += lambda2;
- }
- }
-}
-
-void LARS::UpdateXty(const std::vector<int>& colInds)
-{
- for (std::vector<int>::const_iterator i = colInds.begin();
- i != colInds.end(); ++i)
- matXTy(*i) = dot(matX.col(*i), y);
-}
- */
-
-/*
-void LARS::PrintGram()
-{
- matGram.print("Gram matrix");
-}
-*/
-
- /*
-void LARS::SetY(const vec& y)
-{
- this->y = y;
-}
- */
-
- /*
-void LARS::PrintY()
-{
- y.print();
-}
- */
-
const std::vector<u32> LARS::ActiveSet()
{
return activeSet;
@@ -154,12 +90,10 @@
return lambdaPath;
}
- /*
-void LARS::SetDesiredLambda(double lambda1)
+const mat LARS::MatUtriCholFactor()
{
- this->lambda1 = lambda1;
+ return matUtriCholFactor;
}
- */
void LARS::DoLARS()
{
@@ -189,7 +123,7 @@
lambda2 = 0; // just in case it is accidentally used, the code still will be correct
}
- vec corr = matXTy;
+ vec corr = vecXTy;
vec absCorr = abs(corr);
u32 changeInd;
double maxCorr = absCorr.max(changeInd); // change_ind gets set here
@@ -384,7 +318,7 @@
Deactivate(changeInd);
}
- corr = matXTy - trans(matX) * yHat;
+ corr = vecXTy - trans(matX) * yHat;
if (elasticNet)
{
corr -= lambda2 * beta;
@@ -415,13 +349,9 @@
beta = BetaPath().back();
}
-void LARS::GetCholFactor(mat& matUtriCholFactor)
-{
- matUtriCholFactor = this->matUtriCholFactor;
-}
- // private functions
+ ////////// private functions //////////
void LARS::Deactivate(u32 activeVarInd)
{
Modified: mlpack/trunk/src/mlpack/methods/lars/lars.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/lars/lars.hpp 2011-12-11 19:12:53 UTC (rev 10701)
+++ mlpack/trunk/src/mlpack/methods/lars/lars.hpp 2011-12-11 20:38:49 UTC (rev 10702)
@@ -87,41 +87,27 @@
void ComputeXty();
- //void UpdateX(const std::vector<int>& colInds, const arma::mat& matNewCols);
-
- //void UpdateGram(const std::vector<int>& colInds);
-
- //void UpdateXty(const std::vector<int>& colInds);
-
- //void PrintGram();
-
- //void SetY(const arma::vec& y);
-
- //void PrintY();
-
const std::vector<arma::u32> ActiveSet();
const std::vector<arma::vec> BetaPath();
const std::vector<double> LambdaPath();
-
- //void SetDesiredLambda(double lambda1);
+ const arma::mat MatUtriCholFactor();
+
void DoLARS();
void Solution(arma::vec& beta);
- void GetCholFactor(arma::mat& matUtriCholFactor);
-
-
private:
arma::mat matX;
arma::vec y;
- arma::vec matXTy;
+ arma::vec vecXTy;
arma::mat matGram;
- //! Upper triangular cholesky factor; initially 0x0 arma::matrix.
+
+ // Upper triangular cholesky factor; initially 0x0 arma::matrix.
arma::mat matUtriCholFactor;
bool useCholesky;
Modified: mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp 2011-12-11 19:12:53 UTC (rev 10701)
+++ mlpack/trunk/src/mlpack/methods/lars/lars_main.cpp 2011-12-11 20:38:49 UTC (rev 10702)
@@ -30,7 +30,7 @@
int main(int argc, char* argv[])
{
-
+
// Handle parameters
CLI::ParseCommandLine(argc, argv);
More information about the mlpack-svn
mailing list