mlpack  2.0.1
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
mlpack::range::RSModel Class Reference

Public Types

enum  TreeTypes {
  KD_TREE,
  COVER_TREE,
  R_TREE,
  R_STAR_TREE,
  BALL_TREE
}
 

Public Member Functions

 RSModel (const int treeType=TreeTypes::KD_TREE, const bool randomBasis=false)
 Initialize the RSModel with the given type and whether or not a random basis should be used. More...
 
 ~RSModel ()
 Clean memory, if necessary. More...
 
void BuildModel (arma::mat &&referenceSet, const size_t leafSize, const bool naive, const bool singleMode)
 Build the reference tree on the given dataset with the given parameters. More...
 
const arma::mat & Dataset () const
 Expose the dataset. More...
 
size_t LeafSize () const
 Get the leaf size (applicable to everything but the cover tree). More...
 
size_t & LeafSize ()
 Modify the leaf size (applicable to everything but the cover tree). More...
 
bool Naive () const
 Get whether the model is in naive search mode. More...
 
bool & Naive ()
 Modify whether the model is in naive search mode. More...
 
bool RandomBasis () const
 Get whether a random basis is used. More...
 
bool & RandomBasis ()
 Modify whether a random basis is used (don't do this after the model has been built). More...
 
void Search (arma::mat &&querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances)
 Perform range search. More...
 
void Search (const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances)
 Perform monochromatic range search, with the reference set as the query set. More...
 
template<typename Archive >
void Serialize (Archive &ar, const unsigned int)
 Serialize the range search model. More...
 
bool SingleMode () const
 Get whether the model is in single-tree search mode. More...
 
bool & SingleMode ()
 Modify whether the model is in single-tree search mode. More...
 
int TreeType () const
 Get the type of tree. More...
 
int & TreeType ()
 Modify the type of tree (don't do this after the model has been built). More...
 

Private Types

template<template< typename TreeMetricType, typename TreeStatType, typename TreeMatType > class TreeType>
using RSType = RangeSearch< metric::EuclideanDistance, arma::mat, TreeType >
 The mostly-specified type of the range search model. More...
 

Private Member Functions

void CleanMemory ()
 Clean up memory. More...
 
std::string TreeName () const
 Return a string representing the name of the tree. More...
 

Private Attributes

RSType< tree::BallTree > * ballTreeRS
 Ball tree based range search object (NULL if not in use). More...
 
RSType< tree::StandardCoverTree > * coverTreeRS
 Cover tree based range search object (NULL if not in use). More...
 
RSType< tree::KDTree > * kdTreeRS
 kd-tree based range search object (NULL if not in use). More...
 
size_t leafSize
 
arma::mat q
 Random projection matrix. More...
 
bool randomBasis
 If true, we randomly project the data into a new basis before search. More...
 
RSType< tree::RStarTree > * rStarTreeRS
 R* tree based range search object (NULL if not in use). More...
 
RSType< tree::RTree > * rTreeRS
 R tree based range search object (NULL if not in use). More...
 
int treeType
 

Detailed Description

Definition at line 29 of file rs_model.hpp.

Member Typedef Documentation

◆ RSType

template<template< typename TreeMetricType, typename TreeStatType, typename TreeMatType > class TreeType>
using mlpack::range::RSModel::RSType = RangeSearch<metric::EuclideanDistance, arma::mat, TreeType>
private

The mostly-specified type of the range search model.

Definition at line 54 of file rs_model.hpp.

Member Enumeration Documentation

◆ TreeTypes

Enumerator
KD_TREE 
COVER_TREE 
R_TREE 
R_STAR_TREE 
BALL_TREE 

Definition at line 32 of file rs_model.hpp.

Constructor & Destructor Documentation

◆ RSModel()

mlpack::range::RSModel::RSModel ( const int  treeType = TreeTypes::KD_TREE,
const bool  randomBasis = false 
)

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

Parameters
treeTypeType of tree to use.
randomBasisWhether or not to use a random basis.

◆ ~RSModel()

mlpack::range::RSModel::~RSModel ( )

Clean memory, if necessary.

Member Function Documentation

◆ BuildModel()

void mlpack::range::RSModel::BuildModel ( arma::mat &&  referenceSet,
const size_t  leafSize,
const bool  naive,
const bool  singleMode 
)

Build the reference tree on the given dataset with the given parameters.

This takes possession of the reference set to avoid a copy.

Parameters
referenceSetSet of reference points.
leafSizeLeaf size of tree (ignored for the cover tree).
naiveWhether naive search should be used.
singleModeWhether single-tree search should be used.

Referenced by RandomBasis().

◆ CleanMemory()

void mlpack::range::RSModel::CleanMemory ( )
private

Clean up memory.

Referenced by RandomBasis().

◆ Dataset()

const arma::mat& mlpack::range::RSModel::Dataset ( ) const

Expose the dataset.

◆ LeafSize() [1/2]

size_t mlpack::range::RSModel::LeafSize ( ) const
inline

Get the leaf size (applicable to everything but the cover tree).

Definition at line 102 of file rs_model.hpp.

References leafSize.

◆ LeafSize() [2/2]

size_t& mlpack::range::RSModel::LeafSize ( )
inline

Modify the leaf size (applicable to everything but the cover tree).

Definition at line 104 of file rs_model.hpp.

References leafSize.

◆ Naive() [1/2]

bool mlpack::range::RSModel::Naive ( ) const

Get whether the model is in naive search mode.

◆ Naive() [2/2]

bool& mlpack::range::RSModel::Naive ( )

Modify whether the model is in naive search mode.

◆ RandomBasis() [1/2]

bool mlpack::range::RSModel::RandomBasis ( ) const
inline

Get whether a random basis is used.

Definition at line 112 of file rs_model.hpp.

References randomBasis.

◆ RandomBasis() [2/2]

bool& mlpack::range::RSModel::RandomBasis ( )
inline

Modify whether a random basis is used (don't do this after the model has been built).

Definition at line 115 of file rs_model.hpp.

References BuildModel(), CleanMemory(), randomBasis, Search(), and TreeName().

◆ Search() [1/2]

void mlpack::range::RSModel::Search ( arma::mat &&  querySet,
const math::Range range,
std::vector< std::vector< size_t >> &  neighbors,
std::vector< std::vector< double >> &  distances 
)

Perform range search.

This takes possession of the query set, so the query set will not be usable after the search. For more information on the output format, see RangeSearch<>::Search().

Parameters
querySetSet of query points.
rangeRange to search for.
neighborsOutput: neighbors falling within the desired range.
distancesOutput: distances of neighbors.

Referenced by RandomBasis().

◆ Search() [2/2]

void mlpack::range::RSModel::Search ( const math::Range range,
std::vector< std::vector< size_t >> &  neighbors,
std::vector< std::vector< double >> &  distances 
)

Perform monochromatic range search, with the reference set as the query set.

For more information on the output format, see RangeSearch<>::Search().

Parameters
rangeRange to search for.
neighborsOutput: neighbors falling within the desired range.
distancesOutput: distances of neighbors.

◆ Serialize()

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

Serialize the range search model.

◆ SingleMode() [1/2]

bool mlpack::range::RSModel::SingleMode ( ) const

Get whether the model is in single-tree search mode.

◆ SingleMode() [2/2]

bool& mlpack::range::RSModel::SingleMode ( )

Modify whether the model is in single-tree search mode.

◆ TreeName()

std::string mlpack::range::RSModel::TreeName ( ) const
private

Return a string representing the name of the tree.

This is used for logging output.

Referenced by RandomBasis().

◆ TreeType() [1/2]

int mlpack::range::RSModel::TreeType ( ) const
inline

Get the type of tree.

Definition at line 107 of file rs_model.hpp.

References treeType.

◆ TreeType() [2/2]

int& mlpack::range::RSModel::TreeType ( )
inline

Modify the type of tree (don't do this after the model has been built).

Definition at line 109 of file rs_model.hpp.

References treeType.

Member Data Documentation

◆ ballTreeRS

RSType<tree::BallTree>* mlpack::range::RSModel::ballTreeRS
private

Ball tree based range search object (NULL if not in use).

Definition at line 66 of file rs_model.hpp.

◆ coverTreeRS

RSType<tree::StandardCoverTree>* mlpack::range::RSModel::coverTreeRS
private

Cover tree based range search object (NULL if not in use).

Definition at line 60 of file rs_model.hpp.

◆ kdTreeRS

RSType<tree::KDTree>* mlpack::range::RSModel::kdTreeRS
private

kd-tree based range search object (NULL if not in use).

Definition at line 58 of file rs_model.hpp.

◆ leafSize

size_t mlpack::range::RSModel::leafSize
private

Definition at line 43 of file rs_model.hpp.

Referenced by LeafSize().

◆ q

arma::mat mlpack::range::RSModel::q
private

Random projection matrix.

Definition at line 48 of file rs_model.hpp.

◆ randomBasis

bool mlpack::range::RSModel::randomBasis
private

If true, we randomly project the data into a new basis before search.

Definition at line 46 of file rs_model.hpp.

Referenced by RandomBasis().

◆ rStarTreeRS

RSType<tree::RStarTree>* mlpack::range::RSModel::rStarTreeRS
private

R* tree based range search object (NULL if not in use).

Definition at line 64 of file rs_model.hpp.

◆ rTreeRS

RSType<tree::RTree>* mlpack::range::RSModel::rTreeRS
private

R tree based range search object (NULL if not in use).

Definition at line 62 of file rs_model.hpp.

◆ treeType

int mlpack::range::RSModel::treeType
private

Definition at line 42 of file rs_model.hpp.

Referenced by TreeType().


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