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>
223 const arma::mat&
operator()(NSType *ns)
const;
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;
363 double Epsilon()
const;
371 double Tau()
const {
return tau; }
372 double&
Tau() {
return tau; }
375 double Rho()
const {
return rho; }
376 double&
Rho() {
return rho; }
387 void BuildModel(arma::mat&& referenceSet,
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);
404 std::string TreeName()
const;
415 #include "ns_model_impl.hpp"
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.
bool RandomBasis() const
Expose randomBasis.
TreeTypes
Enum type to identify each accepted tree type.
BOOST_TEMPLATE_CLASS_VERSION(template< typename SortPolicy >, mlpack::neighbor::NSModel< SortPolicy >, 1)
Set the serialization version of the NSModel class.
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...
TreeTypes TreeType() const
Expose treeType.
NeighborSearch< SortPolicy, metric::EuclideanDistance, arma::mat, TreeType, TreeType< metric::EuclideanDistance, NeighborSearchStat< SortPolicy >, arma::mat >::template DualTreeTraverser > NSType
Alias template for euclidean neighbor search.
size_t LeafSize() const
Expose leafSize.
BiSearchVisitor executes a bichromatic neighbor search on the given NSType.
The NSModel class provides an easy way to serialize a model, abstracts away the different types of tr...
double Tau() const
Expose tau.
TrainVisitor sets the reference set to a new reference set on the given NSType.
void operator()(NSType *ns) const
Perform monochromatic nearest neighbor search.
MonoSearchVisitor executes a monochromatic neighbor search on the given NSType.
DeleteVisitor deletes the given NSType instance.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
double Rho() const
Expose rho.
NeighborSearchMode
NeighborSearchMode represents the different neighbor search modes available.