NSModel< SortPolicy > Class Template Reference

The NSModel class provides an easy way to serialize a model, abstracts away the different types of trees, and also reflects the NeighborSearch API. More...

Public Types

enum  TreeTypes
{
  KD_TREE
,
  COVER_TREE
,
  R_TREE
,
  R_STAR_TREE
,
  BALL_TREE
,
  X_TREE
,
  HILBERT_R_TREE
,
  R_PLUS_TREE
,
  R_PLUS_PLUS_TREE
,
  VP_TREE
,
  RP_TREE
,
  MAX_RP_TREE
,
  SPILL_TREE
,
  UB_TREE
,
  OCTREE

}
 Enum type to identify each accepted tree type. More...

 

Public Member Functions

 NSModel (TreeTypes treeType=TreeTypes::KD_TREE, bool randomBasis=false)
 Initialize the NSModel with the given type and whether or not a random basis should be used. More...

 
 NSModel (const NSModel &other)
 Copy the given NSModel. More...

 
 NSModel (NSModel &&other)
 Take ownership of the given NSModel. More...

 
 ~NSModel ()
 Clean memory, if necessary. More...

 
void BuildModel (util::Timers &timers, arma::mat &&referenceSet, const NeighborSearchMode searchMode, const double epsilon=0)
 Build the reference tree. More...

 
const arma::mat & Dataset () const
 Expose the dataset. More...

 
double Epsilon () const
 Expose Epsilon. More...

 
double & Epsilon ()
 
void InitializeModel (const NeighborSearchMode searchMode, const double epsilon)
 Initialize the model type. (This does not perform any training.) More...

 
size_t LeafSize () const
 Expose LeafSize. More...

 
size_t & LeafSize ()
 
NSModeloperator= (const NSModel &other)
 Copy the given NSModel. More...

 
NSModeloperator= (NSModel &&other)
 Take ownership of the given NSModel. More...

 
bool RandomBasis () const
 Expose randomBasis. More...

 
bool & RandomBasis ()
 
double Rho () const
 Expose Rho. More...

 
double & Rho ()
 
