12 #ifndef MLPACK_METHODS_LMNN_CONSTRAINTS_HPP 13 #define MLPACK_METHODS_LMNN_CONSTRAINTS_HPP 30 template<
typename MetricType = metric::SquaredEucl
ideanDistance>
46 const arma::Row<size_t>& labels,
59 const arma::mat& dataset,
60 const arma::Row<size_t>& labels,
61 const arma::vec& norms);
75 const arma::mat& dataset,
76 const arma::Row<size_t>& labels,
77 const arma::vec& norms,
79 const size_t batchSize);
90 void Impostors(arma::Mat<size_t>& outputMatrix,
91 const arma::mat& dataset,
92 const arma::Row<size_t>& labels,
93 const arma::vec& norms);
105 void Impostors(arma::Mat<size_t>& outputNeighbors,
106 arma::mat& outputDistance,
107 const arma::mat& dataset,
108 const arma::Row<size_t>& labels,
109 const arma::vec& norms);
122 void Impostors(arma::Mat<size_t>& outputMatrix,
123 const arma::mat& dataset,
124 const arma::Row<size_t>& labels,
125 const arma::vec& norms,
127 const size_t batchSize);
141 void Impostors(arma::Mat<size_t>& outputNeighbors,
142 arma::mat& outputDistance,
143 const arma::mat& dataset,
144 const arma::Row<size_t>& labels,
145 const arma::vec& norms,
147 const size_t batchSize);
162 void Impostors(arma::Mat<size_t>& outputNeighbors,
163 arma::mat& outputDistance,
164 const arma::mat& dataset,
165 const arma::Row<size_t>& labels,
166 const arma::vec& norms,
167 const arma::uvec& points,
168 const size_t numPoints);
179 void Triplets(arma::Mat<size_t>& outputMatrix,
180 const arma::mat& dataset,
181 const arma::Row<size_t>& labels,
182 const arma::vec& norms);
185 const size_t&
K()
const {
return k; }
187 size_t&
K() {
return k; }
199 arma::Row<size_t> uniqueLabels;
202 std::vector<arma::uvec> indexSame;
205 std::vector<arma::uvec> indexDiff;
214 inline void Precalculate(
const arma::Row<size_t>& labels);
220 inline void ReorderResults(
const arma::mat& distances,
221 arma::Mat<size_t>& neighbors,
222 const arma::vec& norms);
229 #include "constraints_impl.hpp" Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
The NeighborSearch class is a template class for performing distance-based neighbor searches...
const size_t & K() const
Get the number of target neighbors (k).
void Impostors(arma::Mat< size_t > &outputMatrix, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms)
Calculates k differently labeled nearest neighbors for each datapoint and writes them back to passed ...
Interface for generating distance based constraints on a given dataset, provided corresponding true l...
neighbor::NeighborSearch< neighbor::NearestNeighborSort, MetricType > KNN
Convenience typedef.
bool & PreCalulated()
Modify the value of precalculated.
void Triplets(arma::Mat< size_t > &outputMatrix, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms)
Generate triplets {i, j, l} for each datapoint i and writes back generated triplets to matrix passed...
void TargetNeighbors(arma::Mat< size_t > &outputMatrix, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms)
Calculates k similar labeled nearest neighbors and stores them into the passed matrix.
Constraints(const arma::mat &dataset, const arma::Row< size_t > &labels, const size_t k)
Constructor for creating a Constraints instance.
size_t & K()
Modify the number of target neighbors (k).
const bool & PreCalulated() const
Access the boolean value of precalculated.