14 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_SVD_INCOMPLETE_METHOD_HPP
15 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_SVD_INCOMPLETE_METHOD_HPP
59 template<
typename MatType>
61 const arma::sp_mat& cleanedData,
63 const size_t maxIterations,
64 const double minResidue,
75 svdici.Apply(cleanedData, rank, w, h);
85 svdici.
Apply(cleanedData, rank, w, h);
95 double GetRating(
const size_t user,
const size_t item)
const
97 double rating = arma::as_scalar(w.row(item) * h.col(user));
109 rating = w * h.col(user);
124 template<
typename NeighborSearchPolicy>
126 const size_t numUsersForSimilarity,
127 arma::Mat<size_t>& neighborhood,
128 arma::mat& similarities)
const
137 arma::mat l = arma::chol(w.t() * w);
138 arma::mat stretchedH = l * h;
141 arma::mat query(stretchedH.n_rows, users.n_elem);
143 for (
size_t i = 0; i < users.n_elem; i++)
144 query.col(i) = stretchedH.col(users(i));
146 NeighborSearchPolicy neighborSearch(stretchedH);
147 neighborSearch.Search(
148 query, numUsersForSimilarity, neighborhood, similarities);
152 const arma::mat&
W()
const {
return w; }
154 const arma::mat&
H()
const {
return h; }
159 template<
typename Archive>
162 ar & BOOST_SERIALIZATION_NVP(w);
163 ar & BOOST_SERIALIZATION_NVP(h);