PearsonSearch Class Reference

Nearest neighbor search with pearson distance (or furthest neighbor search with pearson correlation). More...

Public Member Functions

 PearsonSearch (const arma::mat &referenceSet)
 Constructor with reference set. More...

 
void Search (const arma::mat &query, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &similarities)
 Given a set of query points, find the nearest k neighbors, and return similarities. More...

 

Detailed Description

Nearest neighbor search with pearson distance (or furthest neighbor search with pearson correlation).

Note that, with normalized vectors, neighbor search with pearson distance is equivalent to neighbor search with Euclidean distance. Therefore, instead of performing neighbor search directly with pearson distance, we first normalize all vectors, and then use neighbor::KNN (i.e. NeighborSearch with Euclidean distance, KDTree). Pearson correlation are calculated from Euclidean distance.

An example of how to use PearsonSearch 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<PearsonSearch>(10, recommendations);

Definition at line 45 of file pearson_search.hpp.

Constructor & Destructor Documentation

◆ PearsonSearch()

PearsonSearch ( const arma::mat &  referenceSet)
inline

Constructor with reference set.

In order to use neighbor::KNN(i.e. NeighborSearch with Euclidean distance, KDTree), we need to normalize all vectors in referenceSet. For each vector x, we first subtract mean(x) from each element in x. Then, we normalize the vector to unit length.

Parameters
referenceSetSet of reference points.

Definition at line 57 of file pearson_search.hpp.

References core::v2::move(), core::v2::size(), and NeighborSearch< SortPolicy, MetricType, MatType, TreeType, DualTreeTraversalType, SingleTreeTraversalType >::Train().

Member Function Documentation

◆ Search()

void Search ( const arma::mat &  query,
const size_t  k,
arma::Mat< size_t > &  neighbors,
arma::mat &  similarities 
)
inline

Given a set of query points, find the nearest k neighbors, and return similarities.

Similarities are non-negative and no larger than one.

Parameters
queryA set of query points.
kNumber of neighbors to search.
neighborsNearest neighbors.
similaritiesSimilarities between query point and its neighbors.

Definition at line 78 of file pearson_search.hpp.

References NeighborSearch< SortPolicy, MetricType, MatType, TreeType, DualTreeTraversalType, SingleTreeTraversalType >::Search().


The documentation for this class was generated from the following file:
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-git/src/mlpack/methods/cf/neighbor_search_policies/pearson_search.hpp