MLPACK  1.0.8
nca.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_NCA_NCA_HPP
23 #define __MLPACK_METHODS_NCA_NCA_HPP
24 
25 #include <mlpack/core.hpp>
28 
30 
31 namespace mlpack {
32 namespace nca {
33 
57 template<typename MetricType = metric::SquaredEuclideanDistance,
58  template<typename> class OptimizerType = optimization::SGD>
59 class NCA
60 {
61  public:
75  NCA(const arma::mat& dataset,
76  const arma::Col<size_t>& labels,
77  MetricType metric = MetricType());
78 
88  void LearnDistance(arma::mat& outputMatrix);
89 
91  const arma::mat& Dataset() const { return dataset; }
93  const arma::Col<size_t>& Labels() const { return labels; }
94 
96  const OptimizerType<SoftmaxErrorFunction<MetricType> >& Optimizer() const
97  { return optimizer; }
98  OptimizerType<SoftmaxErrorFunction<MetricType> >& Optimizer()
99  { return optimizer; }
100 
101  private:
103  const arma::mat& dataset;
105  const arma::Col<size_t>& labels;
106 
108  MetricType metric;
109 
112 
114  OptimizerType<SoftmaxErrorFunction<MetricType> > optimizer;
115 };
116 
117 }; // namespace nca
118 }; // namespace mlpack
119 
120 // Include the implementation.
121 #include "nca_impl.hpp"
122 
123 #endif
SoftmaxErrorFunction< MetricType > errorFunction
The function to optimize.
Definition: nca.hpp:111
MetricType metric
Metric to be used.
Definition: nca.hpp:108
const arma::mat & dataset
Dataset reference.
Definition: nca.hpp:103
The "softmax" stochastic neighbor assignment probability function.
OptimizerType< SoftmaxErrorFunction< MetricType > > optimizer
The optimizer to use.
Definition: nca.hpp:114
LMetric< 2, false > SquaredEuclideanDistance
Definition: lmetric.hpp:99
NCA(const arma::mat &dataset, const arma::Col< size_t > &labels, MetricType metric=MetricType())
Construct the Neighborhood Components Analysis object.
const OptimizerType< SoftmaxErrorFunction< MetricType > > & Optimizer() const
Get the optimizer.
Definition: nca.hpp:96
const arma::mat & Dataset() const
Get the dataset reference.
Definition: nca.hpp:91
const arma::Col< size_t > & Labels() const
Get the labels reference.
Definition: nca.hpp:93
Stochastic Gradient Descent is a technique for minimizing a function which can be expressed as a sum ...
Definition: sgd.hpp:84
An implementation of Neighborhood Components Analysis, both a linear dimensionality reduction techniq...
Definition: nca.hpp:59
const arma::Col< size_t > & labels
Labels reference.
Definition: nca.hpp:105
void LearnDistance(arma::mat &outputMatrix)
Perform Neighborhood Components Analysis.
OptimizerType< SoftmaxErrorFunction< MetricType > > & Optimizer()
Definition: nca.hpp:98