SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LMNN.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Fernando J. Iglesias Garcia
8  * Copyright (C) 2013 Fernando J. Iglesias Garcia
9  */
10 
11 #ifndef LMNN_H_
12 #define LMNN_H_
13 
14 #include <shogun/lib/config.h>
15 
16 #ifdef HAVE_EIGEN3
17 
18 #include <shogun/base/SGObject.h>
22 #include <shogun/lib/SGMatrix.h>
23 
24 namespace shogun
25 {
26 
27 // Forward declaration
28 class CLMNNStatistics;
29 
37 class CLMNN : public CSGObject
38 {
39  public:
41  CLMNN();
42 
49  CLMNN(CDenseFeatures<float64_t>* features, CMulticlassLabels* labels, int32_t k);
50 
52  virtual ~CLMNN();
53 
55  virtual const char* get_name() const;
56 
64  void train(SGMatrix<float64_t> init_transform=SGMatrix<float64_t>());
65 
71 
79 
84  int32_t get_k() const;
85 
90  void set_k(const int32_t k);
91 
97 
102  void set_regularization(const float64_t regularization);
103 
108  float64_t get_stepsize() const;
109 
114  void set_stepsize(const float64_t stepsize);
115 
121 
126  void set_stepsize_threshold(const float64_t stepsize_threshold);
127 
132  uint32_t get_maxiter() const;
133 
138  void set_maxiter(const uint32_t maxiter);
139 
144  uint32_t get_correction() const;
145 
150  void set_correction(const uint32_t correction);
151 
157 
162  void set_obj_threshold(const float64_t obj_threshold);
163 
168  bool get_diagonal() const;
169 
174  void set_diagonal(const bool diagonal);
175 
181 
182  private:
184  void init();
185 
186  private:
188  SGMatrix<float64_t> m_linear_transform;
189 
191  CFeatures* m_features;
192 
194  CLabels* m_labels;
195 
200  float64_t m_regularization;
201 
203  int32_t m_k;
204 
209  float64_t m_stepsize;
210 
216  float64_t m_stepsize_threshold;
217 
219  uint32_t m_maxiter;
220 
225  uint32_t m_correction;
226 
233  float64_t m_obj_threshold;
234 
239  bool m_diagonal;
240 
242  CLMNNStatistics* m_statistics;
243 
244 }; /* class CLMNN */
245 
251 {
252  public:
254  CLMNNStatistics();
255 
257  virtual ~CLMNNStatistics();
258 
260  virtual const char* get_name() const;
261 
268  void resize(int32_t size);
269 
280  void set(index_t iter, float64_t obj_iter, float64_t stepsize_iter, uint32_t num_impostors_iter);
281 
282  private:
284  void init();
285 
286  public:
289 
292 
295 };
296 
297 } /* namespace shogun */
298 
299 #endif /* HAVE_EIGEN3 */
300 
301 #endif /* LMNN_H_ */
CCustomMahalanobisDistance * get_distance() const
Definition: LMNN.cpp:153
virtual const char * get_name() const
Definition: LMNN.cpp:55
void set_regularization(const float64_t regularization)
Definition: LMNN.cpp:194
void set_diagonal(const bool diagonal)
Definition: LMNN.cpp:260
virtual const char * get_name() const
Definition: LMNN.cpp:319
float64_t get_obj_threshold() const
Definition: LMNN.cpp:243
bool get_diagonal() const
Definition: LMNN.cpp:255
SGVector< uint32_t > num_impostors
Definition: LMNN.h:294
int32_t index_t
Definition: common.h:62
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
float64_t get_stepsize_threshold() const
Definition: LMNN.cpp:210
float64_t get_stepsize() const
Definition: LMNN.cpp:199
SGVector< float64_t > stepsize
Definition: LMNN.h:291
Class LMNNStatistics used to give access to intermediate results obtained training LMNN...
Definition: LMNN.h:250
Class LMNN that implements the distance metric learning technique Large Margin Nearest Neighbour (LMN...
Definition: LMNN.h:37
float64_t get_regularization() const
Definition: LMNN.cpp:189
void set(index_t iter, float64_t obj_iter, float64_t stepsize_iter, uint32_t num_impostors_iter)
Definition: LMNN.cpp:334
Multiclass Labels for multi-class classification.
uint32_t get_correction() const
Definition: LMNN.cpp:233
void set_maxiter(const uint32_t maxiter)
Definition: LMNN.cpp:227
void set_stepsize_threshold(const float64_t stepsize_threshold)
Definition: LMNN.cpp:215
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
CLMNNStatistics * get_statistics() const
Definition: LMNN.cpp:265
double float64_t
Definition: common.h:50
void set_k(const int32_t k)
Definition: LMNN.cpp:183
Class CustomMahalanobisDistance used to compute the distance between feature vectors and as ...
virtual ~CLMNNStatistics()
Definition: LMNN.cpp:315
void resize(int32_t size)
Definition: LMNN.cpp:324
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
SGMatrix< float64_t > get_linear_transform() const
Definition: LMNN.cpp:148
void set_obj_threshold(const float64_t obj_threshold)
Definition: LMNN.cpp:248
void train(SGMatrix< float64_t > init_transform=SGMatrix< float64_t >())
Definition: LMNN.cpp:60
void set_correction(const uint32_t correction)
Definition: LMNN.cpp:238
The class Features is the base class of all feature objects.
Definition: Features.h:68
uint32_t get_maxiter() const
Definition: LMNN.cpp:222
virtual ~CLMNN()
Definition: LMNN.cpp:48
void set_stepsize(const float64_t stepsize)
Definition: LMNN.cpp:204
SGVector< float64_t > obj
Definition: LMNN.h:288
int32_t get_k() const
Definition: LMNN.cpp:178

SHOGUN Machine Learning Toolbox - Documentation