mlpack  master
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
mlpack::neighbor::RAModel< SortPolicy > Class Template Reference

The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType parameter and allowing it to be specified at runtime in this class. More...

Public Types

enum  TreeTypes {
  KD_TREE,
  COVER_TREE,
  R_TREE,
  R_STAR_TREE,
  X_TREE,
  HILBERT_R_TREE,
  R_PLUS_TREE,
  R_PLUS_PLUS_TREE,
  UB_TREE,
  OCTREE
}
 The list of tree types we can use with RASearch. More...
 

Public Member Functions

 RAModel (TreeTypes treeType=TreeTypes::KD_TREE, bool randomBasis=false)
 Initialize the RAModel with the given type and whether or not a random basis should be used. More...
 
 RAModel (const RAModel &other)
 Copy the given RAModel. More...
 
 RAModel (RAModel &&other)
 Take ownership of the given RAModel. More...
 
 ~RAModel ()
 Clean memory, if necessary. More...
 
double Alpha () const
 Get the desired success probability. More...
 
double & Alpha ()
 Modify the desired success probability. More...
 
void BuildModel (arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
 Build the reference tree. More...
 
const arma::mat & Dataset () const
 Expose the dataset. More...
 
bool FirstLeafExact () const
 Get whether or not we traverse to the first leaf without approximation. More...
 
bool & FirstLeafExact ()
 Modify whether or not we traverse to the first leaf without approximation. More...
 
size_t LeafSize () const
 Get the leaf size (only relevant when the kd-tree is used). More...
 
size_t & LeafSize ()
 Modify the leaf size (only relevant when the kd-tree is used). More...
 
bool Naive () const
 Get whether or not naive search is being used. More...
 
bool & Naive ()
 Modify whether or not naive search is being used. More...
 
RAModeloperator= (const RAModel &other)
 Copy the given RAModel. More...
 
RAModeloperator= (RAModel &&other)
 Take ownership of the given RAModel. More...
 
bool RandomBasis () const
 Get whether or not a random basis is being used. More...
 
bool & RandomBasis ()
 Modify whether or not a random basis is being used. More...
 
bool SampleAtLeaves () const
 Get whether or not sampling is done at the leaves. More...
 
bool & SampleAtLeaves ()
 Modify whether or not sampling is done at the leaves. More...
 
void Search (arma::mat &&querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
 Perform rank-approximate neighbor search, taking ownership of the query set. More...
 
void Search (const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
 Perform rank-approximate neighbor search, using 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 being used. More...
 
bool & SingleMode ()
 Modify whether or not single-tree search is being used. More...
 
size_t SingleSampleLimit () const
 Get the limit on the size of a node that can be approximated. More...
 
size_t & SingleSampleLimit ()
 Modify the limit on the size of a node that can be approximation. More...
 
double Tau () const
 Get the rank-approximation in percentile of the data. More...
 
double & Tau ()
 Modify the rank-approximation in percentile of the data. More...
 
std::string TreeName () const
 Get the name of the tree type. More...
 
TreeTypes TreeType () const
 Get the type of tree being used. More...
 
TreeTypesTreeType ()
 Modify the type of tree being used. More...
 

Private Types

template<template< typename TreeMetricType, typename TreeStatType, typename TreeMatType > class TreeType>
using RAType = RASearch< SortPolicy, metric::EuclideanDistance, arma::mat, TreeType >
 Typedef the RASearch class we'll use. More...
 

Private Attributes

RAType< tree::StandardCoverTree > * coverTreeRA
 Non-NULL if the cover tree is used. More...
 
RAType< tree::HilbertRTree > * hilbertRTreeRA
 Non-NULL if the Hilbert R tree is used. More...
 
RAType< tree::KDTree > * kdTreeRA
 Non-NULL if the kd-tree is used. More...
 
size_t leafSize
 The leaf size of the tree being used (useful only for the kd-tree). More...
 
RAType< tree::Octree > * octreeRA
 Non-NULL if the octree is used. More...
 
arma::mat q
 The basis to project into. More...
 
bool randomBasis
 If true, randomly project into a new basis. More...
 
RAType< tree::RPlusPlusTree > * rPlusPlusTreeRA
 Non-NULL if the R++ tree is used. More...
 
RAType< tree::RPlusTree > * rPlusTreeRA
 Non-NULL if the R+ tree is used. More...
 
RAType< tree::RStarTree > * rStarTreeRA
 Non-NULL if the R* tree is used. More...
 
RAType< tree::RTree > * rTreeRA
 Non-NULL if the R tree is used. More...
 
TreeTypes treeType
 The type of tree being used. More...
 
RAType< tree::UBTree > * ubTreeRA
 Non-NULL if the UB tree is used. More...
 
RAType< tree::XTree > * xTreeRA
 Non-NULL if the X tree is used. More...
 

Detailed Description

template<typename SortPolicy>
class mlpack::neighbor::RAModel< SortPolicy >

The RAModel class provides an abstraction for the RASearch class, abstracting away the TreeType parameter and allowing it to be specified at runtime in this class.

This class is written for the sake of the 'allkrann' program, but is not necessarily restricted to that use.

Parameters
SortPolicySorting policy for neighbor searching (see RASearch).

Definition at line 36 of file ra_model.hpp.

Member Typedef Documentation

template<typename SortPolicy >
template<template< typename TreeMetricType, typename TreeStatType, typename TreeMatType > class TreeType>
using mlpack::neighbor::RAModel< SortPolicy >::RAType = RASearch<SortPolicy, metric::EuclideanDistance, arma::mat, TreeType>
private

Typedef the RASearch class we'll use.

Definition at line 75 of file ra_model.hpp.

Member Enumeration Documentation

template<typename SortPolicy >
enum mlpack::neighbor::RAModel::TreeTypes

The list of tree types we can use with RASearch.

Does not include ball trees; see #338.

Enumerator
KD_TREE 
COVER_TREE 
R_TREE 
R_STAR_TREE 
X_TREE 
HILBERT_R_TREE 
R_PLUS_TREE 
R_PLUS_PLUS_TREE 
UB_TREE 
OCTREE 

Definition at line 43 of file ra_model.hpp.

Constructor & Destructor Documentation

template<typename SortPolicy >
mlpack::neighbor::RAModel< SortPolicy >::RAModel ( TreeTypes  treeType = TreeTypes::KD_TREE,
bool  randomBasis = false 
)

Initialize the RAModel with the given type and whether or not a random basis should be used.

template<typename SortPolicy >
mlpack::neighbor::RAModel< SortPolicy >::RAModel ( const RAModel< SortPolicy > &  other)

Copy the given RAModel.

Parameters
otherRAModel to copy.
template<typename SortPolicy >
mlpack::neighbor::RAModel< SortPolicy >::RAModel ( RAModel< SortPolicy > &&  other)

Take ownership of the given RAModel.

Parameters
otherRAModel to take ownership of.
template<typename SortPolicy >
mlpack::neighbor::RAModel< SortPolicy >::~RAModel ( )

Clean memory, if necessary.

Member Function Documentation

template<typename SortPolicy >
double mlpack::neighbor::RAModel< SortPolicy >::Alpha ( ) const

Get the desired success probability.

template<typename SortPolicy >
double& mlpack::neighbor::RAModel< SortPolicy >::Alpha ( )

Modify the desired success probability.

template<typename SortPolicy >
void mlpack::neighbor::RAModel< SortPolicy >::BuildModel ( arma::mat &&  referenceSet,
const size_t  leafSize,
const bool  naive,
const bool  singleMode 
)

Build the reference tree.

template<typename SortPolicy >
const arma::mat& mlpack::neighbor::RAModel< SortPolicy >::Dataset ( ) const

Expose the dataset.

template<typename SortPolicy >
bool mlpack::neighbor::RAModel< SortPolicy >::FirstLeafExact ( ) const

Get whether or not we traverse to the first leaf without approximation.

template<typename SortPolicy >
bool& mlpack::neighbor::RAModel< SortPolicy >::FirstLeafExact ( )

Modify whether or not we traverse to the first leaf without approximation.

template<typename SortPolicy >
size_t mlpack::neighbor::RAModel< SortPolicy >::LeafSize ( ) const

Get the leaf size (only relevant when the kd-tree is used).

template<typename SortPolicy >
size_t& mlpack::neighbor::RAModel< SortPolicy >::LeafSize ( )

Modify the leaf size (only relevant when the kd-tree is used).

template<typename SortPolicy >
bool mlpack::neighbor::RAModel< SortPolicy >::Naive ( ) const

Get whether or not naive search is being used.

template<typename SortPolicy >
bool& mlpack::neighbor::RAModel< SortPolicy >::Naive ( )

Modify whether or not naive search is being used.

template<typename SortPolicy >
RAModel& mlpack::neighbor::RAModel< SortPolicy >::operator= ( const RAModel< SortPolicy > &  other)

Copy the given RAModel.

Parameters
otherRAModel to copy.
template<typename SortPolicy >
RAModel& mlpack::neighbor::RAModel< SortPolicy >::operator= ( RAModel< SortPolicy > &&  other)

Take ownership of the given RAModel.

Parameters
otherRAModel to take ownership of.
template<typename SortPolicy >
bool mlpack::neighbor::RAModel< SortPolicy >::RandomBasis ( ) const

Get whether or not a random basis is being used.

template<typename SortPolicy >
bool& mlpack::neighbor::RAModel< SortPolicy >::RandomBasis ( )

Modify whether or not a random basis is being used.

Be sure to rebuild the model using BuildModel().

template<typename SortPolicy >
bool mlpack::neighbor::RAModel< SortPolicy >::SampleAtLeaves ( ) const

Get whether or not sampling is done at the leaves.

template<typename SortPolicy >
bool& mlpack::neighbor::RAModel< SortPolicy >::SampleAtLeaves ( )

Modify whether or not sampling is done at the leaves.

template<typename SortPolicy >
void mlpack::neighbor::RAModel< SortPolicy >::Search ( arma::mat &&  querySet,
const size_t  k,
arma::Mat< size_t > &  neighbors,
arma::mat &  distances 
)

Perform rank-approximate neighbor search, taking ownership of the query set.

template<typename SortPolicy >
void mlpack::neighbor::RAModel< SortPolicy >::Search ( const size_t  k,
arma::Mat< size_t > &  neighbors,
arma::mat &  distances 
)

Perform rank-approximate neighbor search, using the reference set as the query set.

template<typename SortPolicy >
template<typename Archive >
void mlpack::neighbor::RAModel< SortPolicy >::Serialize ( Archive &  ar,
const unsigned  int 
)

Serialize the model.

template<typename SortPolicy >
bool mlpack::neighbor::RAModel< SortPolicy >::SingleMode ( ) const

Get whether or not single-tree search is being used.

template<typename SortPolicy >
bool& mlpack::neighbor::RAModel< SortPolicy >::SingleMode ( )

Modify whether or not single-tree search is being used.

template<typename SortPolicy >
size_t mlpack::neighbor::RAModel< SortPolicy >::SingleSampleLimit ( ) const

Get the limit on the size of a node that can be approximated.

template<typename SortPolicy >
size_t& mlpack::neighbor::RAModel< SortPolicy >::SingleSampleLimit ( )

Modify the limit on the size of a node that can be approximation.

template<typename SortPolicy >
double mlpack::neighbor::RAModel< SortPolicy >::Tau ( ) const

Get the rank-approximation in percentile of the data.

template<typename SortPolicy >
double& mlpack::neighbor::RAModel< SortPolicy >::Tau ( )

Modify the rank-approximation in percentile of the data.

template<typename SortPolicy >
std::string mlpack::neighbor::RAModel< SortPolicy >::TreeName ( ) const

Get the name of the tree type.

template<typename SortPolicy >
TreeTypes mlpack::neighbor::RAModel< SortPolicy >::TreeType ( ) const

Get the type of tree being used.

template<typename SortPolicy >
TreeTypes& mlpack::neighbor::RAModel< SortPolicy >::TreeType ( )

Modify the type of tree being used.

Member Data Documentation

template<typename SortPolicy >
RAType<tree::StandardCoverTree>* mlpack::neighbor::RAModel< SortPolicy >::coverTreeRA
private

Non-NULL if the cover tree is used.

Definition at line 80 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::HilbertRTree>* mlpack::neighbor::RAModel< SortPolicy >::hilbertRTreeRA
private

Non-NULL if the Hilbert R tree is used.

Definition at line 88 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::KDTree>* mlpack::neighbor::RAModel< SortPolicy >::kdTreeRA
private

Non-NULL if the kd-tree is used.

Definition at line 78 of file ra_model.hpp.

template<typename SortPolicy >
size_t mlpack::neighbor::RAModel< SortPolicy >::leafSize
private

The leaf size of the tree being used (useful only for the kd-tree).

Definition at line 61 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::Octree>* mlpack::neighbor::RAModel< SortPolicy >::octreeRA
private

Non-NULL if the octree is used.

Definition at line 96 of file ra_model.hpp.

template<typename SortPolicy >
arma::mat mlpack::neighbor::RAModel< SortPolicy >::q
private

The basis to project into.

Definition at line 66 of file ra_model.hpp.

template<typename SortPolicy >
bool mlpack::neighbor::RAModel< SortPolicy >::randomBasis
private

If true, randomly project into a new basis.

Definition at line 64 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::RPlusPlusTree>* mlpack::neighbor::RAModel< SortPolicy >::rPlusPlusTreeRA
private

Non-NULL if the R++ tree is used.

Definition at line 92 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::RPlusTree>* mlpack::neighbor::RAModel< SortPolicy >::rPlusTreeRA
private

Non-NULL if the R+ tree is used.

Definition at line 90 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::RStarTree>* mlpack::neighbor::RAModel< SortPolicy >::rStarTreeRA
private

Non-NULL if the R* tree is used.

Definition at line 84 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::RTree>* mlpack::neighbor::RAModel< SortPolicy >::rTreeRA
private

Non-NULL if the R tree is used.

Definition at line 82 of file ra_model.hpp.

template<typename SortPolicy >
TreeTypes mlpack::neighbor::RAModel< SortPolicy >::treeType
private

The type of tree being used.

Definition at line 59 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::UBTree>* mlpack::neighbor::RAModel< SortPolicy >::ubTreeRA
private

Non-NULL if the UB tree is used.

Definition at line 94 of file ra_model.hpp.

template<typename SortPolicy >
RAType<tree::XTree>* mlpack::neighbor::RAModel< SortPolicy >::xTreeRA
private

Non-NULL if the X tree is used.

Definition at line 86 of file ra_model.hpp.


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