mlpack  master
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 
30 namespace mlpack {
31 namespace neighbor {
32 
33 template<typename MatType = arma::mat>
34 class 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
const MatType & CandidateSet(const size_t t) const
Get the candidate set for the given projection table.
Definition: qdafn.hpp:90
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
MatType & CandidateSet(const size_t t)
Modify the candidate set for the given projection table. Careful!
Definition: qdafn.hpp:92
size_t m
The number of elements to store for each projection.
Definition: qdafn.hpp:98
arma::mat lines
The random lines we are projecting onto. Has l columns.
Definition: qdafn.hpp:100
The core includes that mlpack expects; standard C++ includes and Armadillo.
QDAFN(const size_t l, const size_t m)
Construct the QDAFN object but do not train it.
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.
arma::Mat< size_t > sIndices
Indices of the points for each S.
Definition: qdafn.hpp:105
size_t NumProjections() const
Get the number of projections.
Definition: qdafn.hpp:87
std::vector< MatType > candidateSet
Definition: qdafn.hpp:110
void Serialize(Archive &ar, const unsigned int)
Serialize the model.
arma::mat sValues
Values of a_i * x for each point in S.
Definition: qdafn.hpp:107
size_t l
The number of projections.
Definition: qdafn.hpp:96
arma::mat projections
Projections of each point onto each random line.
Definition: qdafn.hpp:102
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...