16 #ifndef __MLPACK_METHODS_RANN_RA_MODEL_HPP
17 #define __MLPACK_METHODS_RANN_RA_MODEL_HPP
36 template<
typename SortPolicy>
64 template<
template<
typename TreeMetricType,
65 typename TreeStatType,
66 typename TreeMatType>
class TreeType>
86 RAModel(
int treeType = TreeTypes::KD_TREE,
bool randomBasis =
false);
92 template<
typename Archive>
93 void Serialize(Archive& ar,
const unsigned int );
96 const arma::mat&
Dataset()
const;
114 double Alpha()
const;
151 const size_t leafSize,
153 const bool singleMode);
157 void Search(arma::mat&& querySet,
159 arma::Mat<size_t>& neighbors,
160 arma::mat& distances);
166 void Search(
const size_t k,
167 arma::Mat<size_t>& neighbors,
168 arma::mat& distances);
177 #include "ra_model_impl.hpp"
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
void Serialize(Archive &ar, const unsigned int)
Serialize the model.
double Tau() const
Get the rank-approximation in percentile of the data.
Linear algebra utility functions, generally performed on matrices or vectors.
int treeType
The type of tree being used.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
RAType< tree::RStarTree > * rStarTreeRA
Non-NULL if the R* tree is used.
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
void BuildModel(arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
Build the reference tree.
~RAModel()
Clean memory, if necessary.
bool Naive() const
Get whether or not naive search is being used.
std::string TreeName() const
Get the name of the tree type.
bool RandomBasis() const
Get whether or not a random basis is being used.
bool SingleMode() const
Get whether or not single-tree search is being used.
void Search(arma::mat &&querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Perform rank-approximate neighbor search, taking ownership of the query set.
arma::mat q
The basis to project into.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
RAType< tree::RTree > * rTreeRA
Non-NULL if the R tree is used.
const arma::mat & Dataset() const
Expose the dataset.
bool randomBasis
If true, randomly project into a new basis.
RAModel(int treeType=TreeTypes::KD_TREE, bool randomBasis=false)
Initialize the RAModel with the given type and whether or not a random basis should be used...
size_t LeafSize() const
Get the leaf size (only relevant when the kd-tree is used).
TreeTypes
The list of tree types we can use with RASearch.
double Alpha() const
Get the desired success probability.
RAType< tree::StandardCoverTree > * coverTreeRA
Non-NULL if the cover tree is used.
RAType< tree::KDTree > * kdTreeRA
Non-NULL if the kd-tree is used.
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
size_t leafSize
The leaf size of the tree being used (useful only for the kd-tree).
The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType param...
int TreeType() const
Get the type of tree being used.