14 #ifndef MLPACK_METHODS_RANN_RA_MODEL_HPP 15 #define MLPACK_METHODS_RANN_RA_MODEL_HPP 47 virtual const arma::mat&
Dataset()
const = 0;
65 virtual double Alpha()
const = 0;
67 virtual double&
Alpha() = 0;
70 virtual double Tau()
const = 0;
72 virtual double&
Tau() = 0;
80 virtual bool Naive()
const = 0;
82 virtual bool&
Naive() = 0;
86 arma::mat&& referenceSet,
87 const size_t leafSize) = 0;
94 arma::Mat<size_t>& neighbors,
96 const size_t leafSize) = 0;
102 arma::Mat<size_t>& neighbors,
103 arma::mat& distances) = 0;
109 template<
template<
typename TreeMetricType,
110 typename TreeStatType,
111 typename TreeMatType>
class TreeType>
118 ra(singleMode, naive)
131 const arma::mat&
Dataset()
const {
return ra.ReferenceSet(); }
149 double Alpha()
const {
return ra.Alpha(); }
151 double&
Alpha() {
return ra.Alpha(); }
154 double Tau()
const {
return ra.Tau(); }
156 double&
Tau() {
return ra.Tau(); }
164 bool Naive()
const {
return ra.Naive(); }
166 bool&
Naive() {
return ra.Naive(); }
170 arma::mat&& referenceSet,
176 arma::mat&& querySet,
178 arma::Mat<size_t>& neighbors,
179 arma::mat& distances,
186 arma::Mat<size_t>& neighbors,
187 arma::mat& distances);
190 template<
typename Archive>
211 template<
template<
typename TreeMetricType,
212 typename TreeStatType,
213 typename TreeMatType>
class TreeType>
236 arma::mat&& referenceSet,
237 const size_t leafSize);
242 arma::mat&& querySet,
244 arma::Mat<size_t>& neighbors,
245 arma::mat& distances,
246 const size_t leafSize);
249 template<
typename Archive>
339 template<
typename Archive>
340 void serialize(Archive& ar,
const uint32_t );
356 double Tau()
const {
return raSearch->
Tau(); }
358 double&
Tau() {
return raSearch->
Tau(); }
397 void InitializeModel(
const bool naive,
const bool singleMode);
401 arma::mat&& referenceSet,
402 const size_t leafSize,
404 const bool singleMode);
409 arma::mat&& querySet,
411 arma::Mat<size_t>& neighbors,
412 arma::mat& distances);
420 arma::Mat<size_t>& neighbors,
421 arma::mat& distances);
424 std::string TreeName()
const;
430 #include "ra_model_impl.hpp" LeafSizeRAWrapper(const bool singleMode, const bool naive)
Construct the LeafSizeRAWrapper by delegating to the RAWrapper constructor.
TreeTypes TreeType() const
Get the type of tree being used.
size_t & SingleSampleLimit()
Modify the single sample limit.
virtual size_t SingleSampleLimit() const =0
Get the single sample limit.
double Alpha() const
Get the value of alpha.
size_t & SingleSampleLimit()
Modify the limit on the size of a node that can be approximation.
double & Tau()
Modify the value of tau.
virtual RAWrapperBase * Clone() const =0
Create a new RAWrapperBase that is the same as this one.
bool RandomBasis() const
Get whether or not a random basis is being used.
virtual bool Naive() const =0
Get whether naive search is being used.
bool & SampleAtLeaves()
Modify whether or not sampling is done at the leaves.
Linear algebra utility functions, generally performed on matrices or vectors.
virtual void Search(util::Timers &timers, arma::mat &&querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances, const size_t leafSize)=0
Perform bichromatic rank-approximate nearest neighbor search (i.e.
const arma::mat & Dataset() const
Expose the dataset.
size_t SingleSampleLimit() const
Get the single sample limit.
virtual bool SampleAtLeaves() const =0
Get whether to do sampling at leaves.
bool FirstLeafExact() const
Get whether to do exact search at the first leaf.
bool & Naive()
Modify whether naive search is being used.
virtual ~RAWrapperBase()
Destruct the RAWrapperBase (nothing to do).
virtual ~LeafSizeRAWrapper()
Delete the LeafSizeRAWrapper.
const arma::mat & Dataset() const
Get a reference to the reference set.
bool & SingleMode()
Modify whether or not single-tree search is being used.
virtual bool SingleMode() const =0
Get whether single-tree search is being used.
double Tau() const
Get the rank-approximation in percentile of the data.
RAWrapper(const bool singleMode, const bool naive)
Construct the RAWrapper object, initializing the internally-held RASearch object. ...
double Tau() const
Get the value of tau.
virtual void Train(util::Timers &timers, arma::mat &&referenceSet, const size_t leafSize)=0
Train the RASearch model with the given parameters.
size_t SingleSampleLimit() const
Get the limit on the size of a node that can be approximated.
bool & SingleMode()
Modify whether single-tree search is being used.
bool & RandomBasis()
Modify whether or not a random basis is being used.
bool SingleMode() const
Get whether single-tree search is being used.
double & Alpha()
Modify the desired success probability.
bool SampleAtLeaves() const
Get whether to do sampling at leaves.
bool FirstLeafExact() const
Get whether or not we traverse to the first leaf without approximation.
virtual ~RAWrapper()
Delete the RAWrapper object.
double & Alpha()
Modify the value of alpha.
NearestNS NearestNeighborSort
virtual bool FirstLeafExact() const =0
Get whether to do exact search at the first leaf.
void serialize(Archive &ar, const uint32_t)
Serialize the RASearch model.
virtual double Alpha() const =0
Get the value of alpha.
RAWrapperBase()
Create the RAWrapperBase object.
TreeTypes & TreeType()
Modify the type of tree being used.
virtual double Tau() const =0
Get the value of tau.
virtual const arma::mat & Dataset() const =0
Return a reference to the dataset.
LeafSizeRAWrapper wraps any RASearch type that needs to be able to take the leaf size into account wh...
virtual RAWrapper * Clone() const
Create a copy of this RAWrapper object.
RAType ra
The instantiated RASearch object that we are wrapping.
bool & FirstLeafExact()
Modify whether or not we traverse to the first leaf without approximation.
virtual LeafSizeRAWrapper * Clone() const
Return a copy of the LeafSizeRAWrapper.
bool SingleMode() const
Get whether or not single-tree search is being used.
double & Tau()
Modify the rank-approximation in percentile of the data.
The RASearch class: This class provides a generic manner to perform rank-approximate search via rando...
void serialize(Archive &ar, const uint32_t)
Serialize the RASearch model.
RAWrapper is a wrapper class for most RASearch types.
bool & FirstLeafExact()
Modify whether to do exact search at the first leaf.
bool & SampleAtLeaves()
Modify whether to do sampling at leaves.
RAWrapperBase is a base wrapper class for holding all RASearch types supported by RAModel...
RASearch< NearestNeighborSort, metric::EuclideanDistance, arma::mat, TreeType > RAType
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.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
bool SampleAtLeaves() const
Get whether or not sampling is done at the leaves.
bool Naive() const
Get whether naive search is being used.
bool Naive() const
Get whether or not naive search is being used.
The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType param...
double Alpha() const
Get the desired success probability.
size_t & LeafSize()
Modify the leaf size (only relevant when the kd-tree is used).
bool & Naive()
Modify whether or not naive search is being used.