14 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_SVD_COMPLETE_METHOD_HPP
15 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_SVD_COMPLETE_METHOD_HPP
59 template<
typename MatType>
61 const arma::sp_mat& cleanedData,
63 const size_t maxIterations,
64 const double minResidue,
76 svdci.Apply(cleanedData, rank, w, h);
86 svdci.
Apply(cleanedData, rank, w, h);
96 double GetRating(
const size_t user,
const size_t item)
const
98 double rating = arma::as_scalar(w.row(item) * h.col(user));
110 rating = w * h.col(user);
125 template<
typename NeighborSearchPolicy>
127 const size_t numUsersForSimilarity,
128 arma::Mat<size_t>& neighborhood,
129 arma::mat& similarities)
const
138 arma::mat l = arma::chol(w.t() * w);
139 arma::mat stretchedH = l * h;
142 arma::mat query(stretchedH.n_rows, users.n_elem);
144 for (
size_t i = 0; i < users.n_elem; i++)
145 query.col(i) = stretchedH.col(users(i));
147 NeighborSearchPolicy neighborSearch(stretchedH);
148 neighborSearch.Search(
149 query, numUsersForSimilarity, neighborhood, similarities);
153 const arma::mat&
W()
const {
return w; }
155 const arma::mat&
H()
const {
return h; }
160 template<
typename Archive>
163 ar & BOOST_SERIALIZATION_NVP(w);
164 ar & BOOST_SERIALIZATION_NVP(h);