23 #ifndef MLPACK_METHODS_RANN_RA_SEARCH_HPP 24 #define MLPACK_METHODS_RANN_RA_SEARCH_HPP 40 template<
typename SortPolicy>
65 template<
typename SortPolicy = NearestNeighborSort,
67 typename MatType = arma::mat,
68 template<
typename TreeMetricType,
69 typename TreeStatType,
75 typedef TreeType<MetricType, RAQueryStat<SortPolicy>, MatType>
Tree;
123 const bool naive =
false,
125 const double tau = 5,
126 const double alpha = 0.95,
130 const MetricType
metric = MetricType());
177 const bool naive =
false,
179 const double tau = 5,
180 const double alpha = 0.95,
184 const MetricType
metric = MetricType());
236 const double tau = 5,
237 const double alpha = 0.95,
241 const MetricType
metric = MetricType());
264 const double tau = 5,
265 const double alpha = 0.95,
269 const MetricType
metric = MetricType());
286 void Train(
const MatType& referenceSet);
297 void Train(MatType&& referenceSet);
315 void Search(
const MatType& querySet,
317 arma::Mat<size_t>& neighbors,
318 arma::mat& distances);
343 void Search(Tree* queryTree,
345 arma::Mat<size_t>& neighbors,
346 arma::mat& distances);
360 void Search(
const size_t k,
361 arma::Mat<size_t>& neighbors,
362 arma::mat& distances);
418 template<
typename Archive>
419 void Serialize(Archive& ar,
const unsigned int );
462 #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.
The core includes that mlpack expects; standard C++ includes and Armadillo.
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...
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).