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

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Apr 7 11:26:22 EDT 2014


Author: rcurtin
Date: Mon Apr  7 11:26:22 2014
New Revision: 16405

Log:
Clean up implementation of GetRecommendations().


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

Modified: mlpack/trunk/src/mlpack/methods/cf/cf_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/cf/cf_impl.hpp	(original)
+++ mlpack/trunk/src/mlpack/methods/cf/cf_impl.hpp	Mon Apr  7 11:26:22 2014
@@ -50,14 +50,14 @@
 void CF<FactorizerType>::GetRecommendations(const size_t numRecs,
                                             arma::Mat<size_t>& recommendations)
 {
-  // Used to save user IDs.
-  arma::Col<size_t> users =
-    arma::zeros<arma::Col<size_t> >(cleanedData.n_cols, 1);
-  // Getting all user IDs.
-  for (size_t i = 0; i < cleanedData.n_cols; i++)
-    users(i) = i;
+  // Generate list of users.  Maybe it would be more efficient to pass an empty
+  // users list, and then have the other overload of GetRecommendations() assume
+  // that if users is empty, then recommendations should be generated for all
+  // users?
+  arma::Col<size_t> users = arma::linspace<arma::Col<size_t> >(0,
+      cleanedData.n_cols - 1, cleanedData.n_cols);
 
-  // Calling base function for recommendations.
+  // Call the main overload for recommendations.
   GetRecommendations(numRecs, recommendations, users);
 }
 



More information about the mlpack-svn mailing list