SYNOPSIS

Public Member Functions

NCA (const arma::mat &dataset, const arma::Col< size_t > &labels, MetricType metric=MetricType())

Construct the Neighborhood Components Analysis object. const arma::mat & Dataset () const

Get the dataset reference. const arma::Col< size_t > & Labels () const

Get the labels reference. void LearnDistance (arma::mat &outputMatrix)

Perform Neighborhood Components Analysis. const OptimizerType

< SoftmaxErrorFunction

< MetricType > > & Optimizer () const "

Get the optimizer. OptimizerType

< SoftmaxErrorFunction

< MetricType > > & Optimizer ()"

std::string ToString () const

Private Attributes

const arma::mat & dataset

Dataset reference. SoftmaxErrorFunction< MetricType > errorFunction

The function to optimize. const arma::Col< size_t > & labels

Labels reference. MetricType metric

Metric to be used. OptimizerType

< SoftmaxErrorFunction

< MetricType > > optimizer"

The optimizer to use.

Detailed Description

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD>class mlpack::nca::NCA< MetricType, OptimizerType >

An implementation of Neighborhood Components Analysis, both a linear dimensionality reduction technique and a distance learning technique.

The method seeks to improve k-nearest-neighbor classification on a dataset by scaling the dimensions. The method is nonparametric, and does not require a value of k. It works by using stochastic ('soft') neighbor assignments and using optimization techniques over the gradient of the accuracy of the neighbor assignments.

For more details, see the following published paper:

@inproceedings{Goldberger2004,
  author = {Goldberger, Jacob and Roweis, Sam and Hinton, Geoff and
      Salakhutdinov, Ruslan},
  booktitle = {Advances in Neural Information Processing Systems 17},
  pages = {513--520},
  publisher = {MIT Press},
  title = {{Neighbourhood Components Analysis}},
  year = {2004}
}

Definition at line 59 of file nca.hpp.

Constructor & Destructor Documentation

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::\fBNCA\fP (const arma::mat &dataset, const arma::Col< size_t > &labels, MetricTypemetric = \fCMetricType()\fP)

Construct the Neighborhood Components Analysis object. This simply stores the reference to the dataset and labels as well as the parameters for optimization before the actual optimization is performed.

Parameters:

dataset Input dataset.

labels Input dataset labels.

stepSize Step size for stochastic gradient descent.

maxIterations Maximum iterations for stochastic gradient descent.

tolerance Tolerance for termination of stochastic gradient descent.

shuffle Whether or not to shuffle the dataset during SGD.

metric Instantiated metric to use.

Member Function Documentation

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> const arma::mat& \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::Dataset () const\fC [inline]\fP

Get the dataset reference.

Definition at line 91 of file nca.hpp.

References mlpack::nca::NCA< MetricType, OptimizerType >::dataset.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> const arma::Col<size_t>& \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::Labels () const\fC [inline]\fP

Get the labels reference.

Definition at line 93 of file nca.hpp.

References mlpack::nca::NCA< MetricType, OptimizerType >::labels.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> void \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::LearnDistance (arma::mat &outputMatrix)

Perform Neighborhood Components Analysis. The output distance learning matrix is written into the passed reference. If LearnDistance() is called with an outputMatrix which has the correct size (dataset.n_rows x dataset.n_rows), that matrix will be used as the starting point for optimization.

Parameters:

output_matrix Covariance matrix of Mahalanobis distance.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> const OptimizerType<\fBSoftmaxErrorFunction\fP<MetricType> >& \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::Optimizer () const\fC [inline]\fP

Get the optimizer.

Definition at line 96 of file nca.hpp.

References mlpack::nca::NCA< MetricType, OptimizerType >::optimizer.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> OptimizerType<\fBSoftmaxErrorFunction\fP<MetricType> >& \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::Optimizer ()\fC [inline]\fP

Definition at line 98 of file nca.hpp.

References mlpack::nca::NCA< MetricType, OptimizerType >::optimizer.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> std::string \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::ToString () const

Member Data Documentation

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> const arma::mat& \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::dataset\fC [private]\fP

Dataset reference.

Definition at line 106 of file nca.hpp.

Referenced by mlpack::nca::NCA< MetricType, OptimizerType >::Dataset().

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> \fBSoftmaxErrorFunction\fP<MetricType> \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::errorFunction\fC [private]\fP

The function to optimize.

Definition at line 114 of file nca.hpp.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> const arma::Col<size_t>& \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::labels\fC [private]\fP

Labels reference.

Definition at line 108 of file nca.hpp.

Referenced by mlpack::nca::NCA< MetricType, OptimizerType >::Labels().

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> MetricType \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::metric\fC [private]\fP

Metric to be used.

Definition at line 111 of file nca.hpp.

template<typename MetricType = metric::SquaredEuclideanDistance, template< typename > class OptimizerType = optimization::SGD> OptimizerType<\fBSoftmaxErrorFunction\fP<MetricType> > \fBmlpack::nca::NCA\fP< MetricType, OptimizerType >::optimizer\fC [private]\fP

The optimizer to use.

Definition at line 117 of file nca.hpp.

Referenced by mlpack::nca::NCA< MetricType, OptimizerType >::Optimizer().

Author

Generated automatically by Doxygen for MLPACK from the source code.