[mlpack-svn] r15879 - 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 18:24:44 EDT 2013


Author: rcurtin
Date: Mon Sep 30 18:24:43 2013
New Revision: 15879

Log:
Remove GetNeighbourhood() because it is only called once.  The check that
numUsersForSimilarity < numUsers is redundant because AllkNN will make that
check.


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 18:24:43 2013
@@ -174,8 +174,11 @@
   // Temporary storage for neighborhood of the queried users.
   arma::Mat<size_t> neighborhood;
 
-  // Calculates the neighborhood of the queried users.
-  GetNeighbourhood(query, neighborhood);
+  // Calculate the neighborhood of the queried users.
+  // This should be a templatized option.
+  AllkNN a(rating, query);
+  arma::mat resultingDistances; // Temporary storage.
+  a.Search(numUsersForSimilarity, neighborhood, resultingDistances);
 
   // Temporary storage for storing the average rating for each user in their
   // neighborhood.
@@ -188,28 +191,6 @@
   CalculateTopRecommendations(recommendations, averages, users);
 }
 
-void CF::GetNeighbourhood(arma::mat& query,
-                         arma::Mat<size_t>& neighbourhood)
-{
-  Log::Info<<"GetNeighbourhood"<<endl;
-  if(numUsersForSimilarity>rating.n_cols)
-  {
-    Log::Warn << "CF::GetNeighbourhood(arma::mat,armaMat<size_t>):"
-        <<"neighbourhood size should be > total number of users("
-        << rating.n_cols << " given). Setting value to number of users.\n";
-    NumUsersForSimilarity(rating.n_cols);
-  }
-  //Creating an Alknn object
-  //Should be moved to templates
-  AllkNN a(rating, query);
-  //Temproraily storing distance between neighbours
-  arma::mat resultingDistances;
-  //Building neighbourhood
-  a.Search(numUsersForSimilarity, neighbourhood,
-           resultingDistances);
-  //data::Save("neighbourhood.csv",neighbourhood);
-}
-
 void CF::CalculateAverage(arma::Mat<size_t>& neighbourhood,
                       arma::mat& averages) const
 {

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 18:24:43 2013
@@ -204,16 +204,6 @@
   void Query(arma::Mat<size_t>& recommendations,arma::Col<size_t>& users);
 
   /**
-   * Generates the neighbourhood of users.
-   *
-   * @param query Matrix to store the item preference of the user.
-   * @param modifiedRating Matrix to store the Modified Matix.
-   * @param neighbourhood Matrix to store user neighbourhood.
-   */
-  void GetNeighbourhood(arma::mat& query,
-                        arma::Mat<size_t>& neighbourhood);
-
-  /**
    * Calculates the Average rating users would have given to unrated items based
    * on their similarity with other users.
    *



More information about the mlpack-svn mailing list