Go to the documentation of this file.
25 #ifndef MLPACK_METHODS_RANN_RA_SEARCH_HPP
26 #define MLPACK_METHODS_RANN_RA_SEARCH_HPP
42 template<
typename SortPolicy>
71 typename MatType = arma::mat,
72 template<
typename TreeMetricType,
73 typename TreeStatType,
79 typedef TreeType<MetricType, RAQueryStat<SortPolicy>, MatType>
Tree;
127 const bool naive =
false,
128 const bool singleMode =
false,
129 const double tau = 5,
130 const double alpha = 0.95,
131 const bool sampleAtLeaves =
false,
132 const bool firstLeafExact =
false,
133 const size_t singleSampleLimit = 20,
134 const MetricType metric = MetricType());
184 const bool singleMode =
false,
185 const double tau = 5,
186 const double alpha = 0.95,
187 const bool sampleAtLeaves =
false,
188 const bool firstLeafExact =
false,
189 const size_t singleSampleLimit = 20,
190 const MetricType metric = MetricType());
212 const bool singleMode =
false,
213 const double tau = 5,
214 const double alpha = 0.95,
215 const bool sampleAtLeaves =
false,
216 const bool firstLeafExact =
false,
217 const size_t singleSampleLimit = 20,
218 const MetricType metric = MetricType());
260 arma::Mat<size_t>& neighbors,
261 arma::mat& distances);
287 arma::Mat<size_t>& neighbors,
288 arma::mat& distances);
303 arma::Mat<size_t>& neighbors,
304 arma::mat& distances);
325 bool Naive()
const {
return naive; }
335 double Tau()
const {
return tau; }
337 double&
Tau() {
return tau; }
340 double Alpha()
const {
return alpha; }
360 template<
typename Archive>
365 std::vector<size_t> oldFromNewReferences;
369 const MatType* referenceSet;
391 size_t singleSampleLimit;
397 template<
typename SortPol>
405 #include "ra_search_impl.hpp"
double & Alpha()
Modify the desired success probability.
TrainVisitor sets the reference set to a new reference set on the given NSType.
The core includes that mlpack expects; standard C++ includes and Armadillo.
bool & Naive()
Modify whether or not naive (brute-force) search is used.
double Tau() const
Get the rank-approximation in percentile of the data.
double & Tau()
Modify the rank-approximation in percentile of the data.
~RASearch()
Delete the RASearch object.
BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
RASearch(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())
Create an RASearch object with no reference data.
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
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.
const MatType & ReferenceSet() const
Access the reference set.
Linear algebra utility functions, generally performed on matrices or vectors.
RASearch(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...
void Search(const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Compute the rank approximate nearest neighbors of each point in the reference set (that is,...
bool & FirstLeafExact()
Modify whether or not we traverse to the first leaf without approximation.
void Train(Tree *referenceTree)
Set the reference tree to a new reference tree.
NearestNS NearestNeighborSort
void Search(Tree *queryTree, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Compute the rank approximate nearest neighbors of each point in the pre-built query tree and store th...
void serialize(Archive &ar, const unsigned int)
Serialize the object.
double Alpha() const
Get the desired success probability.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
RASearch(Tree *referenceTree, 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 with the given pre-constructed reference tree.
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...
size_t & SingleSampleLimit()
Modify the limit on the size of a node that can be approximation.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
bool & SampleAtLeaves()
Modify whether or not sampling is done at the leaves.
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
TreeType< MetricType, RAQueryStat< SortPolicy >, MatType > Tree
Convenience typedef.
void Train(MatType referenceSet)
"Train" the model on the given reference set.
bool & SingleMode()
Modify whether or not single-tree search is used.
void ResetQueryTree(Tree *queryTree) const
This function recursively resets the RAQueryStat of the given query tree to set 'bound' to SortPolicy...
bool SingleMode() const
Get whether or not single-tree search is used.