void Search (util::Timers &timers, arma::mat &&querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
 Perform neighbor search. The query set will be reordered. More...

 
void Search (util::Timers &timers, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
 Perform monochromatic neighbor search. More...

 
NeighborSearchMode SearchMode () const
 Expose SearchMode. More...

 
NeighborSearchModeSearchMode ()
 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialize the neighbor search model. More...

 
double Tau () const
 Expose Tau. More...

 
double & Tau ()
 
std::string TreeName () const
 Return a string representation of the current tree type. More...

 
TreeTypes TreeType () const
 Expose treeType. More...

 
TreeTypesTreeType ()
 

Detailed Description


template
<
typename
SortPolicy
>

class mlpack::neighbor::NSModel< SortPolicy >

The NSModel class provides an easy way to serialize a model, abstracts away the different types of trees, and also reflects the NeighborSearch API.

This class is meant to be used by the command-line mlpack_knn and mlpack_kfn programs, and thus does not have the same complete functionality and flexibility as the NeighborSearch class. So if you are using it outside of mlpack_knn and mlpack_kfn, be aware that it is limited!

Template Parameters
SortPolicyThe sort policy for distances; see NearestNeighborSort.

Definition at line 343 of file ns_model.hpp.

Member Enumeration Documentation

◆ TreeTypes

enum TreeTypes

Enum type to identify each accepted tree type.

Enumerator
KD_TREE 
COVER_TREE 
R_TREE 
R_STAR_TREE 
BALL_TREE 
X_TREE 
HILBERT_R_TREE 
R_PLUS_TREE 
R_PLUS_PLUS_TREE 
VP_TREE 
RP_TREE 
MAX_RP_TREE 
SPILL_TREE 
UB_TREE 
OCTREE 

Definition at line 347 of file ns_model.hpp.

Constructor & Destructor Documentation

◆ NSModel() [1/3]

NSModel ( TreeTypes  treeType = TreeTypes::KD_TREE,
bool  randomBasis = false 
)

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

Parameters
treeTypeType of tree to use.
randomBasisWhether or not to project the points onto a random basis before searching.

◆ NSModel() [2/3]

NSModel ( const NSModel< SortPolicy > &  other)

Copy the given NSModel.

Parameters
otherModel to copy.

◆ NSModel() [3/3]

NSModel ( NSModel< SortPolicy > &&  other)

Take ownership of the given NSModel.

Parameters
otherModel to take ownership of.

◆ ~NSModel()

~NSModel ( )

Clean memory, if necessary.

Member Function Documentation

◆ BuildModel()

void BuildModel ( util::Timers timers,
arma::mat &&  referenceSet,
const NeighborSearchMode  searchMode,
const double  epsilon = 0 
)

Build the reference tree.

◆ Dataset()

const arma::mat& Dataset ( ) const

Expose the dataset.

◆ Epsilon() [1/2]

double Epsilon ( ) const

Expose Epsilon.

◆ Epsilon() [2/2]

double& Epsilon ( )

◆ InitializeModel()

void InitializeModel ( const NeighborSearchMode  searchMode,
const double  epsilon 
)

Initialize the model type. (This does not perform any training.)

◆ LeafSize() [1/2]

size_t LeafSize ( ) const
inline

Expose LeafSize.

Definition at line 439 of file ns_model.hpp.

◆ LeafSize() [2/2]

size_t& LeafSize ( )
inline

Definition at line 440 of file ns_model.hpp.

◆ operator=() [1/2]

NSModel& operator= ( const NSModel< SortPolicy > &  other)

Copy the given NSModel.

Parameters
otherModel to copy.

◆ operator=() [2/2]

NSModel& operator= ( NSModel< SortPolicy > &&  other)

Take ownership of the given NSModel.

Parameters
otherModel to take ownership of.

◆ RandomBasis() [1/2]

bool RandomBasis ( ) const
inline

Expose randomBasis.

Definition at line 459 of file ns_model.hpp.

◆ RandomBasis() [2/2]

bool& RandomBasis ( )
inline

Definition at line 460 of file ns_model.hpp.

References NSWrapperBase::Search().

◆ Rho() [1/2]

double Rho ( ) const
inline

Expose Rho.

Definition at line 447 of file ns_model.hpp.

◆ Rho() [2/2]

double& Rho ( )
inline

Definition at line 448 of file ns_model.hpp.

References NSWrapperBase::Epsilon().

◆ Search() [1/2]

void Search ( util::Timers timers,
arma::mat &&  querySet,
const size_t  k,
arma::Mat< size_t > &  neighbors,
arma::mat &  distances 
)

Perform neighbor search. The query set will be reordered.

◆ Search() [2/2]

void Search ( util::Timers timers,
const size_t  k,
arma::Mat< size_t > &  neighbors,
arma::mat &  distances 
)

Perform monochromatic neighbor search.

◆ SearchMode() [1/2]

NeighborSearchMode SearchMode ( ) const

Expose SearchMode.

◆ SearchMode() [2/2]

NeighborSearchMode& SearchMode ( )

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

Serialize the neighbor search model.

◆ Tau() [1/2]

double Tau ( ) const
inline

Expose Tau.

Definition at line 443 of file ns_model.hpp.

◆ Tau() [2/2]

double& Tau ( )
inline

Definition at line 444 of file ns_model.hpp.

◆ TreeName()

std::string TreeName ( ) const

Return a string representation of the current tree type.

◆ TreeType() [1/2]

TreeTypes TreeType ( ) const
inline

Expose treeType.

Definition at line 455 of file ns_model.hpp.

◆ TreeType() [2/2]

TreeTypes& TreeType ( )
inline

Definition at line 456 of file ns_model.hpp.


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/neighbor_search/ns_model.hpp