mlpack 3.4.2
qdafn.hpp
Go to the documentation of this file.
1
24#ifndef MLPACK_METHODS_APPROX_KFN_QDAFN_HPP
25#define MLPACK_METHODS_APPROX_KFN_QDAFN_HPP
26
27#include <mlpack/prereqs.hpp>
29
30namespace mlpack {
31namespace neighbor {
32
33template<typename MatType = arma::mat>
34class QDAFN
35{
36 public:
44 QDAFN(const size_t l, const size_t m);
45
54 QDAFN(const MatType& referenceSet,
55 const size_t l,
56 const size_t m);
57
67 void Train(const MatType& referenceSet,
68 const size_t l = 0,
69 const size_t m = 0);
70
77 void Search(const MatType& querySet,
78 const size_t k,
79 arma::Mat<size_t>& neighbors,
80 arma::mat& distances);
81
83 template<typename Archive>
84 void serialize(Archive& ar, const unsigned int /* version */);
85
87 size_t NumProjections() const { return candidateSet.size(); }
88
90 const MatType& CandidateSet(const size_t t) const { return candidateSet[t]; }
92 MatType& CandidateSet(const size_t t) { return candidateSet[t]; }
93
94 private:
96 size_t l;
98 size_t m;
100 arma::mat lines;
102 arma::mat projections;
103
105 arma::Mat<size_t> sIndices;
107 arma::mat sValues;
108
109 // Candidate sets; one element in the vector for each table.
110 std::vector<MatType> candidateSet;
111};
112
113} // namespace neighbor
114} // namespace mlpack
115
116// Include implementation.
117#include "qdafn_impl.hpp"
118
119#endif
QDAFN(const MatType &referenceSet, const size_t l, const size_t m)
Construct the QDAFN object with the given reference set (this is the set that will be searched).
void Train(const MatType &referenceSet, const size_t l=0, const size_t m=0)
Train the QDAFN model on the given reference set, optionally setting new parameters for the number of...
void Search(const MatType &querySet, const size_t k, arma::Mat< size_t > &neighbors, arma::mat &distances)
Search for the k furthest neighbors of the given query set.
size_t NumProjections() const
Get the number of projections.
Definition: qdafn.hpp:87
MatType & CandidateSet(const size_t t)
Modify the candidate set for the given projection table. Careful!
Definition: qdafn.hpp:92
QDAFN(const size_t l, const size_t m)
Construct the QDAFN object but do not train it.
const MatType & CandidateSet(const size_t t) const
Get the candidate set for the given projection table.
Definition: qdafn.hpp:90
void serialize(Archive &ar, const unsigned int)
Serialize the model.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.