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 () |
| NSModel & | operator= (const NSModel &other) |
| Copy the given NSModel. More... | |
| NSModel & | operator= (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... | |
| NeighborSearchMode & | SearchMode () |
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... | |
| TreeTypes & | TreeType () |
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!
| SortPolicy | The sort policy for distances; see NearestNeighborSort. |
Definition at line 343 of file ns_model.hpp.
| 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.
Initialize the NSModel with the given type and whether or not a random basis should be used.
| treeType | Type of tree to use. |
| randomBasis | Whether or not to project the points onto a random basis before searching. |
Copy the given NSModel.
| other | Model to copy. |
Take ownership of the given NSModel.
| other | Model to take ownership of. |
| ~NSModel | ( | ) |
Clean memory, if necessary.
| void BuildModel | ( | util::Timers & | timers, |
| arma::mat && | referenceSet, | ||
| 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 | ( | ) |
| void InitializeModel | ( | const NeighborSearchMode | searchMode, |
| const double | epsilon | ||
| ) |
Initialize the model type. (This does not perform any training.)
|
inline |
Expose LeafSize.
Definition at line 439 of file ns_model.hpp.
|
inline |
Definition at line 440 of file ns_model.hpp.
Copy the given NSModel.
| other | Model to copy. |
Take ownership of the given NSModel.
| other | Model to take ownership of. |
|
inline |
Expose randomBasis.
Definition at line 459 of file ns_model.hpp.
|
inline |
Definition at line 460 of file ns_model.hpp.
References NSWrapperBase::Search().
|
inline |
Expose Rho.
Definition at line 447 of file ns_model.hpp.
|
inline |
Definition at line 448 of file ns_model.hpp.
References NSWrapperBase::Epsilon().
| 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.
| void Search | ( | util::Timers & | timers, |
| const size_t | k, | ||
| arma::Mat< size_t > & | neighbors, | ||
| arma::mat & | distances | ||
| ) |
Perform monochromatic neighbor search.
| NeighborSearchMode SearchMode | ( | ) | const |
Expose SearchMode.
| NeighborSearchMode& SearchMode | ( | ) |
| void serialize | ( | Archive & | ar, |
| const uint32_t | |||
| ) |
Serialize the neighbor search model.
|
inline |
Expose Tau.
Definition at line 443 of file ns_model.hpp.
|
inline |
Definition at line 444 of file ns_model.hpp.
| std::string TreeName | ( | ) | const |
Return a string representation of the current tree type.
|
inline |
Expose treeType.
Definition at line 455 of file ns_model.hpp.
|
inline |
Definition at line 456 of file ns_model.hpp.