mlpack  master
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
mlpack::fastmks::FastMKSModel Class Reference

A utility struct to contain all the possible FastMKS models, for use by the mlpack_fastmks program. More...

Public Types

enum  KernelTypes {
  LINEAR_KERNEL,
  POLYNOMIAL_KERNEL,
  COSINE_DISTANCE,
  GAUSSIAN_KERNEL,
  EPANECHNIKOV_KERNEL,
  TRIANGULAR_KERNEL,
  HYPTAN_KERNEL
}
 A list of all the kernels we support. More...
 

Public Member Functions

 FastMKSModel (const int kernelType=LINEAR_KERNEL)
 Create the FastMKSModel with the given kernel type. More...
 
 FastMKSModel (const FastMKSModel &other)
 Copy constructor. More...
 
 FastMKSModel (FastMKSModel &&other)
 Move constructor. More...
 
 ~FastMKSModel ()
 Clean memory. More...
 
template<typename TKernelType >
void BuildModel (const arma::mat &referenceData, TKernelType &kernel, const bool singleMode, const bool naive, const double base)
 Build the model on the given reference set. More...
 
int KernelType () const
 Get the kernel type. More...
 
int & KernelType ()
 Modify the kernel type. More...
 
bool Naive () const
 Get whether or not naive search is used. More...
 
bool & Naive ()
 Set whether or not naive search is used. More...
 
FastMKSModeloperator= (const FastMKSModel &other)
 Copy assignment operator. More...
 
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. More...
 
void Search (const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels)
 Search with the reference set as the query set. More...
 
template<typename Archive >
void Serialize (Archive &ar, const unsigned int)
 Serialize the model. More...
 
bool SingleMode () const
 Get whether or not single-tree search is used. More...
 
bool & SingleMode ()
 Set whether or not single-tree search is used. More...
 

Private Member Functions

template<typename FastMKSType >
void Search (FastMKSType &f, const arma::mat &querySet, const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels, const double base)
 Build a query tree and execute the search. More...
 

Private Attributes

FastMKS< kernel::CosineDistance > * cosine
 This will only be non-NULL if this is the type of kernel we are using. More...
 
FastMKS< kernel::EpanechnikovKernel > * epan
 This will only be non-NULL if this is the type of kernel we are using. More...
 
FastMKS< kernel::GaussianKernel > * gaussian
 This will only be non-NULL if this is the type of kernel we are using. More...
 
FastMKS< kernel::HyperbolicTangentKernel > * hyptan
 This will only be non-NULL if this is the type of kernel we are using. More...
 
int kernelType
 The type of kernel we are using. More...
 
FastMKS< kernel::LinearKernel > * linear
 This will only be non-NULL if this is the type of kernel we are using. More...
 
FastMKS< kernel::PolynomialKernel > * polynomial
 This will only be non-NULL if this is the type of kernel we are using. More...
 
FastMKS< kernel::TriangularKernel > * triangular
 This will only be non-NULL if this is the type of kernel we are using. More...
 

Detailed Description

A utility struct to contain all the possible FastMKS models, for use by the mlpack_fastmks program.

Definition at line 34 of file fastmks_model.hpp.

Member Enumeration Documentation

A list of all the kernels we support.

Enumerator
LINEAR_KERNEL 
POLYNOMIAL_KERNEL 
COSINE_DISTANCE 
GAUSSIAN_KERNEL 
EPANECHNIKOV_KERNEL 
TRIANGULAR_KERNEL 
HYPTAN_KERNEL 

Definition at line 38 of file fastmks_model.hpp.

Constructor & Destructor Documentation

mlpack::fastmks::FastMKSModel::FastMKSModel ( const int  kernelType = LINEAR_KERNEL)

Create the FastMKSModel with the given kernel type.

mlpack::fastmks::FastMKSModel::FastMKSModel ( const FastMKSModel other)

Copy constructor.

mlpack::fastmks::FastMKSModel::FastMKSModel ( FastMKSModel &&  other)

Move constructor.

mlpack::fastmks::FastMKSModel::~FastMKSModel ( )

Clean memory.

Member Function Documentation

template<typename TKernelType >
void mlpack::fastmks::FastMKSModel::BuildModel ( const arma::mat &  referenceData,
TKernelType &  kernel,
const bool  singleMode,
const bool  naive,
const double  base 
)

Build the model on the given reference set.

Make sure kernelType is equal to the correct entry in KernelTypes for the given KernelType class!

int mlpack::fastmks::FastMKSModel::KernelType ( ) const
inline

Get the kernel type.

Definition at line 90 of file fastmks_model.hpp.

References kernelType.

int& mlpack::fastmks::FastMKSModel::KernelType ( )
inline

Modify the kernel type.

Definition at line 92 of file fastmks_model.hpp.

References kernelType, Search(), and Serialize().

bool mlpack::fastmks::FastMKSModel::Naive ( ) const

Get whether or not naive search is used.

bool& mlpack::fastmks::FastMKSModel::Naive ( )

Set whether or not naive search is used.

FastMKSModel& mlpack::fastmks::FastMKSModel::operator= ( const FastMKSModel other)

Copy assignment operator.

void mlpack::fastmks::FastMKSModel::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.

Parameters
querySetSet to search with.
kNumber of max-kernel candidates to search for.
indicesA matrix in which to store the indices of max-kernel candidates.
kernelsA matrix in which to store the max-kernel candidate kernel values.
baseBase to use for cover tree building (if in dual-tree search mode).

Referenced by KernelType().

void mlpack::fastmks::FastMKSModel::Search ( const size_t  k,
arma::Mat< size_t > &  indices,
arma::mat &  kernels 
)

Search with the reference set as the query set.

Parameters
kNumber of max-kernel candidates to search for.
indicesA matrix in which to store the indices of max-kernel candidates.
kernelsA matrix in which to store the max-kernel candidate kernel values.
template<typename FastMKSType >
void mlpack::fastmks::FastMKSModel::Search ( FastMKSType &  f,
const arma::mat &  querySet,
const size_t  k,
arma::Mat< size_t > &  indices,
arma::mat &  kernels,
const double  base 
)
private

Build a query tree and execute the search.

template<typename Archive >
void mlpack::fastmks::FastMKSModel::Serialize ( Archive &  ar,
const unsigned  int 
)

Serialize the model.

Referenced by KernelType().

bool mlpack::fastmks::FastMKSModel::SingleMode ( ) const

Get whether or not single-tree search is used.

bool& mlpack::fastmks::FastMKSModel::SingleMode ( )

Set whether or not single-tree search is used.

Member Data Documentation

FastMKS<kernel::CosineDistance>* mlpack::fastmks::FastMKSModel::cosine
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 140 of file fastmks_model.hpp.

FastMKS<kernel::EpanechnikovKernel>* mlpack::fastmks::FastMKSModel::epan
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 144 of file fastmks_model.hpp.

FastMKS<kernel::GaussianKernel>* mlpack::fastmks::FastMKSModel::gaussian
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 142 of file fastmks_model.hpp.

FastMKS<kernel::HyperbolicTangentKernel>* mlpack::fastmks::FastMKSModel::hyptan
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 148 of file fastmks_model.hpp.

int mlpack::fastmks::FastMKSModel::kernelType
private

The type of kernel we are using.

Definition at line 133 of file fastmks_model.hpp.

Referenced by KernelType().

FastMKS<kernel::LinearKernel>* mlpack::fastmks::FastMKSModel::linear
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 136 of file fastmks_model.hpp.

FastMKS<kernel::PolynomialKernel>* mlpack::fastmks::FastMKSModel::polynomial
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 138 of file fastmks_model.hpp.

FastMKS<kernel::TriangularKernel>* mlpack::fastmks::FastMKSModel::triangular
private

This will only be non-NULL if this is the type of kernel we are using.

Definition at line 146 of file fastmks_model.hpp.


The documentation for this class was generated from the following file: