mlpack
|
Interface for generating distance based constraints on a given dataset, provided corresponding true labels and a quantity parameter (k) are specified. More...
#include <constraints.hpp>
Public Types | |
typedef neighbor::NeighborSearch< neighbor::NearestNeighborSort, MetricType > | KNN |
Convenience typedef. | |
Public Member Functions | |
Constraints (const arma::mat &dataset, const arma::Row< size_t > &labels, const size_t k) | |
Constructor for creating a Constraints instance. More... | |
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. More... | |
void | TargetNeighbors (arma::Mat< size_t > &outputMatrix, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms, const size_t begin, const size_t batchSize) |
Calculates k similar labeled nearest neighbors for a batch of dataset and stores them into the passed matrix. More... | |
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 matrix. More... | |
void | Impostors (arma::Mat< size_t > &outputNeighbors, arma::mat &outputDistance, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms) |
Calculates k differently labeled nearest neighbors & distances to impostors for each datapoint and writes them back to passed matrices. More... | |
void | Impostors (arma::Mat< size_t > &outputMatrix, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms, const size_t begin, const size_t batchSize) |
Calculates k differently labeled nearest neighbors for a batch of dataset and writes them back to passed matrix. More... | |
void | Impostors (arma::Mat< size_t > &outputNeighbors, arma::mat &outputDistance, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms, const size_t begin, const size_t batchSize) |
Calculates k differently labeled nearest neighbors & distances to impostors for a batch of dataset and writes them back to passed matrices. More... | |
void | Impostors (arma::Mat< size_t > &outputNeighbors, arma::mat &outputDistance, const arma::mat &dataset, const arma::Row< size_t > &labels, const arma::vec &norms, const arma::uvec &points, const size_t numPoints) |
Calculates k differently labeled nearest neighbors & distances to impostors for some points of dataset and writes them back to passed matrices. More... | |
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. More... | |
const size_t & | K () const |
Get the number of target neighbors (k). | |
size_t & | K () |
Modify the number of target neighbors (k). | |
const bool & | PreCalulated () const |
Access the boolean value of precalculated. | |
bool & | PreCalulated () |
Modify the value of precalculated. | |
Interface for generating distance based constraints on a given dataset, provided corresponding true labels and a quantity parameter (k) are specified.
Class provides TargetNeighbors() (Used for calculating target neighbors of each data point), Impostors() (used for calculating impostors of each data point) and Triplets() (Generates sets of {dataset, target neighbors, impostors} tripltets.)
mlpack::lmnn::Constraints< MetricType >::Constraints | ( | const arma::mat & | dataset, |
const arma::Row< size_t > & | labels, | ||
const size_t | k | ||
) |
Constructor for creating a Constraints instance.
dataset | Input dataset. |
labels | Input dataset labels. |
k | Number of target neighbors, impostors & triplets. |
void mlpack::lmnn::Constraints< MetricType >::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 matrix.
outputMatrix | Coordinates matrix to store impostors. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
void mlpack::lmnn::Constraints< MetricType >::Impostors | ( | arma::Mat< size_t > & | outputNeighbors, |
arma::mat & | outputDistance, | ||
const arma::mat & | dataset, | ||
const arma::Row< size_t > & | labels, | ||
const arma::vec & | norms | ||
) |
Calculates k differently labeled nearest neighbors & distances to impostors for each datapoint and writes them back to passed matrices.
outputNeighbors | Coordinates matrix to store impostors. |
outputDistance | matrix to store distance. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
void mlpack::lmnn::Constraints< MetricType >::Impostors | ( | arma::Mat< size_t > & | outputMatrix, |
const arma::mat & | dataset, | ||
const arma::Row< size_t > & | labels, | ||
const arma::vec & | norms, | ||
const size_t | begin, | ||
const size_t | batchSize | ||
) |
Calculates k differently labeled nearest neighbors for a batch of dataset and writes them back to passed matrix.
outputMatrix | Coordinates matrix to store impostors. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
begin | Index of the initial point of dataset. |
batchSize | Number of data points to use. |
void mlpack::lmnn::Constraints< MetricType >::Impostors | ( | arma::Mat< size_t > & | outputNeighbors, |
arma::mat & | outputDistance, | ||
const arma::mat & | dataset, | ||
const arma::Row< size_t > & | labels, | ||
const arma::vec & | norms, | ||
const size_t | begin, | ||
const size_t | batchSize | ||
) |
Calculates k differently labeled nearest neighbors & distances to impostors for a batch of dataset and writes them back to passed matrices.
outputNeighbors | Coordinates matrix to store impostors. |
outputDistance | matrix to store distance. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
begin | Index of the initial point of dataset. |
batchSize | Number of data points to use. |
void mlpack::lmnn::Constraints< MetricType >::Impostors | ( | arma::Mat< size_t > & | outputNeighbors, |
arma::mat & | outputDistance, | ||
const arma::mat & | dataset, | ||
const arma::Row< size_t > & | labels, | ||
const arma::vec & | norms, | ||
const arma::uvec & | points, | ||
const size_t | numPoints | ||
) |
Calculates k differently labeled nearest neighbors & distances to impostors for some points of dataset and writes them back to passed matrices.
outputNeighbors | Coordinates matrix to store impostors. |
outputDistance | matrix to store distance. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
points | Indices of data points to calculate impostors on. |
numPoints | Number of points to actually calculate impostors on. |
void mlpack::lmnn::Constraints< MetricType >::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.
outputMatrix | Coordinates matrix to store target neighbors. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
void mlpack::lmnn::Constraints< MetricType >::TargetNeighbors | ( | arma::Mat< size_t > & | outputMatrix, |
const arma::mat & | dataset, | ||
const arma::Row< size_t > & | labels, | ||
const arma::vec & | norms, | ||
const size_t | begin, | ||
const size_t | batchSize | ||
) |
Calculates k similar labeled nearest neighbors for a batch of dataset and stores them into the passed matrix.
outputMatrix | Coordinates matrix to store target neighbors. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |
begin | Index of the initial point of dataset. |
batchSize | Number of data points to use. |
void mlpack::lmnn::Constraints< MetricType >::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.
outputMatrix | Coordinates matrix to store triplets. |
dataset | Input dataset. |
labels | Input dataset labels. |
norms | Input dataset norms. |