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

The base case and pruning rules for FastMKS (fast max-kernel search). More...

Public Types

typedef
neighbor::NeighborSearchTraversalInfo
< TreeType > 
TraversalInfoType
 

Public Member Functions

 FastMKSRules (const arma::mat &referenceSet, const arma::mat &querySet, arma::Mat< size_t > &indices, arma::mat &products, KernelType &kernel)
 
double BaseCase (const size_t queryIndex, const size_t referenceIndex)
 Compute the base case (kernel value) between two points. More...
 
size_t BaseCases () const
 Get the number of times BaseCase() was called. More...
 
size_t & BaseCases ()
 Modify the number of times BaseCase() was called. 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...
 
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...
 
size_t Scores () const
 Get the number of times Score() was called. More...
 
size_t & Scores ()
 Modify the number of times Score() was called. More...
 
const TraversalInfoTypeTraversalInfo () const
 
TraversalInfoTypeTraversalInfo ()
 

Private Member Functions

double CalculateBound (TreeType &queryNode) const
 Calculate the bound for a given query node. More...
 
void InsertNeighbor (const size_t queryIndex, const size_t pos, const size_t neighbor, const double distance)
 Utility function to insert neighbor into list of results. More...
 

Private Attributes

size_t baseCases
 For benchmarking. More...
 
arma::Mat< size_t > & indices
 The indices of the maximum kernel results. More...
 
KernelType & kernel
 The instantiated kernel. More...
 
double lastKernel
 The last kernel evaluation resulting from BaseCase(). More...
 
size_t lastQueryIndex
 The last query index BaseCase() was called with. More...
 
size_t lastReferenceIndex
 The last reference index BaseCase() was called with. More...
 
arma::mat & products
 The maximum kernels. More...
 
arma::vec queryKernels
 Cached query set self-kernels (|| q || for each q). More...
 
const arma::mat & querySet
 The query dataset. More...
 
arma::vec referenceKernels
 Cached reference set self-kernels (|| r || for each r). More...
 
const arma::mat & referenceSet
 The reference dataset. More...
 
size_t scores
 For benchmarking. More...
 
TraversalInfoType traversalInfo
 

Detailed Description

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

The base case and pruning rules for FastMKS (fast max-kernel search).

Definition at line 37 of file fastmks_rules.hpp.

Member Typedef Documentation

template<typename KernelType , typename TreeType >
typedef neighbor::NeighborSearchTraversalInfo<TreeType> mlpack::fastmks::FastMKSRules< KernelType, TreeType >::TraversalInfoType

Definition at line 109 of file fastmks_rules.hpp.

Constructor & Destructor Documentation

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

Member Function Documentation

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::BaseCase ( const size_t  queryIndex,
const size_t  referenceIndex 
)

Compute the base case (kernel value) between two points.

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

Get the number of times BaseCase() was called.

Definition at line 100 of file fastmks_rules.hpp.

References mlpack::fastmks::FastMKSRules< KernelType, TreeType >::baseCases.

template<typename KernelType , typename TreeType >
size_t& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::BaseCases ( )
inline

Modify the number of times BaseCase() was called.

Definition at line 102 of file fastmks_rules.hpp.

References mlpack::fastmks::FastMKSRules< KernelType, TreeType >::baseCases.

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::CalculateBound ( TreeType &  queryNode) const
private

Calculate the bound for a given query node.

template<typename KernelType , typename TreeType >
void mlpack::fastmks::FastMKSRules< KernelType, TreeType >::InsertNeighbor ( const size_t  queryIndex,
const size_t  pos,
const size_t  neighbor,
const double  distance 
)
private

Utility function to insert neighbor into list of results.

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()).
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()).
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.
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.
template<typename KernelType , typename TreeType >
size_t mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Scores ( ) const
inline

Get the number of times Score() was called.

Definition at line 105 of file fastmks_rules.hpp.

References mlpack::fastmks::FastMKSRules< KernelType, TreeType >::scores.

template<typename KernelType , typename TreeType >
size_t& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Scores ( )
inline

Modify the number of times Score() was called.

Definition at line 107 of file fastmks_rules.hpp.

References mlpack::fastmks::FastMKSRules< KernelType, TreeType >::scores.

template<typename KernelType , typename TreeType >
const TraversalInfoType& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::TraversalInfo ( ) const
inline
template<typename KernelType , typename TreeType >
TraversalInfoType& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::TraversalInfo ( )
inline

Member Data Documentation

template<typename KernelType , typename TreeType >
size_t mlpack::fastmks::FastMKSRules< KernelType, TreeType >::baseCases
private

For benchmarking.

Definition at line 150 of file fastmks_rules.hpp.

Referenced by mlpack::fastmks::FastMKSRules< KernelType, TreeType >::BaseCases().

template<typename KernelType , typename TreeType >
arma::Mat<size_t>& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::indices
private

The indices of the maximum kernel results.

Definition at line 121 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
KernelType& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::kernel
private

The instantiated kernel.

Definition at line 131 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
double mlpack::fastmks::FastMKSRules< KernelType, TreeType >::lastKernel
private

The last kernel evaluation resulting from BaseCase().

Definition at line 138 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
size_t mlpack::fastmks::FastMKSRules< KernelType, TreeType >::lastQueryIndex
private

The last query index BaseCase() was called with.

Definition at line 134 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
size_t mlpack::fastmks::FastMKSRules< KernelType, TreeType >::lastReferenceIndex
private

The last reference index BaseCase() was called with.

Definition at line 136 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
arma::mat& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::products
private

The maximum kernels.

Definition at line 123 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
arma::vec mlpack::fastmks::FastMKSRules< KernelType, TreeType >::queryKernels
private

Cached query set self-kernels (|| q || for each q).

Definition at line 126 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
const arma::mat& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::querySet
private

The query dataset.

Definition at line 118 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
arma::vec mlpack::fastmks::FastMKSRules< KernelType, TreeType >::referenceKernels
private

Cached reference set self-kernels (|| r || for each r).

Definition at line 128 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
const arma::mat& mlpack::fastmks::FastMKSRules< KernelType, TreeType >::referenceSet
private

The reference dataset.

Definition at line 116 of file fastmks_rules.hpp.

template<typename KernelType , typename TreeType >
size_t mlpack::fastmks::FastMKSRules< KernelType, TreeType >::scores
private

For benchmarking.

Definition at line 152 of file fastmks_rules.hpp.

Referenced by mlpack::fastmks::FastMKSRules< KernelType, TreeType >::Scores().

template<typename KernelType , typename TreeType >
TraversalInfoType mlpack::fastmks::FastMKSRules< KernelType, TreeType >::traversalInfo
private

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