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) 1999-2009 Soeren Sonnenburg 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _LDA_H___ 00012 #define _LDA_H___ 00013 00014 #include <shogun/lib/config.h> 00015 00016 #ifdef HAVE_LAPACK 00017 #include <shogun/lib/common.h> 00018 #include <shogun/features/Features.h> 00019 #include <shogun/features/DenseFeatures.h> 00020 #include <shogun/machine/LinearMachine.h> 00021 00022 namespace shogun 00023 { 00024 template <class ST> class CDenseFeatures; 00052 class CLDA : public CLinearMachine 00053 { 00054 public: 00055 MACHINE_PROBLEM_TYPE(PT_BINARY); 00056 00061 CLDA(float64_t gamma=0); 00062 00069 CLDA(float64_t gamma, CDenseFeatures<float64_t>* traindat, CLabels* trainlab); 00070 virtual ~CLDA(); 00071 00076 inline void set_gamma(float64_t gamma) 00077 { 00078 m_gamma=gamma; 00079 } 00080 00085 inline float64_t get_gamma() 00086 { 00087 return m_gamma; 00088 } 00089 00094 virtual EMachineType get_classifier_type() 00095 { 00096 return CT_LDA; 00097 } 00098 00103 virtual void set_features(CDotFeatures* feat) 00104 { 00105 if (feat->get_feature_class() != C_DENSE || 00106 feat->get_feature_type() != F_DREAL) 00107 SG_ERROR("LDA requires SIMPLE REAL valued features\n"); 00108 00109 CLinearMachine::set_features(feat); 00110 } 00111 00113 virtual const char* get_name() const { return "LDA"; } 00114 00115 protected: 00124 virtual bool train_machine(CFeatures* data=NULL); 00125 00126 protected: 00128 float64_t m_gamma; 00129 }; 00130 } 00131 #endif 00132 #endif