svm.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef __LEMGA_SVM_H__
00003 #define __LEMGA_SVM_H__
00004 
00011 #include "learnmodel.h"
00012 #include "kernel.h"
00013 
00014 namespace lemga {
00015 
00017 struct SVM_detail;
00018 
00019 const kernel::RBF _svm_ker(0.5);
00020 
00021 class SVM : public LearnModel {
00022 private:
00023     SVM_detail *detail;
00024     const kernel::Kernel& ker;
00025 
00026 public:
00027     explicit SVM (const kernel::Kernel& = _svm_ker, UINT n_in = 0);
00028     SVM (const SVM&);
00029     explicit SVM (std::istream& is): ker(_svm_ker) { is >> *this; }
00030     virtual ~SVM ();
00031     const SVM& operator= (const SVM&);
00032 
00033     virtual const id_t& id () const;
00034     virtual SVM* create () const { return new SVM(); }
00035     virtual SVM* clone () const { return new SVM(*this); }
00036 
00037     REAL C () const;
00038     void set_C (REAL);
00039     UINT n_support_vectors () const;
00040     Input support_vector (UINT) const;
00042     REAL support_vector_coef (UINT) const;
00043     REAL bias () const;
00044     REAL kernel (const Input&, const Input&) const;
00045 
00046     virtual bool support_weighted_data () const { return true; }
00047     virtual void initialize ();
00048     virtual REAL train ();
00049 
00050     virtual Output operator() (const Input&) const;
00051     virtual REAL margin_norm () const { return w_norm(); }
00052     virtual REAL margin_of (const Input&, const Output&) const;
00053     REAL w_norm () const;
00054 
00055 protected:
00058     REAL signed_margin (const Input&) const;
00059     virtual bool serialize (std::ostream&, ver_list&) const;
00060     virtual bool unserialize (std::istream&, ver_list&,
00061                               const id_t& = empty_id);
00062 };
00063 
00064 } // namespace lemga
00065 
00066 #ifdef  __SVM_H__
00067 #warning "This header file may conflict with another `svm.h' file."
00068 #endif
00069 #define __SVM_H__
00070 #endif

Generated on Mon Jan 9 23:43:25 2006 for LEMGA by  doxygen 1.4.6