[mlpack-svn] r15874 - mlpack/trunk/src/mlpack/methods/cf

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Sep 30 15:40:36 EDT 2013


Author: rcurtin
Date: Mon Sep 30 15:40:36 2013
New Revision: 15874

Log:
Decompose() is only called once, so just inline it because it's simple.


Modified:
   mlpack/trunk/src/mlpack/methods/cf/cf.cpp
   mlpack/trunk/src/mlpack/methods/cf/cf.hpp

Modified: mlpack/trunk/src/mlpack/methods/cf/cf.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/cf/cf.cpp	(original)
+++ mlpack/trunk/src/mlpack/methods/cf/cf.cpp	Mon Sep 30 15:40:36 2013
@@ -79,9 +79,16 @@
 
 void CF::CalculateApproximateRatings()
 {
-  Log::Info<<"CalculatineApproximateRating"<<endl;
-  //Decompose the size_tiial table size_to user and item
-  Decompose();
+  // Decompose the sparse data matrix to user and data matrices.
+  // Should this rank be parameterizable?
+  size_t rank = 2;
+
+  // Presently only ALS (via NMF) is supported as an optimizer.  This should be
+  // converted to a template when more optimizers are available.
+  NMF<RandomInitialization, WAlternatingLeastSquaresRule,
+      HAlternatingLeastSquaresRule> als(10000, 1e-5);
+  als.Apply(cleanedData, rank, w, h);
+
   //Generate new table by multiplying approximate values
   GenerateRating();
 }
@@ -157,18 +164,6 @@
     mask(data(1, i) - 1, data(0, i) - 1) = -1.0;
 }
 
-void CF::Decompose()
-{
-  // Should this rank be parameterizable?
-  size_t rank = 2;
-
-  // Presently only ALS (via NMF) is supported as an optimizer.  This should be
-  // converted to a template when more optimizers are available.
-  NMF<RandomInitialization, WAlternatingLeastSquaresRule,
-      HAlternatingLeastSquaresRule> als(10000, 1e-5);
-  als.Apply(cleanedData, rank, w, h);
-}
-
 void CF::GenerateRating()
 {
   Log::Info<<"GenerateRatings"<<endl;

Modified: mlpack/trunk/src/mlpack/methods/cf/cf.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/cf/cf.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/cf/cf.hpp	Mon Sep 30 15:40:36 2013
@@ -196,8 +196,6 @@
   void CalculateApproximateRatings();
   //!Converts the User, Item, Value Matrix to User-Item Table
   void CleanData();
-  //!Decomposes the cleanedData size_to user and item matrices
-  void Decompose();
   //!Create ratings from user and item matrices
   void GenerateRating();
 



More information about the mlpack-svn mailing list