Go to the documentation of this file.
14 #ifndef MLPACK_METHODS_RANN_RA_MODEL_HPP
15 #define MLPACK_METHODS_RANN_RA_MODEL_HPP
21 #include <boost/variant.hpp>
30 template<
typename SortPolicy,
31 template<
typename TreeMetricType,
32 typename TreeStatType,
33 typename TreeMatType>
class TreeType>
49 arma::Mat<size_t>& neighbors;
55 template<
typename RAType>
60 arma::Mat<size_t>& neighbors,
61 arma::mat& distances) :
74 template<
typename SortPolicy>
75 class BiSearchVisitor :
public boost::static_visitor<void>
79 const arma::mat& querySet;
83 arma::Mat<size_t>& neighbors;
87 const size_t leafSize;
90 template<
typename RAType>
91 void SearchLeaf(
RAType* ra)
const;
95 template<
template<
typename TreeMetricType,
96 typename TreeStatType,
97 typename TreeMatType>
class TreeType>
101 template<
template<
typename TreeMetricType,
102 typename TreeStatType,
103 typename TreeMatType>
class TreeType>
115 arma::Mat<size_t>& neighbors,
116 arma::mat& distances,
117 const size_t leafSize);
126 template<
typename SortPolicy>
131 arma::mat&& referenceSet;
136 template<
typename RAType>
137 void TrainLeaf(
RAType* ra)
const;
141 template<
template<
typename TreeMetricType,
142 typename TreeStatType,
143 typename TreeMatType>
class TreeType>
147 template<
template<
typename TreeMetricType,
148 typename TreeStatType,
149 typename TreeMatType>
class TreeType>
161 const size_t leafSize);
170 template<
typename RAType>
180 template<
typename RAType>
191 template<
typename RAType>
202 template<
typename RAType>
213 template<
typename RAType>
224 template<
typename RAType>
235 template<
typename RAType>
258 template<
typename RAType>
270 template<
typename SortPolicy>
304 boost::variant<RAType<SortPolicy, tree::KDTree>*,
354 template<
typename Archive>
413 const size_t leafSize,
415 const bool singleMode);
421 arma::Mat<size_t>& neighbors,
422 arma::mat& distances);
429 arma::Mat<size_t>& neighbors,
430 arma::mat& distances);
439 #include "ra_model_impl.hpp"
bool RandomBasis() const
Get whether or not a random basis is being used.
void operator()(RATypeT< tree::Octree > *ra) const
Bichromatic search on the given RAType specialized for octrees.
void operator()(RAType *ra) const
Delete the RAType Object.
bool & SampleAtLeaves()
Modify whether or not sampling is done at the leaves.
Exposes the FirstLeafExact() method of the given RAType.
double Tau() const
Get the rank-approximation in percentile of the data.
TrainVisitor sets the reference set to a new reference set on the given NSType.
const arma::mat & operator()(RAType *ra) const
Return the reference set.
bool Naive() const
Get whether or not naive search is being used.
void operator()(RATypeT< tree::KDTree > *ra) const
Bichromatic search on the given RAType specialized for KDTrees.
Exposes the SingleMode() method of the given RAType.
Exposes the Tau() method of the given RAType.
RAModel & operator=(RAModel &&other)
Take ownership of the given RAModel.
RAModel(const RAModel &other)
Copy the given RAModel.
void serialize(Archive &ar, const unsigned int)
Serialize the model.
const arma::mat & Dataset() const
Expose the dataset.
RAModel(RAModel &&other)
Take ownership of the given RAModel.
void Search(const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Perform rank-approximate neighbor search, using the reference set as the query set.
void operator()(RATypeT< tree::Octree > *ra) const
Train on the given RAType specialized for Octrees.
Exposes the Alpha() method of the given RAType.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
MonoSearchVisitor(const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Construct the MonoSearchVisitor object with the given parameters.
size_t & operator()(RAType *ra) const
void BuildModel(arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
Build the reference tree.
Linear algebra utility functions, generally performed on matrices or vectors.
void operator()(RATypeT< tree::KDTree > *ra) const
Train on the given RAType specialized for KDTrees.
TrainVisitor(arma::mat &&referenceSet, const size_t leafSize)
Construct the TrainVisitor object with the given reference set, leafSize for BinarySpaceTrees.
DeleteVisitor deletes the given NSType instance.
RAModel & operator=(const RAModel &other)
Copy the given RAModel.
double & operator()(RAType *ra) const
Return Alpha parameter.
bool & operator()(RAType *ra) const
Get a reference to the naive parameter of the given RASearch object.
bool & RandomBasis()
Modify whether or not a random basis is being used.
NaiveVisitor exposes the Naive() method of the given RAType.
RAModel(TreeTypes treeType=TreeTypes::KD_TREE, bool randomBasis=false)
Initialize the RAModel with the given type and whether or not a random basis should be used.
bool & SingleMode()
Modify whether or not single-tree search is being used.
bool & operator()(RAType *ra) const
double & Tau()
Modify the rank-approximation in percentile of the data.
ReferenceSetVisitor exposes the referenceSet of the given NSType.
BiSearchVisitor(const arma::mat &querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances, const size_t leafSize)
Construct the BiSearchVisitor.
double & Alpha()
Modify the desired success probability.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
double Alpha() const
Get the desired success probability.
size_t LeafSize() const
Get the leaf size (only relevant when the kd-tree is used).
bool & FirstLeafExact()
Modify whether or not we traverse to the first leaf without approximation.
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.
RASearch< SortPolicy, metric::EuclideanDistance, arma::mat, TreeType > RAType
Alias template for RASearch.
bool SingleMode() const
Get whether or not single-tree search is being used.
bool & operator()(RAType *) const
Return SampleAtLeaves (whether or not sampling is done at leaves).
TreeTypes TreeType() const
Get the type of tree being used.
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
size_t & LeafSize()
Modify the leaf size (only relevant when the kd-tree is used).
The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType param...
double & operator()(RAType *ra) const
Get a reference to the Tau parameter.
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
Exposes the SampleAtLeaves() method of the given RAType.
MonoSearchVisitor executes a monochromatic neighbor search on the given NSType.
TreeTypes
The list of tree types we can use with RASearch.
void operator()(RAType *ra) const
Perform monochromatic nearest neighbor search.
TreeTypes & TreeType()
Modify the type of tree being used.
std::string TreeName() const
Get the name of the tree type.
~RAModel()
Clean memory, if necessary.
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
bool & operator()(RAType *ra) const
Get a reference to the SingleMode parameter of the given RASearch object.
size_t & SingleSampleLimit()
Modify the limit on the size of a node that can be approximation.
Exposes the SingleSampleLimit() method of the given RAType.
bool & Naive()
Modify whether or not naive search is being used.