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_SVMCLASSIFIER_H 00020 #define MARSYAS_SVMCLASSIFIER_H 00021 00022 #include <marsyas/system/MarSystem.h> 00023 #include "svm.h" 00024 #include <marsyas/WekaData.h> 00025 00026 namespace Marsyas 00027 { 00033 class SVMClassifier: public MarSystem 00034 { 00035 private: 00036 MarControlPtr ctrl_sv_coef_ ; 00037 MarControlPtr ctrl_sv_indices_ ; 00038 MarControlPtr ctrl_SV_ ; 00039 MarControlPtr ctrl_rho_ ; 00040 MarControlPtr ctrl_probA_ ; 00041 MarControlPtr ctrl_probB_ ; 00042 MarControlPtr ctrl_label_ ; 00043 MarControlPtr ctrl_nSV_ ; 00044 MarControlPtr ctrl_nr_class_ ; 00045 MarControlPtr ctrl_weight_; 00046 MarControlPtr ctrl_weight_label_; 00047 MarControlPtr ctrl_minimums_; 00048 MarControlPtr ctrl_maximums_; 00049 MarControlPtr ctrl_mode_; 00050 MarControlPtr ctrl_nClasses_; 00051 MarControlPtr ctrl_l_; 00052 MarControlPtr ctrl_svm_; 00053 MarControlPtr ctrl_kernel_; 00054 MarControlPtr ctrl_degree_; 00055 MarControlPtr ctrl_gamma_; 00056 MarControlPtr ctrl_coef0_; 00057 MarControlPtr ctrl_nu_; 00058 MarControlPtr ctrl_cache_size_; 00059 MarControlPtr ctrl_C_; 00060 MarControlPtr ctrl_eps_; 00061 MarControlPtr ctrl_p_; 00062 MarControlPtr ctrl_shrinking_; 00063 MarControlPtr ctrl_probability_; 00064 MarControlPtr ctrl_nr_weight_; 00065 MarControlPtr ctrl_classPerms_; 00066 00067 std::vector<int> classPerms_; 00068 00069 00070 void addControls(); 00071 void myUpdate(MarControlPtr sender); 00072 00073 WekaData instances_; 00074 struct svm_problem svm_prob_; 00075 struct svm_parameter svm_param_; 00076 struct svm_model *svm_model_; 00077 mrs_bool trained_, training_, was_training_; 00078 mrs_natural kernel_, svm_; 00079 00080 // to clean-up memory leaks 00081 mrs_natural num_nodes; 00082 void ensure_free_svm_model(); 00083 void ensure_free_svm_prob_xy(); 00084 mrs_natural num_svm_prob_x; 00085 00086 public: 00087 SVMClassifier(std::string name); 00088 SVMClassifier(const SVMClassifier& a); 00089 ~SVMClassifier(); 00090 MarSystem* clone() const; 00091 00092 void myProcess(realvec& in, realvec& out); 00093 }; 00094 00095 } 00096 00097 #endif