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>
Implementation of the SVD incomplete incremental to act as a wrapper when accessing SVD incomplete in...
This class implements AMF (alternating matrix factorization) on the given matrix V.
This class computes SVD using incomplete incremental batch learning, as described in the following pa...
This initialization rule for AMF simply fills the W and H matrices with uniform random noise in [0...
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
This class implements a simple residue-based termination policy.
void serialize(Archive &ar, const uint32_t)
Serialization.
const arma::mat & H() const
Get the User Matrix.
void GetRatingOfUser(const size_t user, arma::vec &rating) const
Get predicted ratings for a user.
double Apply(const MatType &V, const size_t r, arma::mat &W, arma::mat &H)
Apply Alternating Matrix Factorization to the provided matrix.
double GetRating(const size_t user, const size_t item) const
Return predicted rating given user ID and item ID.
const arma::mat & W() const
Get the Item Matrix.
This termination policy only terminates when the maximum number of iterations has been reached...
void GetNeighborhood(const arma::Col< size_t > &users, const size_t numUsersForSimilarity, arma::Mat< size_t > &neighborhood, arma::mat &similarities) const
Get the neighborhood and corresponding similarities for a set of users.
void Apply(const MatType &, const arma::sp_mat &cleanedData, const size_t rank, const size_t maxIterations, const double minResidue, const bool mit)
Apply Collaborative Filtering to the provided data set using the SVD incomplete incremental method...