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 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2007-2009 Christian Widmer 00008 * Copyright (C) 2007-2009 Max-Planck-Society 00009 */ 00010 00011 #ifndef _DomainAdaptation_SVM_H___ 00012 #define _DomainAdaptation_SVM_H___ 00013 00014 00015 #include "lib/common.h" 00016 #include "classifier/svm/SVM_light.h" 00017 00018 #include <stdio.h> 00019 00020 namespace shogun 00021 { 00023 class CDomainAdaptationSVM : public CSVMLight 00024 { 00025 00026 public: 00027 00029 CDomainAdaptationSVM(); 00030 00031 00040 CDomainAdaptationSVM(float64_t C, CKernel* k, CLabels* lab, CSVM* presvm, float64_t B); 00041 00042 00044 virtual ~CDomainAdaptationSVM(); 00045 00046 00052 void init(CSVM* presvm, float64_t B); 00053 00054 00063 virtual bool train(CFeatures* data=NULL); 00064 00065 00070 virtual inline EClassifierType get_classifier_type() { return CT_DASVM; } 00071 00072 00078 virtual CLabels* classify(CFeatures* data); 00079 00080 00085 virtual CSVM* get_presvm(); 00086 00087 00092 virtual float64_t get_B(); 00093 00094 00099 virtual float64_t get_train_factor(); 00100 00101 00105 virtual void set_train_factor(float64_t factor); 00106 00107 00109 inline virtual const char* get_name() const { return "DomainAdaptationSVM"; } 00110 00111 00112 private: 00113 00114 #ifdef HAVE_BOOST_SERIALIZATION 00115 friend class ::boost::serialization::access; 00116 // When the class Archive corresponds to an output archive, the 00117 // & operator is defined similar to <<. Likewise, when the class Archive 00118 // is a type of input archive the & operator is defined similar to >>. 00119 template<class Archive> 00120 void serialize(Archive & ar, const unsigned int archive_version) 00121 { 00122 00123 SG_DEBUG("archiving CDomainAdaptationSVM\n"); 00124 00125 // serialize base class 00126 ar & ::boost::serialization::base_object<CSVMLight>(*this); 00127 00128 // serialize remaining fields 00129 ar & presvm; 00130 00131 ar & B; 00132 00133 ar & train_factor; 00134 00135 SG_DEBUG("done archiving CDomainAdaptationSVM\n"); 00136 00137 } 00138 #endif //HAVE_BOOST_SERIALIZATION 00139 00140 protected: 00141 00146 virtual bool is_presvm_sane(); 00147 00148 00150 CSVM* presvm; 00151 00152 00154 float64_t B; 00155 00156 00158 float64_t train_factor; 00159 00160 }; 00161 } 00162 #endif