SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 
LMNN.h
浏览该文件的文档.
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 #ifdef HAVE_LAPACK
18 
19 #include <shogun/base/SGObject.h>
23 #include <shogun/lib/SGMatrix.h>
24 
25 namespace shogun
26 {
27 
28 // Forward declaration
29 class CLMNNStatistics;
30 
38 class CLMNN : public CSGObject
39 {
40  public:
42  CLMNN();
43 
50  CLMNN(CDenseFeatures<float64_t>* features, CMulticlassLabels* labels, int32_t k);
51 
53  virtual ~CLMNN();
54 
56  virtual const char* get_name() const;
57 
65  void train(SGMatrix<float64_t> init_transform=SGMatrix<float64_t>());
66 
72 
80 
85  int32_t get_k() const;
86 
91  void set_k(const int32_t k);
92 
98 
103  void set_regularization(const float64_t regularization);
104 
109  float64_t get_stepsize() const;
110 
115  void set_stepsize(const float64_t stepsize);
116 
122 
127  void set_stepsize_threshold(const float64_t stepsize_threshold);
128 
133  uint32_t get_maxiter() const;
134 
139  void set_maxiter(const uint32_t maxiter);
140 
145  uint32_t get_correction() const;
146 
151  void set_correction(const uint32_t correction);
152 
158 
163  void set_obj_threshold(const float64_t obj_threshold);
164 
169  bool get_diagonal() const;
170 
175  void set_diagonal(const bool diagonal);
176 
182 
183  private:
185  void init();
186 
187  private:
189  SGMatrix<float64_t> m_linear_transform;
190 
192  CFeatures* m_features;
193 
195  CLabels* m_labels;
196 
201  float64_t m_regularization;
202 
204  int32_t m_k;
205 
210  float64_t m_stepsize;
211 
217  float64_t m_stepsize_threshold;
218 
220  uint32_t m_maxiter;
221 
226  uint32_t m_correction;
227 
234  float64_t m_obj_threshold;
235 
240  bool m_diagonal;
241 
243  CLMNNStatistics* m_statistics;
244 
245 }; /* class CLMNN */
246 
252 {
253  public:
255  CLMNNStatistics();
256 
258  virtual ~CLMNNStatistics();
259 
261  virtual const char* get_name() const;
262 
269  void resize(int32_t size);
270 
281  void set(index_t iter, float64_t obj_iter, float64_t stepsize_iter, uint32_t num_impostors_iter);
282 
283  private:
285  void init();
286 
287  public:
290 
293 
296 };
297 
298 } /* namespace shogun */
299 
300 #endif /* HAVE_LAPACK */
301 #endif /* HAVE_EIGEN3 */
302 
303 #endif /* LMNN_H_ */
CCustomMahalanobisDistance * get_distance() const
Definition: LMNN.cpp:154
virtual const char * get_name() const
Definition: LMNN.cpp:56
void set_regularization(const float64_t regularization)
Definition: LMNN.cpp:195
void set_diagonal(const bool diagonal)
Definition: LMNN.cpp:261
virtual const char * get_name() const
Definition: LMNN.cpp:320
float64_t get_obj_threshold() const
Definition: LMNN.cpp:244
bool get_diagonal() const
Definition: LMNN.cpp:256
SGVector< uint32_t > num_impostors
Definition: LMNN.h:295
int32_t index_t
Definition: common.h:60
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
float64_t get_stepsize_threshold() const
Definition: LMNN.cpp:211
float64_t get_stepsize() const
Definition: LMNN.cpp:200
SGVector< float64_t > stepsize
Definition: LMNN.h:292
Class LMNNStatistics used to give access to intermediate results obtained training LMNN...
Definition: LMNN.h:251
Class LMNN that implements the distance metric learning technique Large Margin Nearest Neighbour (LMN...
Definition: LMNN.h:38
float64_t get_regularization() const
Definition: LMNN.cpp:190
void set(index_t iter, float64_t obj_iter, float64_t stepsize_iter, uint32_t num_impostors_iter)
Definition: LMNN.cpp:335
Multiclass Labels for multi-class classification.
uint32_t get_correction() const
Definition: LMNN.cpp:234
void set_maxiter(const uint32_t maxiter)
Definition: LMNN.cpp:228
void set_stepsize_threshold(const float64_t stepsize_threshold)
Definition: LMNN.cpp:216
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:102
CLMNNStatistics * get_statistics() const
Definition: LMNN.cpp:266
double float64_t
Definition: common.h:48
void set_k(const int32_t k)
Definition: LMNN.cpp:184
Class CustomMahalanobisDistance used to compute the distance between feature vectors and as ...
virtual ~CLMNNStatistics()
Definition: LMNN.cpp:316
void resize(int32_t size)
Definition: LMNN.cpp:325
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
SGMatrix< float64_t > get_linear_transform() const
Definition: LMNN.cpp:149
void set_obj_threshold(const float64_t obj_threshold)
Definition: LMNN.cpp:249
void train(SGMatrix< float64_t > init_transform=SGMatrix< float64_t >())
Definition: LMNN.cpp:61
void set_correction(const uint32_t correction)
Definition: LMNN.cpp:239
The class Features is the base class of all feature objects.
Definition: Features.h:62
uint32_t get_maxiter() const
Definition: LMNN.cpp:223
virtual ~CLMNN()
Definition: LMNN.cpp:49
void set_stepsize(const float64_t stepsize)
Definition: LMNN.cpp:205
SGVector< float64_t > obj
Definition: LMNN.h:289
int32_t get_k() const
Definition: LMNN.cpp:179

SHOGUN Machine Learning Toolbox - Documentation