14 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_RANDOMIZED_SVD_METHOD_HPP
15 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_RANDOMIZED_SVD_METHOD_HPP
53 const size_t maxIterations = 2) :
54 iteratedPower(iteratedPower),
55 maxIterations(maxIterations)
72 template<
typename MatType>
74 const arma::sp_mat& cleanedData,
76 const size_t maxIterations,
84 rsvd.
Apply(cleanedData, w, sigma, h, rank);
87 w = w * arma::diagmat(sigma);
99 double GetRating(
const size_t user,
const size_t item)
const
101 double rating = arma::as_scalar(w.row(item) * h.col(user));
113 rating = w * h.col(user);
128 template<
typename NeighborSearchPolicy>
130 const size_t numUsersForSimilarity,
131 arma::Mat<size_t>& neighborhood,
132 arma::mat& similarities)
const
141 arma::mat l = arma::chol(w.t() * w);
142 arma::mat stretchedH = l * h;
145 arma::mat query(stretchedH.n_rows, users.n_elem);
147 for (
size_t i = 0; i < users.n_elem; i++)
148 query.col(i) = stretchedH.col(users(i));
150 NeighborSearchPolicy neighborSearch(stretchedH);
151 neighborSearch.Search(
152 query, numUsersForSimilarity, neighborhood, similarities);
156 const arma::mat&
W()
const {
return w; }
158 const arma::mat&
H()
const {
return h; }
173 template<
typename Archive>
176 ar & BOOST_SERIALIZATION_NVP(w);
177 ar & BOOST_SERIALIZATION_NVP(h);
182 size_t iteratedPower;
184 size_t maxIterations;