MLPACK  1.0.10
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  // Returns a string representation of this object.
102  std::string ToString() const;
103 
104  private:
106  const arma::mat& dataset;
108  const arma::Col<size_t>& labels;
109 
111  MetricType metric;
112 
115 
117  OptimizerType<SoftmaxErrorFunction<MetricType> > optimizer;
118 };
119 
120 }; // namespace nca
121 }; // namespace mlpack
122 
123 // Include the implementation.
124 #include "nca_impl.hpp"
125 
126 #endif