[mlpack-svn] r15876 - 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:44:55 EDT 2013
Author: rcurtin
Date: Mon Sep 30 15:44:55 2013
New Revision: 15876
Log:
Remove CalculateApproximateRatings() since it is only ever called once.
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:44:55 2013
@@ -77,22 +77,6 @@
CleanData();
}
-void CF::CalculateApproximateRatings()
-{
- // 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.
- rating = w * h;
-}
-
void CF::GetRecommendations(arma::Mat<size_t>& recommendations)
{
// Used to save user IDs.
@@ -110,8 +94,21 @@
arma::Col<size_t>& users)
{
// Base function for calculating recommendations.
- // Operations independent of the query.
- CalculateApproximateRatings();
+
+ // Operations independent of the query:
+ // 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.
+ rating = w * h;
+
// Query-dependent operations.
Query(recommendations,users);
}
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:44:55 2013
@@ -192,8 +192,6 @@
arma::mat data;
//! Cleaned Data Matrix.
arma::sp_mat cleanedData;
- //!Calculates a rating matrix with available data and approximations
- void CalculateApproximateRatings();
//!Converts the User, Item, Value Matrix to User-Item Table
void CleanData();
More information about the mlpack-svn
mailing list