00001 // This is mul/clsfy/clsfy_rbf_svm_smo_1_builder.h 00002 // Copyright: (C) 2001 British Telecommunications plc. 00003 #ifndef clsfy_rbf_svm_smo_1_builder_h_ 00004 #define clsfy_rbf_svm_smo_1_builder_h_ 00005 //: 00006 // \file 00007 // \brief Describe an interface to an SMO SVM builder and additional logic 00008 // \author Ian Scott 00009 // \date Dec 2001 00010 00011 #include <clsfy/clsfy_builder_base.h> 00012 #include <clsfy/clsfy_rbf_svm.h> 00013 #include <vnl/vnl_vector.h> 00014 #include <mbl/mbl_data_wrapper.h> 00015 #include <vcl_iosfwd.h> 00016 00017 //: Base for classes to build clsfy_classifier_base objects 00018 class clsfy_rbf_svm_smo_1_builder : public clsfy_builder_base 00019 { 00020 //: C, the upper bound on the Lagrange multipliers. 00021 // 0 means no (or infinite) upper bound. 00022 double boundC_; 00023 00024 //: Width of Gaussian function 00025 double rbf_width_; 00026 00027 public: 00028 00029 //: Dflt ctor 00030 clsfy_rbf_svm_smo_1_builder(); 00031 00032 //: Destructor 00033 virtual ~clsfy_rbf_svm_smo_1_builder() {} 00034 00035 //: Create empty model 00036 virtual clsfy_classifier_base* new_classifier() const{return new clsfy_rbf_svm();} 00037 00038 //: Build model from data 00039 // returns the empirical error, or +INF if there is an error. 00040 // nclasses should be 1. The members of outputs() should be 0 or 1. 00041 // An appropriate RBF width is chosen by the algorithm. 00042 virtual double build(clsfy_classifier_base& classifier, 00043 mbl_data_wrapper<vnl_vector<double> >& inputs, 00044 unsigned nClasses, 00045 const vcl_vector<unsigned> &outputs) const; 00046 00047 //: Build a classifier from data. 00048 // returns the empirical error rate, or +INF if there is an error. 00049 // The members of outputs() should be 0 or 1. 00050 virtual double build(clsfy_classifier_base& classifier, 00051 mbl_data_wrapper<vnl_vector<double> >& inputs, 00052 const vcl_vector<unsigned> &outputs) const; 00053 00054 //: Radius of Gaussian function 00055 double rbf_width() const; 00056 00057 //: Set the Radius of Gaussian function 00058 void set_rbf_width(double); 00059 00060 //: Set C, the upper bound on the Lagrange multipliers 00061 // 0 means no (or infinite) upper bound and is the default. 00062 // A finite value effectively allows the training data to encroach into 00063 // the separating margin. Smaller C -> smoother boundary 00064 void set_bound_on_multipliers(double C) 00065 { boundC_ = C; } 00066 00067 00068 //: The upper bound on the Lagrange multipliers 00069 // 0 means no (or infinite) upper bound. 00070 // A finite value effectively allows the training data to encroach into 00071 // the separating margin. Smaller C -> smoother boundary 00072 double bound_on_multipliers() const 00073 { return boundC_; } 00074 00075 //: Name of the class 00076 virtual vcl_string is_a() const; 00077 00078 //: Name of the class 00079 virtual bool is_class(vcl_string const& s) const; 00080 00081 //: Return the class's IO version number 00082 short version_no() const; 00083 00084 //: Create a copy on the heap and return base class pointer 00085 virtual clsfy_builder_base* clone() const; 00086 00087 //: Print class to os 00088 virtual void print_summary(vcl_ostream& os) const; 00089 00090 //: Save class to binary file stream 00091 virtual void b_write(vsl_b_ostream& bfs) const; 00092 00093 //: Load class from binary file stream 00094 virtual void b_read(vsl_b_istream& bfs); 00095 }; 00096 00097 #endif // clsfy_rbf_svm_smo_1_builder_h_
1.5.1