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>;
44 template<
typename SortPolicy>
78 template<
typename NSType>
79 void operator()(NSType* ns)
const;
83 arma::Mat<size_t>& neighbors,
84 arma::mat& distances) :
97 template<
typename SortPolicy>
117 template<
typename NSType>
118 void SearchLeaf(NSType* ns)
const;
122 template<
template<
typename TreeMetricType,
123 typename TreeStatType,
124 typename TreeMatType>
class TreeType>
128 template<
template<
typename TreeMetricType,
129 typename TreeStatType,
130 typename TreeMatType>
class TreeType>
131 void operator()(NSTypeT<TreeType>* ns)
const;
140 void operator()(
SpillKNN* ns)
const;
148 arma::Mat<size_t>& neighbors,
149 arma::mat& distances,
150 const size_t leafSize,
161 template<
typename SortPolicy>
175 template<
typename NSType>
176 void TrainLeaf(NSType* ns)
const;
180 template<
template<
typename TreeMetricType,
181 typename TreeStatType,
182 typename TreeMatType>
class TreeType>
186 template<
template<
typename TreeMetricType,
187 typename TreeStatType,
188 typename TreeMatType>
class TreeType>
189 void operator()(NSTypeT<TreeType>* ns)
const;
198 void operator()(
SpillKNN* ns)
const;
206 const size_t leafSize,
218 template<
typename NSType>
229 template<
typename NSType>
230 double& operator()(NSType *ns)
const;
240 template<
typename NSType>
241 const arma::mat& operator()(NSType *ns)
const;
251 template<
typename NSType>
252 void operator()(NSType *ns)
const;
265 template<
typename SortPolicy>
311 boost::variant<NSType<SortPolicy, tree::KDTree>*,
370 template<
typename Archive>
371 void Serialize(Archive& ar,
const unsigned int );
374 const arma::mat& Dataset()
const;
381 double Epsilon()
const;
389 double Tau()
const {
return tau; }
390 double&
Tau() {
return tau; }
393 double Rho()
const {
return rho; }
394 double&
Rho() {
return rho; }
405 void BuildModel(arma::mat&& referenceSet,
406 const size_t leafSize,
408 const double epsilon = 0);
411 void Search(arma::mat&& querySet,
413 arma::Mat<size_t>& neighbors,
414 arma::mat& distances);
417 void Search(
const size_t k,
418 arma::Mat<size_t>& neighbors,
419 arma::mat& distances);
433 #include "ns_model_impl.hpp"
static const std::string Name()
NeighborSearch< SortPolicy, metric::EuclideanDistance, arma::mat, TreeType, TreeType< metric::EuclideanDistance, NeighborSearchStat< SortPolicy >, arma::mat >::template DualTreeTraverser > NSType
Alias template for euclidean neighbor search.
EpsilonVisitor exposes the Epsilon method of the given NSType.
arma::mat && referenceSet
The reference set to use for training.
NeighborSearchMode
NeighborSearchMode represents the different neighbor search modes available.
Linear algebra utility functions, generally performed on matrices or vectors.
double Rho() const
Expose rho.
const double rho
Balance threshold (for spill trees).
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
const size_t k
Number of neighbors to search for.
arma::mat q
This is the random projection matrix; only used if randomBasis is true.
BOOST_TEMPLATE_CLASS_VERSION(template< typename SortPolicy >, mlpack::neighbor::NSModel< SortPolicy >, 1)
Set the serialization version of the NSModel class.
TreeTypes
Enum type to identify each accepted tree type.
const size_t leafSize
The number of points in a leaf (for BinarySpaceTrees).
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...
arma::Mat< size_t > & neighbors
Result matrix for neighbors.
arma::mat & distances
Result matrix for distances.
const size_t k
The number of neighbors to search for.
static const std::string Name()
MonoSearchVisitor(const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Construct the MonoSearchVisitor object with the given parameters.
size_t leafSize
The leaf size, used only by BinarySpaceTree.
const double tau
Overlapping size (for spill trees).
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSear...
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSear...
BiSearchVisitor executes a bichromatic neighbor search on the given NSType.
size_t leafSize
For tree types that accept the maxLeafSize parameter.
arma::Mat< size_t > & neighbors
The result matrix for neighbors.
double tau
Overlapping size (for spill trees).
The NSModel class provides an easy way to serialize a model, abstracts away the different types of tr...
bool RandomBasis() const
Expose randomBasis.
TrainVisitor sets the reference set to a new reference set on the given NSType.
const double tau
Overlapping size (for spill trees).
const double rho
Balance threshold (for spill trees).
const arma::mat & querySet
The query set for the bichromatic search.
boost::variant< NSType< SortPolicy, tree::KDTree > *, NSType< SortPolicy, tree::StandardCoverTree > *, NSType< SortPolicy, tree::RTree > *, NSType< SortPolicy, tree::RStarTree > *, NSType< SortPolicy, tree::BallTree > *, NSType< SortPolicy, tree::XTree > *, NSType< SortPolicy, tree::HilbertRTree > *, NSType< SortPolicy, tree::RPlusTree > *, NSType< SortPolicy, tree::RPlusPlusTree > *, NSType< SortPolicy, tree::VPTree > *, NSType< SortPolicy, tree::RPTree > *, NSType< SortPolicy, tree::MaxRPTree > *, SpillKNN *, NSType< SortPolicy, tree::UBTree > *, NSType< SortPolicy, tree::Octree > * > nSearch
nSearch holds an instance of the NeigborSearch class for the current treeType.
size_t LeafSize() const
Expose leafSize.
TreeTypes TreeType() const
Expose treeType.
double Tau() const
Expose tau.
MonoSearchVisitor executes a monochromatic neighbor search on the given NSType.
arma::mat & distances
The result matrix for distances.
static const std::string Name()
TreeTypes treeType
Tree type considered for neighbor search.
test cpp RESULT_VARIABLE MEX_RESULT_TRASH OUTPUT_VARIABLE MEX_OUTPUT ERROR_VARIABLE MEX_ERROR_TRASH string(REGEX MATCH"Warning: You are using"MEX_WARNING"${MEX_OUTPUT}") if(MEX_WARNING) string(REGEX REPLACE".*using [a-zA-Z]* version \"([0-9.]*)[^\"]*\".*""\\1"OTHER_COMPILER_VERSION"$
DeleteVisitor deletes the given NSType instance.
bool randomBasis
If true, random projections are used.
double rho
Balance threshold (for spill trees).