mlpack  3.4.2
fastmks_model.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_FASTMKS_FASTMKS_MODEL_HPP
13 #define MLPACK_METHODS_FASTMKS_FASTMKS_MODEL_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 #include "fastmks.hpp"
28 
29 namespace mlpack {
30 namespace fastmks {
31 
35 {
36  public:
39  {
47  };
48 
52  FastMKSModel(const int kernelType = LINEAR_KERNEL);
53 
55  FastMKSModel(const FastMKSModel& other);
56 
59 
62 
67 
72  template<typename TKernelType>
73  void BuildModel(arma::mat&& referenceData,
74  TKernelType& kernel,
75  const bool singleMode,
76  const bool naive,
77  const double base);
78 
80  bool Naive() const;
82  bool& Naive();
83 
85  bool SingleMode() const;
87  bool& SingleMode();
88 
90  int KernelType() const { return kernelType; }
92  int& KernelType() { return kernelType; }
93 
106  void Search(const arma::mat& querySet,
107  const size_t k,
108  arma::Mat<size_t>& indices,
109  arma::mat& kernels,
110  const double base);
111 
121  void Search(const size_t k,
122  arma::Mat<size_t>& indices,
123  arma::mat& kernels);
124 
128  template<typename Archive>
129  void serialize(Archive& ar, const unsigned int /* version */);
130 
131  private:
133  int kernelType;
134 
149 
151  template<typename FastMKSType>
152  void Search(FastMKSType& f,
153  const arma::mat& querySet,
154  const size_t k,
155  arma::Mat<size_t>& indices,
156  arma::mat& kernels,
157  const double base);
158 };
159 
160 } // namespace fastmks
161 } // namespace mlpack
162 
163 #include "fastmks_model_impl.hpp"
164 
165 #endif
mlpack::fastmks::FastMKSModel::Naive
bool & Naive()
Set whether or not naive search is used.
mlpack::fastmks::FastMKS
An implementation of fast exact max-kernel search.
Definition: fastmks.hpp:64
mlpack::fastmks::FastMKSModel::KernelType
int & KernelType()
Modify the kernel type.
Definition: fastmks_model.hpp:92
mlpack::fastmks::FastMKSModel::COSINE_DISTANCE
@ COSINE_DISTANCE
Definition: fastmks_model.hpp:42
pspectrum_string_kernel.hpp
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::fastmks::FastMKSModel::HYPTAN_KERNEL
@ HYPTAN_KERNEL
Definition: fastmks_model.hpp:46
mlpack::fastmks::FastMKSModel::FastMKSModel
FastMKSModel(const int kernelType=LINEAR_KERNEL)
Create the FastMKSModel with the given kernel type.
mlpack::fastmks::FastMKSModel::GAUSSIAN_KERNEL
@ GAUSSIAN_KERNEL
Definition: fastmks_model.hpp:43
mlpack::fastmks::FastMKSModel::EPANECHNIKOV_KERNEL
@ EPANECHNIKOV_KERNEL
Definition: fastmks_model.hpp:44
mlpack::fastmks::FastMKSModel::Search
void Search(const arma::mat &querySet, const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels, const double base)
Search with a different query set.
mlpack::fastmks::FastMKSModel::Naive
bool Naive() const
Get whether or not naive search is used.
mlpack::fastmks::FastMKSModel::KernelTypes
KernelTypes
A list of all the kernels we support.
Definition: fastmks_model.hpp:39
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_cli11.hpp:21
hyperbolic_tangent_kernel.hpp
polynomial_kernel.hpp
mlpack::fastmks::FastMKSModel::TRIANGULAR_KERNEL
@ TRIANGULAR_KERNEL
Definition: fastmks_model.hpp:45
mlpack::fastmks::FastMKSModel::SingleMode
bool & SingleMode()
Set whether or not single-tree search is used.
mlpack::fastmks::FastMKSModel::POLYNOMIAL_KERNEL
@ POLYNOMIAL_KERNEL
Definition: fastmks_model.hpp:41
mlpack::fastmks::FastMKSModel::SingleMode
bool SingleMode() const
Get whether or not single-tree search is used.
mlpack::fastmks::FastMKSModel::Search
void Search(const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels)
Search with the reference set as the query set.
epanechnikov_kernel.hpp
gaussian_kernel.hpp
mlpack::fastmks::FastMKSModel::BuildModel
void BuildModel(arma::mat &&referenceData, TKernelType &kernel, const bool singleMode, const bool naive, const double base)
Build the model on the given reference set.
mlpack::fastmks::FastMKSModel::operator=
FastMKSModel & operator=(const FastMKSModel &other)
Copy assignment operator.
mlpack::fastmks::FastMKSModel::LINEAR_KERNEL
@ LINEAR_KERNEL
Definition: fastmks_model.hpp:40
mlpack::fastmks::FastMKSModel::~FastMKSModel
~FastMKSModel()
Clean memory.
mlpack::fastmks::FastMKSModel::FastMKSModel
FastMKSModel(const FastMKSModel &other)
Copy constructor.
linear_kernel.hpp
mlpack::fastmks::FastMKSModel
A utility struct to contain all the possible FastMKS models, for use by the mlpack_fastmks program.
Definition: fastmks_model.hpp:35
mlpack::fastmks::FastMKSModel::FastMKSModel
FastMKSModel(FastMKSModel &&other)
Move constructor.
cosine_distance.hpp
triangular_kernel.hpp
fastmks.hpp
laplacian_kernel.hpp
kernel_traits.hpp
mlpack::fastmks::FastMKSModel::serialize
void serialize(Archive &ar, const unsigned int)
Serialize the model.
mlpack::fastmks::FastMKSModel::KernelType
int KernelType() const
Get the kernel type.
Definition: fastmks_model.hpp:90
spherical_kernel.hpp