15 #ifndef MLPACK_METHODS_NEIGHBOR_SEARCH_NS_MODEL_HPP
16 #define MLPACK_METHODS_NEIGHBOR_SEARCH_NS_MODEL_HPP
23 #include <boost/variant.hpp>
32 template<
typename SortPolicy,
33 template<
typename TreeMetricType,
34 typename TreeStatType,
35 typename TreeMatType>
class TreeType>
36 using
NSType = NeighborSearch<SortPolicy,
41 NeighborSearchStat<SortPolicy>,
42 arma::mat>::template DualTreeTraverser>;
54 arma::Mat<size_t>& neighbors;
60 template<
typename NSType>
65 arma::Mat<size_t>& neighbors,
66 arma::mat& distances) :
79 template<
typename SortPolicy>
84 const arma::mat& querySet;
88 arma::Mat<size_t>& neighbors;
92 const size_t leafSize;
99 template<
typename NSType>
100 void SearchLeaf(
NSType* ns)
const;
104 template<
template<
typename TreeMetricType,
105 typename TreeStatType,
106 typename TreeMatType>
class TreeType>
110 template<
template<
typename TreeMetricType,
111 typename TreeStatType,
112 typename TreeMatType>
class TreeType>
113 void operator()(
NSTypeT<TreeType>* ns)
const;
130 arma::Mat<size_t>& neighbors,
131 arma::mat& distances,
132 const size_t leafSize,
143 template<
typename SortPolicy>
148 arma::mat&& referenceSet;
157 template<
typename NSType>
158 void TrainLeaf(
NSType* ns)
const;
162 template<
template<
typename TreeMetricType,
163 typename TreeStatType,
164 typename TreeMatType>
class TreeType>
168 template<
template<
typename TreeMetricType,
169 typename TreeStatType,
170 typename TreeMatType>
class TreeType>
171 void operator()(
NSTypeT<TreeType>* ns)
const;
188 const size_t leafSize,
200 template<
typename NSType>
211 template<
typename NSType>
222 template<
typename NSType>
233 template<
typename NSType>
247 template<
typename SortPolicy>
293 boost::variant<NSType<SortPolicy, tree::KDTree>*,
352 template<
typename Archive>
353 void serialize(Archive& ar,
const unsigned int );
356 const arma::mat&
Dataset()
const;
371 double Tau()
const {
return tau; }
372 double&
Tau() {
return tau; }
375 double Rho()
const {
return rho; }
376 double&
Rho() {
return rho; }
388 const size_t leafSize,
390 const double epsilon = 0);
393 void Search(arma::mat&& querySet,
395 arma::Mat<size_t>& neighbors,
396 arma::mat& distances);
399 void Search(
const size_t k,
400 arma::Mat<size_t>& neighbors,
401 arma::mat& distances);
415 #include "ns_model_impl.hpp"
TreeTypes TreeType() const
Expose treeType.
double Epsilon() const
Expose Epsilon.
#define BOOST_TEMPLATE_CLASS_VERSION(SIGNATURE, T, N)
Use this like BOOST_CLASS_VERSION(), but for templated classes.
MonoSearchVisitor(const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Construct the MonoSearchVisitor object with the given parameters.
EpsilonVisitor exposes the Epsilon method of the given NSType.
std::string TreeName() const
Return a string representation of the current tree type.
TrainVisitor(arma::mat &&referenceSet, const size_t leafSize, const double tau, const double rho)
Construct the TrainVisitor object with the given reference set, leafSize for BinarySpaceTrees, and tau and rho for spill trees.
NeighborSearchMode & operator()(NSType *ns) const
Return the search mode.
void operator()(NSType *ns) const
Delete the NSType object.
TreeTypes
Enum type to identify each accepted tree type.
ReferenceSetVisitor exposes the referenceSet of the given NSType.
SearchModeVisitor exposes the SearchMode() method of the given NSType.
The NeighborSearch class is a template class for performing distance-based neighbor searches...
void operator()(NSTypeT< TreeType > *ns) const
Default Train on the given NSType instance.
double Rho() const
Expose rho.
NeighborSearchMode SearchMode() const
Expose SearchMode.
NeighborSearch< SortPolicy, metric::EuclideanDistance, arma::mat, TreeType, TreeType< metric::EuclideanDistance, NeighborSearchStat< SortPolicy >, arma::mat >::template DualTreeTraverser > NSType
Alias template for euclidean neighbor search.
void operator()(NSType *ns) const
Perform monochromatic nearest neighbor search.
void serialize(Archive &ar, const unsigned int)
Serialize the neighbor search model.
~NSModel()
Clean memory, if necessary.
BiSearchVisitor executes a bichromatic neighbor search on the given NSType.
NSModel & operator=(const NSModel &other)
Copy the given NSModel.
const arma::mat & operator()(NSType *ns) const
Return the reference set.
double & operator()(NSType *ns) const
Return epsilon, the approximation parameter.
The NSModel class provides an easy way to serialize a model, abstracts away the different types of tr...
NSModel(TreeTypes treeType=TreeTypes::KD_TREE, bool randomBasis=false)
Initialize the NSModel with the given type and whether or not a random basis should be used...
double Tau() const
Expose tau.
TrainVisitor sets the reference set to a new reference set on the given NSType.
void operator()(NSTypeT< TreeType > *ns) const
Default Bichromatic neighbor search on the given NSType instance.
void Search(arma::mat &&querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Perform neighbor search. The query set will be reordered.
BiSearchVisitor(const arma::mat &querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances, const size_t leafSize, const double tau, const double rho)
Construct the BiSearchVisitor.
MonoSearchVisitor executes a monochromatic neighbor search on the given NSType.
void BuildModel(arma::mat &&referenceSet, const size_t leafSize, const NeighborSearchMode searchMode, const double epsilon=0)
Build the reference tree.
size_t LeafSize() const
Expose leafSize.
DeleteVisitor deletes the given NSType instance.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
NeighborSearchMode
NeighborSearchMode represents the different neighbor search modes available.
const arma::mat & Dataset() const
Expose the dataset.
src mlpack core util version hpp VERSION_HPP_CONTENTS string(REGEX REPLACE".*#define MLPACK_VERSION_MAJOR ([0-9]+).*""\\1"MLPACK_VERSION_MAJOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* MLPACK_VERSION_MINOR "$
bool RandomBasis() const
Expose randomBasis.