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
00028 #include "SVindex.h"
00029 #include "Target.h"
00030 #include "yat/utility/Vector.h"
00031
00032 #include <utility>
00033 #include <vector>
00034
00035 namespace theplu {
00036 namespace yat {
00037 namespace utility{
00038 class Matrix;
00039 }
00040
00041 namespace classifier {
00042
00043 class DataLookup1D;
00044 class DataLookupWeighted1D;
00045 class KernelLookup;
00046
00050 class SVM
00051 {
00052
00053 public:
00057 SVM(void);
00058
00062 SVM(const SVM&);
00063
00067 virtual ~SVM();
00068
00075 SVM* make_classifier(void) const;
00076
00080 const utility::Vector& alpha(void) const;
00081
00096 double C(void) const;
00097
00103 unsigned long int max_epochs(void) const;
00104
00108 void max_epochs(unsigned long int);
00109
00116 const theplu::yat::utility::Vector& output(void) const;
00117
00132 void predict(const KernelLookup& input, utility::Matrix& predict) const;
00133
00134
00139
00140
00145
00146
00147
00155 void reset(void);
00156
00160 void set_C(const double);
00161
00195 void train(const KernelLookup& kernel, const Target& target);
00196
00202 bool trained(void) const;
00203
00204 private:
00208 void bounds(double&, double&) const;
00209
00215 void calculate_bias(void);
00216
00220 void calculate_margin(void);
00221
00232 bool choose(const theplu::yat::utility::Vector&);
00233
00237 double kernel_mod(const size_t i, const size_t j) const;
00238
00242 int target(size_t i) const;
00243
00244 utility::Vector alpha_;
00245 double bias_;
00246 double C_inverse_;
00247
00248 const KernelLookup* kernel_;
00249 double margin_;
00250 unsigned long int max_epochs_;
00251 utility::Vector output_;
00252 SVindex sample_;
00253 Target target_;
00254 double tolerance_;
00255 bool trained_;
00256
00257 };
00258
00259 }}}
00260
00261 #endif