18 #ifndef __MLPACK_METHODS_CF_CF_HPP 19 #define __MLPACK_METHODS_CF_CF_HPP 40 template<
typename FactorizerType>
89 CF(
const size_t numUsersForSimilarity = 5,
90 const size_t rank = 0);
108 template<
typename FactorizerType = amf::NMFALSFactorizer>
109 CF(
const arma::mat& data,
110 FactorizerType factorizer = FactorizerType(),
111 const size_t numUsersForSimilarity = 5,
112 const size_t rank = 0);
132 template<
typename FactorizerType = amf::NMFALSFactorizer>
133 CF(
const arma::sp_mat& data,
134 FactorizerType factorizer = FactorizerType(),
135 const size_t numUsersForSimilarity = 5,
136 const size_t rank = 0,
137 const typename boost::disable_if_c<
148 template<
typename FactorizerType = amf::NMFALSFactorizer>
149 void Train(
const arma::mat& data,
150 FactorizerType factorizer = FactorizerType());
160 template<
typename FactorizerType = amf::NMFALSFactorizer>
161 void Train(
const arma::sp_mat& data,
162 FactorizerType factorizer = FactorizerType(),
163 const typename boost::disable_if_c<
172 Log::Warn <<
"CF::NumUsersForSimilarity(): invalid value (< 1) " 173 "ignored." << std::endl;
176 this->numUsersForSimilarity = num;
182 return numUsersForSimilarity;
186 void Rank(
const size_t rankValue)
188 this->rank = rankValue;
198 const arma::mat&
W()
const {
return w; }
200 const arma::mat&
H()
const {
return h; }
210 void GetRecommendations(
const size_t numRecs,
211 arma::Mat<size_t>& recommendations);
220 void GetRecommendations(
const size_t numRecs,
221 arma::Mat<size_t>& recommendations,
222 arma::Col<size_t>& users);
225 static void CleanData(
const arma::mat& data, arma::sp_mat& cleanedData);
233 double Predict(
const size_t user,
const size_t item)
const;
247 void Predict(
const arma::Mat<size_t>& combinations,
248 arma::vec& predictions)
const;
253 template<
typename Archive>
254 void Serialize(Archive& ar,
const unsigned int );
277 void InsertNeighbor(
const size_t queryIndex,
279 const size_t neighbor,
281 arma::Mat<size_t>& recommendations,
282 arma::mat& values)
const;
290 #include "cf_impl.hpp" const arma::sp_mat & CleanedData() const
Get the cleaned data matrix.
arma::sp_mat cleanedData
Cleaned data matrix.
size_t NumUsersForSimilarity() const
Gets number of users for calculating similarity.
size_t rank
Rank used for matrix factorization.
size_t Rank() const
Gets rank parameter for matrix factorization.
const arma::mat & W() const
Get the User Matrix.
Linear algebra utility functions, generally performed on matrices or vectors.
static const bool UsesCoordinateList
If true, then the passed data matrix is used for factorizer.Apply().
void NumUsersForSimilarity(const size_t num)
Sets number of users for calculating similarity.
const arma::mat & H() const
Get the Item Matrix.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
size_t numUsersForSimilarity
Number of users for similarity.
Template class for factorizer traits.
static util::PrefixedOutStream Warn
Prints warning messages prefixed with [WARN ].
void Rank(const size_t rankValue)
Sets rank parameter for matrix factorization.
This class implements Collaborative Filtering (CF).