mlpack
nca.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_NCA_NCA_HPP
13 #define MLPACK_METHODS_NCA_NCA_HPP
14 
15 #include <mlpack/prereqs.hpp>
17 #include <ensmallen.hpp>
18 
20 
21 namespace mlpack {
22 namespace nca {
23 
47 template<typename MetricType = metric::SquaredEuclideanDistance,
48  typename OptimizerType = ens::StandardSGD>
49 class NCA
50 {
51  public:
61  NCA(const arma::mat& dataset,
62  const arma::Row<size_t>& labels,
63  MetricType metric = MetricType());
64 
77  template<typename... CallbackTypes>
78  void LearnDistance(arma::mat& outputMatrix, CallbackTypes&&... callbacks);
79 
81  const arma::mat& Dataset() const { return dataset; }
83  const arma::Row<size_t>& Labels() const { return labels; }
84 
86  const OptimizerType& Optimizer() const { return optimizer; }
87  OptimizerType& Optimizer() { return optimizer; }
88 
89  private:
91  const arma::mat& dataset;
93  const arma::Row<size_t>& labels;
94 
96  MetricType metric;
97 
100 
102  OptimizerType optimizer;
103 };
104 
105 } // namespace nca
106 } // namespace mlpack
107 
108 // Include the implementation.
109 #include "nca_impl.hpp"
110 
111 #endif
The "softmax" stochastic neighbor assignment probability function.
Definition: nca_softmax_error_function.hpp:45
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
void LearnDistance(arma::mat &outputMatrix, CallbackTypes &&... callbacks)
Perform Neighborhood Components Analysis.
Definition: nca_impl.hpp:34
const OptimizerType & Optimizer() const
Get the optimizer.
Definition: nca.hpp:86
NCA(const arma::mat &dataset, const arma::Row< size_t > &labels, MetricType metric=MetricType())
Construct the Neighborhood Components Analysis object.
Definition: nca_impl.hpp:23
The L_p metric for arbitrary integer p, with an option to take the root.
Definition: lmetric.hpp:63
const arma::mat & Dataset() const
Get the dataset reference.
Definition: nca.hpp:81
An implementation of Neighborhood Components Analysis, both a linear dimensionality reduction techniq...
Definition: nca.hpp:49
const arma::Row< size_t > & Labels() const
Get the labels reference.
Definition: nca.hpp:83