23 #ifndef MLPACK_METHODS_RANN_RA_SEARCH_HPP
24 #define MLPACK_METHODS_RANN_RA_SEARCH_HPP
40 template<
typename SortPolicy>
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,
124 const bool singleMode =
false,
125 const double tau = 5,
126 const double alpha = 0.95,
127 const bool sampleAtLeaves =
false,
128 const bool firstLeafExact =
false,
129 const size_t singleSampleLimit = 20,
130 const MetricType metric = MetricType());
181 const bool singleMode =
false,
182 const double tau = 5,
183 const double alpha = 0.95,
184 const bool sampleAtLeaves =
false,
185 const bool firstLeafExact =
false,
186 const size_t singleSampleLimit = 20,
187 const MetricType metric = MetricType());
209 const bool singleMode =
false,
210 const double tau = 5,
211 const double alpha = 0.95,
212 const bool sampleAtLeaves =
false,
213 const bool firstLeafExact =
false,
214 const size_t singleSampleLimit = 20,
215 const MetricType metric = MetricType());
232 void Train(MatType referenceSet);
255 void Search(
const MatType& querySet,
257 arma::Mat<size_t>& neighbors,
258 arma::mat& distances);
285 arma::Mat<size_t>& neighbors,
286 arma::mat& distances);
300 void Search(
const size_t k,
301 arma::Mat<size_t>& neighbors,
302 arma::mat& distances);
323 bool Naive()
const {
return naive; }
333 double Tau()
const {
return tau; }
335 double&
Tau() {
return tau; }
338 double Alpha()
const {
return alpha; }
358 template<
typename Archive>
359 void serialize(Archive& ar,
const unsigned int );
363 std::vector<size_t> oldFromNewReferences;
367 const MatType* referenceSet;
389 size_t singleSampleLimit;
395 template<
typename SortPol>
403 #include "ra_search_impl.hpp"
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...
bool Naive() const
Get whether or not naive (brute-force) search is used.
void Train(MatType referenceSet)
"Train" the model on the given reference set.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Alpha() const
Get the desired success probability.
bool & SingleMode()
Modify whether or not single-tree search is used.
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
void serialize(Archive &ar, const unsigned int)
Serialize the object.
size_t & SingleSampleLimit()
Modify the limit on the size of a node that can be approximation.
double & Tau()
Modify the rank-approximation in percentile of the data.
NearestNS NearestNeighborSort
TreeType< MetricType, RAQueryStat< SortPolicy >, MatType > Tree
Convenience typedef.
TrainVisitor sets the reference set to a new reference set on the given NSType.
bool SingleMode() const
Get whether or not single-tree search is used.
bool & Naive()
Modify whether or not naive (brute-force) search is used.
const MatType & ReferenceSet() const
Access the reference set.
bool & FirstLeafExact()
Modify whether or not we traverse to the first leaf without approximation.
void ResetQueryTree(Tree *queryTree) const
This function recursively resets the RAQueryStat of the given query tree to set 'bound' to SortPolicy...
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
double Tau() const
Get the rank-approximation in percentile of the data.
bool & SampleAtLeaves()
Modify whether or not sampling is done at the leaves.
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...
BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
~RASearch()
Delete the RASearch object.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
double & Alpha()
Modify the desired success probability.