Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2006 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef MARSYAS_GMMCLASSIFIER_H 00020 #define MARSYAS_GMMCLASSIFIER_H 00021 00022 #include <marsyas/system/MarSystem.h> 00023 #include <vector> 00024 00025 namespace Marsyas 00026 { 00063 class GMMClassifier: public MarSystem 00064 { 00065 private: 00066 mrs_real factor_; // a constant 00067 00068 mrs_natural labelRow_; 00069 00070 std::vector<realvec> probs_; 00071 std::vector<realvec> ssprobs_; 00072 00073 std::vector<realvec> vars_; 00074 std::vector<realvec> covars_; 00075 std::vector<realvec> means_; 00076 std::vector<realvec> omeans_; 00077 std::vector<realvec> weights_; 00078 00079 realvec trainMatrix_; 00080 realvec likelihoods_; 00081 realvec classSizes_; 00082 realvec accumVec_; 00083 realvec temp_; 00084 realvec sprobs_; 00085 realvec sum_; 00086 00087 mrs_string prev_mode_; 00088 MarControlPtr ctrl_mode_; 00089 00090 MarControlPtr ctrl_nClasses_; 00091 00092 mrs_natural featSize_; // Nr of features 00093 mrs_natural classSize_; // Nr of classes (aka labels) 00094 mrs_natural nMixtures_; // Nr of Gaussian mixtures 00095 mrs_natural iterations_; // EM algorithm iterations 00096 mrs_natural kiterations_; // K-MEANS initialization iterations 00097 mrs_natural eiterations_; // Evaluation-training iterations 00098 MarControlPtr ctrl_nMixtures_; 00099 MarControlPtr ctrl_iterations_; 00100 MarControlPtr ctrl_kiterations_; 00101 MarControlPtr ctrl_eiterations_; 00102 00103 void initialize(); 00104 mrs_real gaussian(mrs_natural cl, mrs_natural k, realvec& vec); 00105 void doEM(); 00106 void addControls(); 00107 void myUpdate(MarControlPtr sender); 00108 00109 public: 00110 GMMClassifier(std::string name); 00111 GMMClassifier(const GMMClassifier& a); 00112 ~GMMClassifier(); 00113 MarSystem* clone() const; 00114 00115 void myProcess(realvec& in, realvec& out); 00116 }; 00117 00118 }//namespace Marsyas 00119 00120 #endif 00121 00122 00123