00001 // This is mul/clsfy/clsfy_random_builder.h 00002 // Copyright: (C) 2001 British Telecommunications plc 00003 #ifndef clsfy_random_builder_h_ 00004 #define clsfy_random_builder_h_ 00005 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00006 #pragma interface 00007 #endif 00008 //: 00009 // \file 00010 // \brief Describe a random classifier builder 00011 // \author Ian Scott 00012 // \date 2001-10-07 00013 00014 //======================================================================= 00015 00016 #include <clsfy/clsfy_builder_base.h> 00017 #include <vcl_vector.h> 00018 #include <vcl_string.h> 00019 #include <vcl_iosfwd.h> 00020 #include <mbl/mbl_data_wrapper.h> 00021 #include <vnl/vnl_vector.h> 00022 00023 00024 //: Builds clsfy_random_classifier classifiers. 00025 // This class doesn't do any calculation, it is easy to create a 00026 // random classifier directly - but it allows for consistent swappable 00027 // classifiers. 00028 class clsfy_random_builder : public clsfy_builder_base 00029 { 00030 //: Standard deviation of confidence noise added to class probabilities 00031 double confidence_; 00032 00033 public: 00034 // Dflt ctor 00035 clsfy_random_builder(); 00036 00037 //: Create empty model 00038 // Caller is responsible for deletion 00039 virtual clsfy_classifier_base* new_classifier() const; 00040 00041 //: Build classifier from data 00042 // return the mean error over the training set. 00043 virtual double build(clsfy_classifier_base& model, 00044 mbl_data_wrapper<vnl_vector<double> >& inputs, 00045 unsigned nClasses, 00046 const vcl_vector<unsigned> &outputs) const; 00047 00048 //: Name of the class 00049 virtual vcl_string is_a() const; 00050 00051 //: Name of the class 00052 virtual bool is_class(vcl_string const& s) const; 00053 00054 //: IO Version number 00055 short version_no() const; 00056 00057 //: Create a copy on the heap and return base class pointer 00058 virtual clsfy_builder_base* clone() const; 00059 00060 //: Print class to os 00061 virtual void print_summary(vcl_ostream& os) const; 00062 00063 //: Save class to binary file stream 00064 virtual void b_write(vsl_b_ostream& bfs) const; 00065 00066 //: Load class from binary file stream 00067 virtual void b_read(vsl_b_istream& bfs); 00068 00069 //: The standard deviation of confidence noise added to class probabilities. 00070 double confidence() const; 00071 00072 //: Set the standard deviation of confidence noise added to class probabilities. 00073 void set_confidence(double); 00074 }; 00075 00076 //: Binary file stream output operator for class reference 00077 void vsl_b_write(vsl_b_ostream& bfs, const clsfy_random_builder& b); 00078 00079 //: Binary file stream input operator for class reference 00080 void vsl_b_read(vsl_b_istream& bfs, clsfy_random_builder& b); 00081 00082 //: Stream output operator for class reference 00083 vcl_ostream& operator<<(vcl_ostream& os,const clsfy_random_builder& b); 00084 00085 #endif // clsfy_random_builder_h_