LMetricSearch< TPower > Class Template Reference

Nearest neighbor search with L_p distance. More...

Public Types

using NeighborSearchType = neighbor::NeighborSearch< neighbor::NearestNeighborSort, metric::LMetric< TPower, true > >
 

Public Member Functions

 LMetricSearch (const arma::mat &referenceSet)
 
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 similarites. More...

 

Detailed Description


template<int TPower>
class mlpack::cf::LMetricSearch< TPower >

Nearest neighbor search with L_p distance.

An example of how to use LMetricSearch 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<LMetricSearch<2>>(10, recommendations);
Template Parameters
TPowerPower of metric.

Definition at line 42 of file lmetric_search.hpp.

Member Typedef Documentation

◆ NeighborSearchType

Constructor & Destructor Documentation

◆ LMetricSearch()

LMetricSearch ( const arma::mat &  referenceSet)
inline
Parameters
referenceSetSet of reference points.

Definition at line 52 of file lmetric_search.hpp.

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 similarites.

Similarities are non-negative and no larger thant one.

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

Definition at line 64 of file lmetric_search.hpp.

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


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