25 #ifndef MLPACK_METHODS_RANN_RA_SEARCH_HPP 26 #define MLPACK_METHODS_RANN_RA_SEARCH_HPP 42 template<
template<
typename TreeMetricType,
43 typename TreeStatType,
44 typename TreeMatType>
class TreeType>
45 class LeafSizeRAWrapper;
71 template<
typename SortPolicy = NearestNeighborSort,
72 typename MetricType = metric::EuclideanDistance,
73 typename MatType = arma::mat,
74 template<
typename TreeMetricType,
75 typename TreeStatType,
81 typedef TreeType<MetricType, RAQueryStat<SortPolicy>, MatType>
Tree;
129 const bool naive =
false,
130 const bool singleMode =
false,
131 const double tau = 5,
132 const double alpha = 0.95,
133 const bool sampleAtLeaves =
false,
134 const bool firstLeafExact =
false,
135 const size_t singleSampleLimit = 20,
136 const MetricType metric = MetricType());
186 const bool singleMode =
false,
187 const double tau = 5,
188 const double alpha = 0.95,
189 const bool sampleAtLeaves =
false,
190 const bool firstLeafExact =
false,
191 const size_t singleSampleLimit = 20,
192 const MetricType metric = MetricType());
214 const bool singleMode =
false,
215 const double tau = 5,
216 const double alpha = 0.95,
217 const bool sampleAtLeaves =
false,
218 const bool firstLeafExact =
false,
219 const size_t singleSampleLimit = 20,
220 const MetricType metric = MetricType());
237 void Train(MatType referenceSet);
242 void Train(Tree* referenceTree);
260 void Search(
const MatType& querySet,
262 arma::Mat<size_t>& neighbors,
263 arma::mat& distances);
287 void Search(Tree* queryTree,
289 arma::Mat<size_t>& neighbors,
290 arma::mat& distances);
304 void Search(
const size_t k,
305 arma::Mat<size_t>& neighbors,
306 arma::mat& distances);
327 bool Naive()
const {
return naive; }
337 double Tau()
const {
return tau; }
339 double&
Tau() {
return tau; }
342 double Alpha()
const {
return alpha; }
362 template<
typename Archive>
363 void serialize(Archive& ar,
const uint32_t );
367 std::vector<size_t> oldFromNewReferences;
371 const MatType* referenceSet;
393 size_t singleSampleLimit;
TreeType< MetricType, RAQueryStat< SortPolicy >, MatType > Tree
Convenience typedef.
Definition: ra_search.hpp:81
BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
Definition: typedef.hpp:63
double Tau() const
Get the rank-approximation in percentile of the data.
Definition: ra_search.hpp:337
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
bool & SampleAtLeaves()
Modify whether or not sampling is done at the leaves.
Definition: ra_search.hpp:349
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.
Definition: ra_search.hpp:354
size_t & SingleSampleLimit()
Modify the limit on the size of a node that can be approximation.
Definition: ra_search.hpp:359
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
Definition: ra_search.hpp:357
bool & Naive()
Modify whether or not naive (brute-force) search is used.
Definition: ra_search.hpp:329
bool SingleMode() const
Get whether or not single-tree search is used.
Definition: ra_search.hpp:332
double Alpha() const
Get the desired success probability.
Definition: ra_search.hpp:342
void ResetQueryTree(Tree *queryTree) const
This function recursively resets the RAQueryStat of the given query tree to set 'bound' to SortPolicy...
Definition: ra_search_impl.hpp:590
bool Naive() const
Get whether or not naive (brute-force) search is used.
Definition: ra_search.hpp:327
const MatType & ReferenceSet() const
Access the reference set.
Definition: ra_search.hpp:324
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...
Definition: ra_search_impl.hpp:57
double & Tau()
Modify the rank-approximation in percentile of the data.
Definition: ra_search.hpp:339
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...
Definition: ra_search_impl.hpp:249
void serialize(Archive &ar, const uint32_t)
Serialize the object.
Definition: ra_search_impl.hpp:607
LeafSizeRAWrapper wraps any RASearch type that needs to be able to take the leaf size into account wh...
Definition: ra_model.hpp:208
~RASearch()
Delete the RASearch object.
Definition: ra_search_impl.hpp:163
void Train(MatType referenceSet)
"Train" the model on the given reference set.
Definition: ra_search_impl.hpp:178
bool & SingleMode()
Modify whether or not single-tree search is used.
Definition: ra_search.hpp:334
double & Alpha()
Modify the desired success probability.
Definition: ra_search.hpp:344
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
Definition: ra_search.hpp:352
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
Definition: ra_search.hpp:77
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
Definition: ra_search.hpp:347