00001 // This is mul/clsfy/clsfy_binary_1d_wrapper_builder.h 00002 // Copyright: (C) 2000 British Telecommunications PLC 00003 #ifndef clsfy_binary_1d_wrapper_builder_h_ 00004 #define clsfy_binary_1d_wrapper_builder_h_ 00005 //: 00006 // \file 00007 // \brief Wrap a builder_1d in general builder_base derivative. 00008 // \author Ian Scott 00009 // \date 2 Sep 2009 00010 00011 #include <vcl_iosfwd.h> 00012 #include <mbl/mbl_cloneable_ptr.h> 00013 #include <clsfy/clsfy_binary_1d_wrapper.h> 00014 #include <clsfy/clsfy_builder_1d.h> 00015 #include <clsfy/clsfy_builder_base.h> 00016 00017 //: Wrap a builder_1d in general builder_base derivative. 00018 class clsfy_binary_1d_wrapper_builder : public clsfy_builder_base 00019 { 00020 mbl_cloneable_nzptr<clsfy_builder_1d> builder_1d_; 00021 00022 public: 00023 // Dflt ctor 00024 clsfy_binary_1d_wrapper_builder(); 00025 00026 //: Set the underlying builder. 00027 // The object will take and maintain its own deep copy of the data. 00028 // This method should only be used by builders. 00029 void set_builder_1d(const clsfy_builder_1d &builder) 00030 { builder_1d_ = builder; } 00031 00032 //: Get the underlying builder. 00033 const clsfy_builder_1d &builder_1d() const 00034 { return *builder_1d_; } 00035 00036 //: Create a new untrained linear classifier with binary output 00037 virtual clsfy_classifier_base* new_classifier() const; 00038 00039 //: Build a linear classifier, with the given data. 00040 // Return the mean error over the training set. 00041 double build(clsfy_classifier_base &classifier, 00042 mbl_data_wrapper<vnl_vector<double> > &inputs, 00043 const vcl_vector<unsigned> &outputs) const; 00044 00045 //: Build a linear classifier, with the given data. 00046 // Return the mean error over the training set. 00047 // n_classes must be 1 00048 double build(clsfy_classifier_base &classifier, 00049 mbl_data_wrapper<vnl_vector<double> > &inputs, 00050 unsigned n_classes, const vcl_vector<unsigned> &outputs) const; 00051 00052 00053 //: Name of the class 00054 vcl_string is_a() const; 00055 00056 //: Name of the class 00057 virtual bool is_class(vcl_string const& s) const; 00058 00059 //: Print class to os 00060 void print_summary(vcl_ostream& os) const; 00061 00062 //: Create a deep copy. 00063 // client is responsible for deleting returned object. 00064 virtual clsfy_builder_base* clone() const 00065 { return new clsfy_binary_1d_wrapper_builder(*this); } 00066 00067 virtual void b_write(vsl_b_ostream &) const; 00068 virtual void b_read(vsl_b_istream &); 00069 00070 //: Initialise the parameters from a text stream. 00071 void config(vcl_istream &as); 00072 00073 }; 00074 00075 #endif // clsfy_binary_1d_wrapper_builder_h_