[mlpack-git] master, mlpack-1.0.x: Clean up implementation of GetRecommendations(). (ac7502e)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 21:46:00 EST 2015
Repository : https://github.com/mlpack/mlpack
On branches: master,mlpack-1.0.x
Link : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40
>---------------------------------------------------------------
commit ac7502e9eda8d3f6655eb585d6cea11208490bd3
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Apr 7 15:26:22 2014 +0000
Clean up implementation of GetRecommendations().
>---------------------------------------------------------------
ac7502e9eda8d3f6655eb585d6cea11208490bd3
src/mlpack/methods/cf/cf_impl.hpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/mlpack/methods/cf/cf_impl.hpp b/src/mlpack/methods/cf/cf_impl.hpp
index 5c29ab9..c2b6232 100644
--- a/src/mlpack/methods/cf/cf_impl.hpp
+++ b/src/mlpack/methods/cf/cf_impl.hpp
@@ -50,14 +50,14 @@ template<typename FactorizerType>
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;
-
- // Calling base function for recommendations.
+ // 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);
+
+ // Call the main overload for recommendations.
GetRecommendations(numRecs, recommendations, users);
}
More information about the mlpack-git
mailing list