25 #ifndef __MLPACK_METHODS_RANN_RA_SEARCH_HPP
26 #define __MLPACK_METHODS_RANN_RA_SEARCH_HPP
42 template<
typename SortPolicy>
67 template<
typename SortPolicy = NearestNeighborSort,
69 typename MatType = arma::mat,
70 template<
typename TreeMetricType,
71 typename TreeStatType,
77 typedef TreeType<MetricType, RAQueryStat<SortPolicy>, MatType>
Tree;
125 const bool naive =
false,
127 const double tau = 5,
128 const double alpha = 0.95,
132 const MetricType
metric = MetricType());
179 const bool naive =
false,
181 const double tau = 5,
182 const double alpha = 0.95,
186 const MetricType
metric = MetricType());
238 const double tau = 5,
239 const double alpha = 0.95,
243 const MetricType
metric = MetricType());
266 const double tau = 5,
267 const double alpha = 0.95,
271 const MetricType
metric = MetricType());
288 void Train(
const MatType& referenceSet);
299 void Train(MatType&& referenceSet);
317 void Search(
const MatType& querySet,
319 arma::Mat<size_t>& neighbors,
320 arma::mat& distances);
345 void Search(Tree* queryTree,
347 arma::Mat<size_t>& neighbors,
348 arma::mat& distances);
362 void Search(
const size_t k,
363 arma::Mat<size_t>& neighbors,
364 arma::mat& distances);
420 template<
typename Archive>
421 void Serialize(Archive& ar,
const unsigned int );
464 #include "ra_search_impl.hpp"
TreeType< MetricType, RAQueryStat< SortPolicy >, MatType > Tree
Convenience typedef.
BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
Linear algebra utility functions, generally performed on matrices or vectors.
bool singleMode
Indicates if single-tree search is being used (opposed to dual-tree).
bool & SampleAtLeaves()
Modify whether or not sampling is done at the leaves.
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
double Tau() const
Get the rank-approximation in percentile of the data.
bool SingleMode() const
Get whether or not single-tree search is used.
bool & FirstLeafExact()
Modify whether or not we traverse to the first leaf without approximation.
bool firstLeafExact
If true, we will traverse to the first leaf without approximation.
size_t & SingleSampleLimit()
Modify the limit on the size of a node that can be approximation.
size_t singleSampleLimit
The limit on the number of points in the largest node that can be approximated by sampling...
Tree * referenceTree
Pointer to the root of the reference tree.
bool & Naive()
Modify whether or not naive (brute-force) search is used.
void Train(const MatType &referenceSet)
"Train" the model on the given reference set.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
MetricType metric
Instantiation of kernel.
bool sampleAtLeaves
Whether or not sampling is done at the leaves. Faster, but less accurate.
const MatType & ReferenceSet() const
Access the reference set.
bool setOwner
If true, we are responsible for deleting the dataset.
bool naive
Indicates if naive random sampling on the set is being used.
double & Tau()
Modify the rank-approximation in percentile of the data.
void Search(const MatType &querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Compute the rank approximate nearest neighbors of each query point in the query set and store the out...
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
double alpha
The desired success probability (between 0 and 1).
const MatType * referenceSet
Reference dataset. In some situations we may own this dataset.
~RASearch()
Delete the RASearch object.
double Alpha() const
Get the desired success probability.
void Serialize(Archive &ar, const unsigned int)
Serialize the object.
bool & SingleMode()
Modify whether or not single-tree search is used.
std::vector< size_t > oldFromNewReferences
Permutations of reference points during tree building.
void ResetQueryTree(Tree *queryTree) const
This function recursively resets the RAQueryStat of the given query tree to set 'bound' to SortPolicy...
bool Naive() const
Get whether or not naive (brute-force) search is used.
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
RASearch(const MatType &referenceSet, const bool naive=false, const bool singleMode=false, const double tau=5, const double alpha=0.95, const bool sampleAtLeaves=false, const bool firstLeafExact=false, const size_t singleSampleLimit=20, const MetricType metric=MetricType())
Initialize the RASearch object, passing both a reference dataset (this is the dataset that will be se...
double & Alpha()
Modify the desired success probability.
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
bool treeOwner
If true, this object created the trees and is responsible for them.
The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType param...
double tau
The rank-approximation in percentile of the data (between 0 and 100).