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) 2009 Soeren Sonnenburg 00008 * Written (W) 2009 Marius Kloft 00009 * Copyright (C) 2009 TU Berlin and Max-Planck-Society 00010 */ 00011 00012 #ifndef _SCATTERSVM_H___ 00013 #define _SCATTERSVM_H___ 00014 00015 #include "lib/common.h" 00016 #include "lib/config.h" 00017 #include "classifier/svm/MultiClassSVM.h" 00018 #include "classifier/svm/SVM_libsvm.h" 00019 00020 #include <stdio.h> 00021 00022 namespace shogun 00023 { 00025 enum SCATTER_TYPE 00026 { 00028 NO_BIAS_LIBSVM, 00029 #ifdef USE_SVMLIGHT 00030 00031 NO_BIAS_SVMLIGHT, 00032 #endif //USE_SVMLIGHT 00033 00034 TEST_RULE1, 00036 TEST_RULE2 00037 }; 00038 00053 class CScatterSVM : public CMultiClassSVM 00054 { 00055 public: 00057 CScatterSVM(void); 00058 00060 CScatterSVM(SCATTER_TYPE type); 00061 00068 CScatterSVM(float64_t C, CKernel* k, CLabels* lab); 00069 00071 virtual ~CScatterSVM(); 00072 00081 virtual bool train(CFeatures* data=NULL); 00082 00087 virtual inline EClassifierType get_classifier_type() { return CT_SCATTERSVM; } 00088 00094 virtual float64_t classify_example(int32_t num); 00095 00100 virtual CLabels* classify_one_vs_rest(); 00101 00103 inline virtual const char* get_name() const { return "ScatterSVM"; } 00104 00105 private: 00106 void compute_norm_wc(); 00107 virtual bool train_no_bias_libsvm(); 00108 #ifdef USE_SVMLIGHT 00109 virtual bool train_no_bias_svmlight(); 00110 #endif //USE_SVMLIGHT 00111 virtual bool train_testrule12(); 00112 00113 protected: 00115 SCATTER_TYPE scatter_type; 00116 00118 svm_problem problem; 00120 svm_parameter param; 00121 00123 struct svm_model* model; 00124 00126 float64_t* norm_wc; 00127 00129 float64_t* norm_wcw; 00130 00132 float64_t rho; 00133 00135 int32_t m_num_classes; 00136 }; 00137 } 00138 #endif // ScatterSVM