mlpack  2.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
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 ()
 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 ()
 
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
 Access the search mode. More...
 
template<typename Archive >
void Serialize (Archive &ar, const unsigned int)
 Serialize the neighbor search model. More...
 
void SetSearchMode (const NeighborSearchMode mode)
 Modify the search mode. 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 283 of file ns_model.hpp.

Member Enumeration Documentation

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 287 of file ns_model.hpp.

Constructor & Destructor Documentation

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.

~NSModel ( )

Clean memory, if necessary.

Member Function Documentation

void BuildModel ( arma::mat &&  referenceSet,
const size_t  leafSize,
const NeighborSearchMode  searchMode,
const double  epsilon = 0 
)

Build the reference tree.

const arma::mat& Dataset ( ) const

Expose the dataset.

double Epsilon ( ) const

Expose Epsilon.

double& Epsilon ( )
size_t LeafSize ( ) const
inline

Expose leafSize.

Definition at line 371 of file ns_model.hpp.

size_t& LeafSize ( )
inline

Definition at line 372 of file ns_model.hpp.

bool RandomBasis ( ) const
inline

Expose randomBasis.

Definition at line 387 of file ns_model.hpp.

bool& RandomBasis ( )
inline

Definition at line 388 of file ns_model.hpp.

double Rho ( ) const
inline

Expose rho.

Definition at line 379 of file ns_model.hpp.

double& Rho ( )
inline

Definition at line 380 of file ns_model.hpp.

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.

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

Perform monochromatic neighbor search.

NeighborSearchMode SearchMode ( ) const

Access the search mode.

void Serialize ( Archive &  ar,
const unsigned  int 
)

Serialize the neighbor search model.

void SetSearchMode ( const NeighborSearchMode  mode)

Modify the search mode.

double Tau ( ) const
inline

Expose tau.

Definition at line 375 of file ns_model.hpp.

double& Tau ( )
inline

Definition at line 376 of file ns_model.hpp.

std::string TreeName ( ) const

Return a string representation of the current tree type.

TreeTypes TreeType ( ) const
inline

Expose treeType.

Definition at line 383 of file ns_model.hpp.

TreeTypes& TreeType ( )
inline

Definition at line 384 of file ns_model.hpp.


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