00001 #ifndef _theplu_yat_classifier_svm_
00002 #define _theplu_yat_classifier_svm_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "SVindex.h"
00028 #include "Target.h"
00029 #include "yat/utility/Vector.h"
00030
00031 #include <utility>
00032 #include <vector>
00033
00034 namespace theplu {
00035 namespace yat {
00036 namespace utility{
00037 class Matrix;
00038 }
00039
00040 namespace classifier {
00041
00042 class DataLookup1D;
00043 class DataLookupWeighted1D;
00044 class KernelLookup;
00045
00049 class SVM
00050 {
00051
00052 public:
00056 SVM(void);
00057
00061 SVM(const SVM&);
00062
00066 virtual ~SVM();
00067
00074 SVM* make_classifier(void) const;
00075
00079 const utility::Vector& alpha(void) const;
00080
00095 double C(void) const;
00096
00102 long int max_epochs(void) const;
00103
00107 void max_epochs(long int);
00108
00115 const theplu::yat::utility::Vector& output(void) const;
00116
00131 void predict(const KernelLookup& input, utility::Matrix& predict) const;
00132
00133
00138
00139
00144
00145
00146
00150 void set_C(const double);
00151
00185 void train(const KernelLookup& kernel, const Target& target);
00186
00187
00188
00189 private:
00193 void bounds(double&, double&) const;
00194
00200 void calculate_bias(void);
00201
00205 void calculate_margin(void);
00206
00217 bool choose(const theplu::yat::utility::Vector&);
00218
00222 double kernel_mod(const size_t i, const size_t j) const;
00223
00227 int target(size_t i) const;
00228
00229 utility::Vector alpha_;
00230 double bias_;
00231 double C_inverse_;
00232
00233 const KernelLookup* kernel_;
00234 double margin_;
00235 unsigned long int max_epochs_;
00236 utility::Vector output_;
00237 SVindex sample_;
00238 Target target_;
00239 double tolerance_;
00240 bool trained_;
00241
00242 };
00243
00244 }}}
00245
00246 #endif