13 #ifndef MLPACK_METHODS_FASTMKS_FASTMKS_HPP 14 #define MLPACK_METHODS_FASTMKS_FASTMKS_HPP 58 typename MatType = arma::mat,
59 template<
typename TreeMetricType,
60 typename TreeStatType,
76 FastMKS(
const bool singleMode =
false,
const bool naive =
false);
87 FastMKS(
const MatType& referenceSet,
88 const bool singleMode =
false,
89 const bool naive =
false);
102 FastMKS(
const MatType& referenceSet,
104 const bool singleMode =
false,
105 const bool naive =
false);
117 FastMKS(MatType&& referenceSet,
118 const bool singleMode =
false,
119 const bool naive =
false);
133 FastMKS(MatType&& referenceSet,
135 const bool singleMode =
false,
136 const bool naive =
false);
149 const bool singleMode =
false);
180 void Train(
const MatType& referenceSet);
190 void Train(
const MatType& referenceSet, KernelType& kernel);
199 void Train(MatType&& referenceSet);
209 void Train(MatType&& referenceSet, KernelType& kernel);
218 void Train(Tree* referenceTree);
240 void Search(
const MatType& querySet,
242 arma::Mat<size_t>& indices,
267 void Search(Tree* querySet,
269 arma::Mat<size_t>& indices,
286 void Search(
const size_t k,
287 arma::Mat<size_t>& indices,
288 arma::mat& products);
301 bool Naive()
const {
return naive; }
306 template<
typename Archive>
307 void serialize(Archive& ar,
const uint32_t );
312 const MatType* referenceSet;
329 typedef std::pair<double, size_t> Candidate;
332 struct CandidateCmp {
333 bool operator()(
const Candidate& c1,
const Candidate& c2)
335 return c1.first > c2.first;
340 typedef std::priority_queue<Candidate, std::vector<Candidate>,
341 CandidateCmp> CandidateList;
348 #include "fastmks_impl.hpp" bool SingleMode() const
Get whether or not single-tree search is used.
const metric::IPMetric< KernelType > & Metric() const
Get the inner-product metric induced by the given kernel.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
bool & Naive()
Modify whether or not brute-force (naive) search is used.
The inner product metric, IPMetric, takes a given Mercer kernel (KernelType), and when Evaluate() is ...
FastMKS(const bool singleMode=false, const bool naive=false)
Create the FastMKS object with an empty reference set and default kernel.
~FastMKS()
Destructor for the FastMKS object.
metric::IPMetric< KernelType > & Metric()
Modify the inner-product metric induced by the given kernel.
bool & SingleMode()
Modify whether or not single-tree search is used.
bool Naive() const
Get whether or not brute-force (naive) search is used.
TreeType< metric::IPMetric< KernelType >, FastMKSStat, MatType > Tree
Convenience typedef.
void Search(const MatType &querySet, const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels)
Search for the points in the reference set with maximum kernel evaluation to each point in the given ...
The statistic used in trees with FastMKS.
void Train(const MatType &referenceSet)
"Train" the FastMKS model on the given reference set (this will just build a tree, if the current search mode is not naive mode).
FastMKS & operator=(const FastMKS &other)
Assign this model to be a copy of the given model.
An implementation of fast exact max-kernel search.
A cover tree is a tree specifically designed to speed up nearest-neighbor computation in high-dimensi...
void serialize(Archive &ar, const uint32_t)
Serialize the model.