mlpack
Public Member Functions | List of all members
mlpack::cf::SimilarityInterpolation Class Reference

With SimilarityInterpolation, interpolation weights are based on similarities between query user and its neighbors. More...

#include <similarity_interpolation.hpp>

Public Member Functions

 SimilarityInterpolation (const arma::sp_mat &)
 This constructor is needed for interface consistency.
 
template<typename VectorType , typename DecompositionPolicy >
void GetWeights (VectorType &&weights, const DecompositionPolicy &, const size_t, const arma::Col< size_t > &neighbors, const arma::vec &similarities, const arma::sp_mat &)
 Interpolation weights are computed as normalized similarities. More...
 

Detailed Description

With SimilarityInterpolation, interpolation weights are based on similarities between query user and its neighbors.

All interpolation weights sum up to one.

An example of how to use SimilarityInterpolation in CF is shown below:

extern arma::mat data; // data is a (user, item, rating) table.
// Users for whom recommendations are generated.
extern arma::Col<size_t> users;
arma::Mat<size_t> recommendations; // Resulting recommendations.
CFType<> cf(data);
// Generate 10 recommendations for all users.
cf.template GetRecommendations<
EuclideanSearch,
SimilarityInterpolation>(10, recommendations);

Member Function Documentation

◆ GetWeights()

template<typename VectorType , typename DecompositionPolicy >
void mlpack::cf::SimilarityInterpolation::GetWeights ( VectorType &&  weights,
const DecompositionPolicy &  ,
const size_t  ,
const arma::Col< size_t > &  neighbors,
const arma::vec &  similarities,
const arma::sp_mat &   
)
inline

Interpolation weights are computed as normalized similarities.

After getting the weights, CF algorithm multiplies each neighbor's rating by its corresponding weight and sums them to get predicted rating.

Parameters
weightsResulting interpolation weights. The size of weights should be set to the number of neighbors before calling GetWeights().
*(decomposition) Decomposition object.
*(queryUser) Queried user.
neighborsNeighbors of queried user.
similaritiesSimilarities between query user and neighbors.
*(cleanedData) Sparse rating matrix.

The documentation for this class was generated from the following file: