mlpack
Classes | Public Types | Public Member Functions | List of all members
mlpack::fastmks::FastMKSRules< KernelType, TreeType > Class Template Reference

The FastMKSRules class is a template helper class used by FastMKS class when performing exact max-kernel search. More...

#include <fastmks_rules.hpp>

Public Types

typedef tree::TraversalInfo< TreeType > TraversalInfoType
 

Public Member Functions

 FastMKSRules (const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const size_t k, KernelType &kernel)
 Construct the FastMKSRules object. More...
 
void GetResults (arma::Mat< size_t > &indices, arma::mat &products)
 Store the list of candidates for each query point in the given matrices. More...
 
double BaseCase (const size_t queryIndex, const size_t referenceIndex)
 Compute the base case (kernel value) between two points.
 
double Score (const size_t queryIndex, TreeType &referenceNode)
 Get the score for recursion order. More...
 
double Score (TreeType &queryNode, TreeType &referenceNode)
 Get the score for recursion order. More...
 
double Rescore (const size_t queryIndex, TreeType &referenceNode, const double oldScore) const
 Re-evaluate the score for recursion order. More...
 
double Rescore (TreeType &queryNode, TreeType &referenceNode, const double oldScore) const
 Re-evaluate the score for recursion order. More...
 
size_t BaseCases () const
 Get the number of times BaseCase() was called.
 
size_t & BaseCases ()
 Modify the number of times BaseCase() was called.
 
size_t Scores () const
 Get the number of times Score() was called.
 
size_t & Scores ()
 Modify the number of times Score() was called.
 
const TraversalInfoTypeTraversalInfo () const
 
TraversalInfoTypeTraversalInfo ()
 
size_t MinimumBaseCases () const
 Get the minimum number of base cases we need to perform to have acceptable results. More...
 

Detailed Description

template<typename KernelType, typename TreeType>
class mlpack::fastmks::FastMKSRules< KernelType, TreeType >

The FastMKSRules class is a template helper class used by FastMKS class when performing exact max-kernel search.

For each point in the query dataset, it keeps track of the k best candidates in the reference dataset.

Template Parameters
KernelTypeType of kernel to run FastMKS with.
TreeTypeType of tree to run FastMKS with; it must satisfy the TreeType policy API.

Constructor & Destructor Documentation

◆ FastMKSRules()

template<typename KernelType , typename TreeType >
mlpack::fastmks::FastMKSRules< KernelType, TreeType >::FastMKSRules ( const typename TreeType::Mat &  referenceSet,
const typename TreeType::Mat &  querySet,
const size_t  k,
KernelType &  kernel 
)

Construct the FastMKSRules object.

This is usually done from within the FastMKS class at search time.

Parameters
referenceSetSet of reference data.
querySetSet of query data.
kNumber of candidates to search for.
kernelKernel to run FastMKS with.

Member Function Documentation

◆ GetResults()

template<typename KernelType , typename TreeType >
void mlpack::fastmks::FastMKSRules< KernelType, TreeType >::GetResults ( arma::Mat< size_t > &  indices,
arma::mat &  products 
)

Store the list of candidates for each query point in the given matrices.

Parameters
indicesMatrix storing lists of candidate for each query point.
productsMatrix storing kernel value for each candidate.

◆ MinimumBaseCases()

template<typename KernelType , typename TreeType >
size_t mlpack::fastmks::FastMKSRules< KernelType, TreeType >::MinimumBaseCases ( ) const
inline

Get the minimum number of base cases we need to perform to have acceptable results.

◆ Rescore() [1/2]

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Rescore ( const size_t  queryIndex,
TreeType &  referenceNode,
const double  oldScore 
) const

Re-evaluate the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that a node should not be recursed into at all (it should be pruned). This is used when the score has already been calculated, but another recursion may have modified the bounds for pruning. So the old score is checked against the new pruning bound.

Parameters
queryIndexIndex of query point.
referenceNodeCandidate node to be recursed into.
oldScoreOld score produced by Score() (or Rescore()).

◆ Rescore() [2/2]

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Rescore ( TreeType &  queryNode,
TreeType &  referenceNode,
const double  oldScore 
) const

Re-evaluate the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that a node should not be recursed into at all (it should be pruned). This is used when the score has already been calculated, but another recursion may have modified the bounds for pruning. So the old score is checked against the new pruning bound.

Parameters
queryNodeCandidate query node to be recursed into.
referenceNodeCandidate reference node to be recursed into.
oldScoreOld score produced by Score() (or Rescore()).

◆ Score() [1/2]

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Score ( const size_t  queryIndex,
TreeType &  referenceNode 
)

Get the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that the node should not be recursed into at all (it should be pruned).

Parameters
queryIndexIndex of query point.
referenceNodeCandidate to be recursed into.

◆ Score() [2/2]

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Score ( TreeType &  queryNode,
TreeType &  referenceNode 
)

Get the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that the node should not be recursed into at all (it should be pruned).

Parameters
queryNodeCandidate query node to be recursed into.
referenceNodeCandidate reference node to be recursed into.

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