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);
88 const bool singleMode =
false,
89 const bool naive =
false);
104 const bool singleMode =
false,
105 const bool naive =
false);
118 const bool singleMode =
false,
119 const bool naive =
false);
135 const bool singleMode =
false,
136 const bool naive =
false);
149 const bool singleMode =
false);
175 void Train(
const MatType& referenceSet);
185 void Train(
const MatType& referenceSet, KernelType& kernel);
204 void Train(MatType&& referenceSet, KernelType& kernel);
237 arma::Mat<size_t>& indices,
264 arma::Mat<size_t>& indices,
282 arma::Mat<size_t>& indices,
283 arma::mat& products);
296 bool Naive()
const {
return naive; }
301 template<
typename Archive>
307 const MatType* referenceSet;
324 typedef std::pair<double, size_t> Candidate;
327 struct CandidateCmp {
328 bool operator()(
const Candidate& c1,
const Candidate& c2)
330 return c1.first > c2.first;
335 typedef std::priority_queue<Candidate, std::vector<Candidate>,
336 CandidateCmp> CandidateList;
343#include "fastmks_impl.hpp"
The statistic used in trees with FastMKS.
An implementation of fast exact max-kernel search.
metric::IPMetric< KernelType > & Metric()
Modify the inner-product metric induced by the given kernel.
bool Naive() const
Get whether or not brute-force (naive) search is used.
FastMKS & operator=(const FastMKS &other)
Assign this model to be a copy of the given model.
FastMKS(MatType &&referenceSet, KernelType &kernel, const bool singleMode=false, const bool naive=false)
Create the FastMKS object using the reference set (this is the set that is searched) with an initiali...
void Train(Tree *referenceTree)
Train the FastMKS model on the given reference tree.
~FastMKS()
Destructor for the FastMKS object.
void Search(Tree *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 query ...
bool SingleMode() const
Get whether or not single-tree search is used.
FastMKS(Tree *referenceTree, const bool singleMode=false)
Create the FastMKS object with an already-initialized tree built on the reference points.
FastMKS(const bool singleMode=false, const bool naive=false)
Create the FastMKS object with an empty reference set and default kernel.
FastMKS(const MatType &referenceSet, KernelType &kernel, const bool singleMode=false, const bool naive=false)
Create the FastMKS object using the reference set (this is the set that is searched) with an initiali...
const metric::IPMetric< KernelType > & Metric() const
Get the inner-product metric induced by the given kernel.
bool & Naive()
Modify whether or not brute-force (naive) search is used.
void Train(const MatType &referenceSet, KernelType &kernel)
"Train" the FastMKS model on the given reference set and use the given kernel.
void Search(const size_t k, arma::Mat< size_t > &indices, arma::mat &products)
Search for the maximum inner products of the query set (or if no query set was passed,...
void Train(MatType &&referenceSet)
"Train" the FastMKS model on the given reference set (this will just build a tree,...
void Train(MatType &&referenceSet, KernelType &kernel)
"Train" the FastMKS model on the given reference set and use the given kernel.
bool & SingleMode()
Modify whether or not single-tree search is used.
void Train(const MatType &referenceSet)
"Train" the FastMKS model on the given reference set (this will just build a tree,...
FastMKS(MatType &&referenceSet, const bool singleMode=false, const bool naive=false)
Create the FastMKS object with the given reference set (this is the set that is searched),...
FastMKS(FastMKS &&other)
Take ownership of the given model.
FastMKS(const FastMKS &other)
Copy the parameters of the given model.
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 ...
void serialize(Archive &ar, const unsigned int)
Serialize the model.
FastMKS(const MatType &referenceSet, const bool singleMode=false, const bool naive=false)
Create the FastMKS object with the given reference set (this is the set that is searched).
The inner product metric, IPMetric, takes a given Mercer kernel (KernelType), and when Evaluate() is ...
A cover tree is a tree specifically designed to speed up nearest-neighbor computation in high-dimensi...
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.