12 #ifndef MLPACK_METHODS_CF_SIMILARITY_INTERPOLATION_HPP 13 #define MLPACK_METHODS_CF_SIMILARITY_INTERPOLATION_HPP 65 template
(similarities.n_elem == 0)
<< "Require: similarities.n_elem > 0. There should be at "
<< "least one neighbor!"
(weights.n_elem != neighbors.n_elem)
<< "The size of the first parameter (weights) should "
<< "be set to the number of neighbors before calling GetWeights()."
similaritiesSum = arma::sum(similarities);
(std::fabs(similaritiesSum) < 1e-14)
weights.fill(1.0 / similarities.n_elem);
weights = similarities / similaritiesSum;
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.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes, Armadillo, cereal, and a few basic mlpa...
SimilarityInterpolation(const arma::sp_mat &)
This constructor is needed for interface consistency.
With SimilarityInterpolation, interpolation weights are based on similarities between query user and ...
static util::PrefixedOutStream Fatal