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 (arma::mat &&referenceSet, const size_t leafSize, 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 ()
 
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 (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 (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 unsigned int)
 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 248 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 252 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 ( arma::mat &&  referenceSet,
const size_t  leafSize,
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 ( )

◆ LeafSize() [1/2]

size_t LeafSize ( ) const
inline

Expose leafSize.

Definition at line 367 of file ns_model.hpp.

◆ LeafSize() [2/2]

size_t& LeafSize ( )
inline

Definition at line 368 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 383 of file ns_model.hpp.

◆ RandomBasis() [2/2]

bool& RandomBasis ( )
inline

Definition at line 384 of file ns_model.hpp.

References BOOST_TEMPLATE_CLASS_VERSION().

◆ Rho() [1/2]

double Rho ( ) const
inline

Expose rho.

Definition at line 375 of file ns_model.hpp.

◆ Rho() [2/2]

double& Rho ( )
inline

Definition at line 376 of file ns_model.hpp.

◆ Search() [1/2]

void Search ( 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 ( 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 unsigned  int 
)

Serialize the neighbor search model.

◆ Tau() [1/2]

double Tau ( ) const
inline

Expose tau.

Definition at line 371 of file ns_model.hpp.

◆ Tau() [2/2]

double& Tau ( )
inline

Definition at line 372 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 379 of file ns_model.hpp.

◆ TreeType() [2/2]

TreeTypes& TreeType ( )
inline

Definition at line 380 of file ns_model.hpp.


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