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... | |
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:
Definition at line 45 of file pearson_search.hpp.
|
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.
referenceSet | Set of reference points. |
Definition at line 57 of file pearson_search.hpp.
|
inline |
Given a set of query points, find the nearest k neighbors, and return similarities.
Similarities are non-negative and no larger than one.
query | A set of query points. |
k | Number of neighbors to search. |
neighbors | Nearest neighbors. |
similarities | Similarities between query point and its neighbors. |
Definition at line 78 of file pearson_search.hpp.