Constraints< MetricType > Class Template Reference

Interface for generating distance based constraints on a given dataset, provided corresponding true labels and a quantity parameter (k) are specified. More...

Public Types

typedef neighbor::NeighborSearch< neighbor::NearestNeighborSort, MetricType > KNN
 Convenience typedef. More...

 

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 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...

 
const size_t & K () const
 Get the number of target neighbors (k). More...

 
size_t & K ()
 Modify the number of target neighbors (k). More...

 
const bool & PreCalulated () const
 Access the boolean value of precalculated. More...

 
bool & PreCalulated ()
 Modify the value of precalculated. 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 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...

 

Detailed Description


template
<
typename
MetricType
=
metric::SquaredEuclideanDistance
>

class mlpack::lmnn::Constraints< MetricType >

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.)

Definition at line 31 of file constraints.hpp.

Member Typedef Documentation

◆ KNN

Convenience typedef.

Definition at line 36 of file constraints.hpp.

Constructor & Destructor Documentation

◆ Constraints()

Constraints ( const arma::mat &  dataset,
const arma::Row< size_t > &  labels,
const size_t  k 
)

Constructor for creating a Constraints instance.

Parameters
datasetInput dataset.
labelsInput dataset labels.
kNumber of target neighbors, impostors & triplets.

Member Function Documentation

◆ Impostors() [1/5]

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.

Parameters
outputMatrixCoordinates matrix to store impostors.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.

◆ Impostors() [2/5]

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.

Parameters
outputNeighborsCoordinates matrix to store impostors.
outputDistancematrix to store distance.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.

◆ Impostors() [3/5]

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.

Parameters
outputMatrixCoordinates matrix to store impostors.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.
beginIndex of the initial point of dataset.
batchSizeNumber of data points to use.

◆ Impostors() [4/5]

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.

Parameters
outputNeighborsCoordinates matrix to store impostors.
outputDistancematrix to store distance.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.
beginIndex of the initial point of dataset.
batchSizeNumber of data points to use.

◆ Impostors() [5/5]

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.

Parameters
outputNeighborsCoordinates matrix to store impostors.
outputDistancematrix to store distance.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.
pointsIndices of data points to calculate impostors on.
numPointsNumber of points to actually calculate impostors on.

◆ K() [1/2]

const size_t& K ( ) const
inline

Get the number of target neighbors (k).

Definition at line 185 of file constraints.hpp.

◆ K() [2/2]

size_t& K ( )
inline

Modify the number of target neighbors (k).

Definition at line 187 of file constraints.hpp.

◆ PreCalulated() [1/2]

const bool& PreCalulated ( ) const
inline

Access the boolean value of precalculated.

Definition at line 190 of file constraints.hpp.

◆ PreCalulated() [2/2]

bool& PreCalulated ( )
inline

Modify the value of precalculated.

Definition at line 192 of file constraints.hpp.

◆ TargetNeighbors() [1/2]

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.

Parameters
outputMatrixCoordinates matrix to store target neighbors.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.

◆ TargetNeighbors() [2/2]

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.

Parameters
outputMatrixCoordinates matrix to store target neighbors.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.
beginIndex of the initial point of dataset.
batchSizeNumber of data points to use.

◆ Triplets()

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.

Parameters
outputMatrixCoordinates matrix to store triplets.
datasetInput dataset.
labelsInput dataset labels.
normsInput dataset norms.

The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/lmnn/constraints.hpp