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 00096 inline virtual const char* get_name() const { return "DomainAdaptationSVM"; } 00097 00098 00099 private: 00100 00101 #ifdef HAVE_BOOST_SERIALIZATION 00102 friend class ::boost::serialization::access; 00103 // When the class Archive corresponds to an output archive, the 00104 // & operator is defined similar to <<. Likewise, when the class Archive 00105 // is a type of input archive the & operator is defined similar to >>. 00106 template<class Archive> 00107 void serialize(Archive & ar, const unsigned int archive_version) 00108 { 00109 00110 SG_DEBUG("archiving CDomainAdaptationSVM\n"); 00111 00112 // serialize base class 00113 ar & ::boost::serialization::base_object<CSVMLight>(*this); 00114 00115 // serialize remaining fields 00116 ar & presvm; 00117 00118 ar & B; 00119 00120 ar & train_factor; 00121 00122 SG_DEBUG("done archiving CDomainAdaptationSVM\n"); 00123 00124 } 00125 #endif //HAVE_BOOST_SERIALIZATION 00126 00127 protected: 00128 00133 virtual bool is_presvm_sane(); 00134 00135 00137 CSVM* presvm; 00138 00139 00141 float64_t B; 00142 00143 00145 float64_t train_factor; 00146 00147 }; 00148 } 00149 #endif