LocallyLinearEmbedding.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2011 Sergey Lisitsyn
00008  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
00009  */
00010 
00011 #ifndef LOCALLYLINEAREMBEDDING_H_
00012 #define LOCALLYLINEAREMBEDDING_H_
00013 #include <shogun/lib/config.h>
00014 #ifdef HAVE_LAPACK
00015 #include <shogun/converter/EmbeddingConverter.h>
00016 #include <shogun/features/Features.h>
00017 #include <shogun/features/DenseFeatures.h>
00018 #include <shogun/distance/Distance.h>
00019 
00020 namespace shogun
00021 {
00022 
00023 class CFeatures;
00024 class CDistance;
00025 
00067 class CLocallyLinearEmbedding: public CEmbeddingConverter
00068 {
00069 public:
00070 
00072     CLocallyLinearEmbedding();
00073 
00075     virtual ~CLocallyLinearEmbedding();
00076 
00080     virtual CFeatures* apply(CFeatures* features);
00081 
00085     void set_k(int32_t k);
00086 
00090     int32_t get_k() const;
00091 
00095     void set_max_k(int32_t max_k);
00096 
00100     int32_t get_max_k() const;
00101 
00105     void set_auto_k(bool auto_k);
00106 
00110     bool get_auto_k() const;
00111 
00115     void set_reconstruction_shift(float64_t reconstruction_shift);
00116 
00120     float64_t get_reconstruction_shift() const;
00121 
00125     void set_nullspace_shift(float64_t nullspace_shift);
00126 
00130     float64_t get_nullspace_shift() const;
00131 
00135     void set_use_arpack(bool use_arpack);
00136 
00140     bool get_use_arpack() const;
00141 
00143     virtual const char* get_name() const;
00144 
00146 protected:
00147 
00149     void init();
00150 
00156     virtual SGMatrix<float64_t> construct_weight_matrix(CDenseFeatures<float64_t>* simple_features,float64_t* W_matrix,
00157                                                             SGMatrix<int32_t> neighborhood_matrix);
00158 
00164     virtual SGMatrix<float64_t> construct_embedding(SGMatrix<float64_t> matrix,int dimension);
00165 
00171     virtual SGMatrix<int32_t> get_neighborhood_matrix(SGMatrix<float64_t> distance_matrix, int32_t k);
00172 
00178     int32_t estimate_k(CDenseFeatures<float64_t>* simple_features, SGMatrix<int32_t> neighborhood_matrix);
00179 
00192     float64_t compute_reconstruction_error(int32_t k, int dim, int N, float64_t* feature_matrix,
00193                                            float64_t* z_matrix, float64_t* covariance_matrix,
00194                                            float64_t* resid_vector, float64_t* id_vector,
00195                                            SGMatrix<int32_t> neighborhood_matrix);
00196 
00198 protected:
00199 
00201     int32_t m_k;
00202 
00204     int32_t m_max_k;
00205 
00207     float64_t m_reconstruction_shift;
00208 
00210     float64_t m_nullspace_shift;
00211 
00213     bool m_use_arpack;
00214 
00216     bool m_auto_k;
00217 
00219 protected:
00220 
00224     static void* run_linearreconstruction_thread(void* p);
00225 
00226 };
00227 }
00228 
00229 #endif /* HAVE_LAPACK */
00230 #endif /* LOCALLYLINEAREMBEDDING_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation