SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 
17 #include <shogun/base/SGObject.h>
21 #include <shogun/lib/SGMatrix.h>
22 
23 namespace shogun
24 {
25 
26 // Forward declaration
27 class CLMNNStatistics;
28 
36 class CLMNN : public CSGObject
37 {
38  public:
40  CLMNN();
41 
48  CLMNN(CDenseFeatures<float64_t>* features, CMulticlassLabels* labels, int32_t k);
49 
51  virtual ~CLMNN();
52 
54  virtual const char* get_name() const;
55 
63  void train(SGMatrix<float64_t> init_transform=SGMatrix<float64_t>());
64 
70 
78 
83  int32_t get_k() const;
84 
89  void set_k(const int32_t k);
90 
96 
101  void set_regularization(const float64_t regularization);
102 
107  float64_t get_stepsize() const;
108 
113  void set_stepsize(const float64_t stepsize);
114 
120 
125  void set_stepsize_threshold(const float64_t stepsize_threshold);
126 
131  uint32_t get_maxiter() const;
132 
137  void set_maxiter(const uint32_t maxiter);
138 
143  uint32_t get_correction() const;
144 
149  void set_correction(const uint32_t correction);
150 
156 
161  void set_obj_threshold(const float64_t obj_threshold);
162 
167  bool get_diagonal() const;
168 
173  void set_diagonal(const bool diagonal);
174 
180 
181  private:
183  void init();
184 
185  private:
187  SGMatrix<float64_t> m_linear_transform;
188 
190  CFeatures* m_features;
191 
193  CLabels* m_labels;
194 
199  float64_t m_regularization;
200 
202  int32_t m_k;
203 
208  float64_t m_stepsize;
209 
215  float64_t m_stepsize_threshold;
216 
218  uint32_t m_maxiter;
219 
224  uint32_t m_correction;
225 
232  float64_t m_obj_threshold;
233 
238  bool m_diagonal;
239 
241  CLMNNStatistics* m_statistics;
242 
243 }; /* class CLMNN */
244 
250 {
251  public:
253  CLMNNStatistics();
254 
256  virtual ~CLMNNStatistics();
257 
259  virtual const char* get_name() const;
260 
267  void resize(int32_t size);
268 
279  void set(index_t iter, float64_t obj_iter, float64_t stepsize_iter, uint32_t num_impostors_iter);
280 
281  private:
283  void init();
284 
285  public:
288 
291 
294 };
295 
296 } /* namespace shogun */
297 
298 
299 #endif /* LMNN_H_ */
CCustomMahalanobisDistance * get_distance() const
Definition: LMNN.cpp:152
virtual const char * get_name() const
Definition: LMNN.cpp:54
void set_regularization(const float64_t regularization)
Definition: LMNN.cpp:193
void set_diagonal(const bool diagonal)
Definition: LMNN.cpp:259
virtual const char * get_name() const
Definition: LMNN.cpp:318
float64_t get_obj_threshold() const
Definition: LMNN.cpp:242
bool get_diagonal() const
Definition: LMNN.cpp:254
SGVector< uint32_t > num_impostors
Definition: LMNN.h:293
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:209
float64_t get_stepsize() const
Definition: LMNN.cpp:198
SGVector< float64_t > stepsize
Definition: LMNN.h:290
Class LMNNStatistics used to give access to intermediate results obtained training LMNN...
Definition: LMNN.h:249
Class LMNN that implements the distance metric learning technique Large Margin Nearest Neighbour (LMN...
Definition: LMNN.h:36
float64_t get_regularization() const
Definition: LMNN.cpp:188
void set(index_t iter, float64_t obj_iter, float64_t stepsize_iter, uint32_t num_impostors_iter)
Definition: LMNN.cpp:333
Multiclass Labels for multi-class classification.
uint32_t get_correction() const
Definition: LMNN.cpp:232
void set_maxiter(const uint32_t maxiter)
Definition: LMNN.cpp:226
void set_stepsize_threshold(const float64_t stepsize_threshold)
Definition: LMNN.cpp:214
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
CLMNNStatistics * get_statistics() const
Definition: LMNN.cpp:264
double float64_t
Definition: common.h:50
void set_k(const int32_t k)
Definition: LMNN.cpp:182
Class CustomMahalanobisDistance used to compute the distance between feature vectors and as ...
virtual ~CLMNNStatistics()
Definition: LMNN.cpp:314
void resize(int32_t size)
Definition: LMNN.cpp:323
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:147
void set_obj_threshold(const float64_t obj_threshold)
Definition: LMNN.cpp:247
void train(SGMatrix< float64_t > init_transform=SGMatrix< float64_t >())
Definition: LMNN.cpp:59
void set_correction(const uint32_t correction)
Definition: LMNN.cpp:237
The class Features is the base class of all feature objects.
Definition: Features.h:68
uint32_t get_maxiter() const
Definition: LMNN.cpp:221
virtual ~CLMNN()
Definition: LMNN.cpp:47
void set_stepsize(const float64_t stepsize)
Definition: LMNN.cpp:203
SGVector< float64_t > obj
Definition: LMNN.h:287
int32_t get_k() const
Definition: LMNN.cpp:177

SHOGUN Machine Learning Toolbox - Documentation