mlpack
master
|
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 () |
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 (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... | |
NeighborSearchMode & | SearchMode () |
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... | |
TreeTypes & | TreeType () |
Private Attributes | |
size_t | leafSize |
For tree types that accept the maxLeafSize parameter. More... | |
boost::variant< NSType< SortPolicy, tree::KDTree > *, NSType< SortPolicy, tree::StandardCoverTree > *, NSType< SortPolicy, tree::RTree > *, NSType< SortPolicy, tree::RStarTree > *, NSType< SortPolicy, tree::BallTree > *, NSType< SortPolicy, tree::XTree > *, NSType< SortPolicy, tree::HilbertRTree > *, NSType< SortPolicy, tree::RPlusTree > *, NSType< SortPolicy, tree::RPlusPlusTree > *, NSType< SortPolicy, tree::VPTree > *, NSType< SortPolicy, tree::RPTree > *, NSType< SortPolicy, tree::MaxRPTree > *, SpillKNN *, NSType< SortPolicy, tree::UBTree > *, NSType< SortPolicy, tree::Octree > * > | nSearch |
nSearch holds an instance of the NeigborSearch class for the current treeType. More... | |
arma::mat | q |
This is the random projection matrix; only used if randomBasis is true. More... | |
bool | randomBasis |
If true, random projections are used. More... | |
double | rho |
Balance threshold (for spill trees). More... | |
double | tau |
Overlapping size (for spill trees). More... | |
TreeTypes | treeType |
Tree type considered for neighbor search. More... | |
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 266 of file ns_model.hpp.
enum mlpack::neighbor::NSModel::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 270 of file ns_model.hpp.
mlpack::neighbor::NSModel< SortPolicy >::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.
treeType | Type of tree to use. |
randomBasis | Whether or not to project the points onto a random basis before searching. |
mlpack::neighbor::NSModel< SortPolicy >::NSModel | ( | const NSModel< SortPolicy > & | other | ) |
Copy the given NSModel.
other | Model to copy. |
mlpack::neighbor::NSModel< SortPolicy >::NSModel | ( | NSModel< SortPolicy > && | other | ) |
Take ownership of the given NSModel.
other | Model to take ownership of. |
mlpack::neighbor::NSModel< SortPolicy >::~NSModel | ( | ) |
Clean memory, if necessary.
void mlpack::neighbor::NSModel< SortPolicy >::BuildModel | ( | arma::mat && | referenceSet, |
const size_t | leafSize, | ||
const NeighborSearchMode | searchMode, | ||
const double | epsilon = 0 |
||
) |
Build the reference tree.
const arma::mat& mlpack::neighbor::NSModel< SortPolicy >::Dataset | ( | ) | const |
Expose the dataset.
double mlpack::neighbor::NSModel< SortPolicy >::Epsilon | ( | ) | const |
Expose Epsilon.
double& mlpack::neighbor::NSModel< SortPolicy >::Epsilon | ( | ) |
|
inline |
Expose leafSize.
Definition at line 385 of file ns_model.hpp.
|
inline |
Definition at line 386 of file ns_model.hpp.
NSModel& mlpack::neighbor::NSModel< SortPolicy >::operator= | ( | const NSModel< SortPolicy > & | other | ) |
Copy the given NSModel.
other | Model to copy. |
NSModel& mlpack::neighbor::NSModel< SortPolicy >::operator= | ( | NSModel< SortPolicy > && | other | ) |
Take ownership of the given NSModel.
other | Model to take ownership of. |
|
inline |
Expose randomBasis.
Definition at line 401 of file ns_model.hpp.
|
inline |
Definition at line 402 of file ns_model.hpp.
References BOOST_TEMPLATE_CLASS_VERSION(), and string().
|
inline |
Expose rho.
Definition at line 393 of file ns_model.hpp.
|
inline |
Definition at line 394 of file ns_model.hpp.
void mlpack::neighbor::NSModel< SortPolicy >::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 mlpack::neighbor::NSModel< SortPolicy >::Search | ( | const size_t | k, |
arma::Mat< size_t > & | neighbors, | ||
arma::mat & | distances | ||
) |
Perform monochromatic neighbor search.
NeighborSearchMode mlpack::neighbor::NSModel< SortPolicy >::SearchMode | ( | ) | const |
Expose SearchMode.
NeighborSearchMode& mlpack::neighbor::NSModel< SortPolicy >::SearchMode | ( | ) |
void mlpack::neighbor::NSModel< SortPolicy >::Serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the neighbor search model.
|
inline |
Expose tau.
Definition at line 389 of file ns_model.hpp.
|
inline |
Definition at line 390 of file ns_model.hpp.
std::string mlpack::neighbor::NSModel< SortPolicy >::TreeName | ( | ) | const |
Return a string representation of the current tree type.
|
inline |
Expose treeType.
Definition at line 397 of file ns_model.hpp.
|
inline |
Definition at line 398 of file ns_model.hpp.
|
private |
For tree types that accept the maxLeafSize parameter.
Definition at line 294 of file ns_model.hpp.
|
private |
nSearch holds an instance of the NeigborSearch class for the current treeType.
It is initialized every time BuildModel is executed. We access to the contained value through the visitor classes defined above.
Definition at line 325 of file ns_model.hpp.
|
private |
This is the random projection matrix; only used if randomBasis is true.
Definition at line 304 of file ns_model.hpp.
|
private |
If true, random projections are used.
Definition at line 302 of file ns_model.hpp.
|
private |
Balance threshold (for spill trees).
Definition at line 299 of file ns_model.hpp.
|
private |
Overlapping size (for spill trees).
Definition at line 297 of file ns_model.hpp.
|
private |
Tree type considered for neighbor search.
Definition at line 291 of file ns_model.hpp.