12 #ifndef MLPACK_METHODS_CF_PEARSON_SEARCH_HPP 13 #define MLPACK_METHODS_CF_PEARSON_SEARCH_HPP 62 arma::mat normalizedSet(arma::size(referenceSet));
63 normalizedSet = arma::normalise(
64 referenceSet.each_row() - arma::mean(referenceSet));
66 neighborSearch.
Train(std::move(normalizedSet));
78 void Search(
const arma::mat& query,
const size_t k,
79 arma::Mat<size_t>& neighbors, arma::mat& similarities)
84 arma::mat normalizedQuery;
85 normalizedQuery = arma::normalise(query.each_row() - arma::mean(query));
87 neighborSearch.
Search(normalizedQuery, k, neighbors, similarities);
95 similarities = 1 - arma::pow(similarities, 2) / 4.0;
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
The NeighborSearch class is a template class for performing distance-based neighbor searches...
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.
PearsonSearch(const arma::mat &referenceSet)
Constructor with reference set.
Nearest neighbor search with pearson distance (or furthest neighbor search with pearson correlation)...
void Search(const MatType &querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
For each point in the query set, compute the nearest neighbors and store the output in the given matr...
void Train(MatType referenceSet)
Set the reference set to a new reference set, and build a tree if necessary.