13 #ifndef MLPACK_METHODS_FASTMKS_FASTMKS_HPP
14 #define MLPACK_METHODS_FASTMKS_FASTMKS_HPP
57 typename MatType = arma::mat,
58 template<
typename TreeMetricType,
59 typename TreeStatType,
75 FastMKS(
const bool singleMode =
false,
const bool naive =
false);
86 FastMKS(
const MatType& referenceSet,
87 const bool singleMode =
false,
88 const bool naive =
false);
101 FastMKS(
const MatType& referenceSet,
103 const bool singleMode =
false,
104 const bool naive =
false);
118 const bool singleMode =
false);
129 void Train(
const MatType& referenceSet);
139 void Train(
const MatType& referenceSet, KernelType& kernel);
170 void Search(
const MatType& querySet,
172 arma::Mat<size_t>& indices,
199 arma::Mat<size_t>& indices,
216 void Search(
const size_t k,
217 arma::Mat<size_t>& indices,
218 arma::mat& products);
231 bool Naive()
const {
return naive; }
236 template<
typename Archive>
237 void Serialize(Archive& ar,
const unsigned int );
242 const MatType* referenceSet;
259 typedef std::pair<double, size_t> Candidate;
262 struct CandidateCmp {
263 bool operator()(
const Candidate& c1,
const Candidate& c2)
265 return c1.first > c2.first;
270 typedef std::priority_queue<Candidate, std::vector<Candidate>,
271 CandidateCmp> CandidateList;
278 #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.
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.
void Serialize(Archive &ar, const unsigned int)
Serialize the model.
~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.
TreeType< metric::IPMetric< KernelType >, FastMKSStat, MatType > Tree
Convenience typedef.
bool Naive() const
Get whether or not brute-force (naive) search is used.
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).
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...