SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LocallyLinearEmbedding.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) 2011 Sergey Lisitsyn
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
11 #ifndef LOCALLYLINEAREMBEDDING_H_
12 #define LOCALLYLINEAREMBEDDING_H_
13 #include <shogun/lib/config.h>
14 #ifdef HAVE_LAPACK
19 
20 namespace shogun
21 {
22 
23 class CFeatures;
24 class CDistance;
25 
64 {
65 public:
66 
69 
71  virtual ~CLocallyLinearEmbedding();
72 
76  virtual CFeatures* apply(CFeatures* features);
77 
81  void set_k(int32_t k);
82 
86  int32_t get_k() const;
87 
91  void set_max_k(int32_t max_k);
92 
96  int32_t get_max_k() const;
97 
101  void set_auto_k(bool auto_k);
102 
106  bool get_auto_k() const;
107 
111  void set_reconstruction_shift(float64_t reconstruction_shift);
112 
117 
121  void set_nullspace_shift(float64_t nullspace_shift);
122 
127 
131  void set_use_arpack(bool use_arpack);
132 
136  bool get_use_arpack() const;
137 
139  virtual const char* get_name() const;
140 
142 protected:
143 
145  void init();
146 
153  SGMatrix<int32_t> neighborhood_matrix);
154 
160  virtual SGMatrix<float64_t> construct_embedding(SGMatrix<float64_t> matrix,int dimension);
161 
167  virtual SGMatrix<int32_t> get_neighborhood_matrix(SGMatrix<float64_t> distance_matrix, int32_t k);
168 
174  int32_t estimate_k(CSimpleFeatures<float64_t>* simple_features, SGMatrix<int32_t> neighborhood_matrix);
175 
188  float64_t compute_reconstruction_error(int32_t k, int dim, int N, float64_t* feature_matrix,
189  float64_t* z_matrix, float64_t* covariance_matrix,
190  float64_t* resid_vector, float64_t* id_vector,
191  SGMatrix<int32_t> neighborhood_matrix);
192 
194 protected:
195 
197  int32_t m_k;
198 
200  int32_t m_max_k;
201 
204 
207 
210 
212  bool m_auto_k;
213 
215 protected:
216 
220  static void* run_neighborhood_thread(void* p);
221 
225  static void* run_linearreconstruction_thread(void* p);
226 
227 };
228 }
229 
230 #endif /* HAVE_LAPACK */
231 #endif /* LOCALLYLINEAREMBEDDING_H_ */

SHOGUN Machine Learning Toolbox - Documentation