Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

clsfy_adaboost_trainer.h

Go to the documentation of this file.
00001 // This is mul/clsfy/clsfy_adaboost_trainer.h
00002 #ifndef clsfy_adaboost_trainer_h_
00003 #define clsfy_adaboost_trainer_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Functions to train classifiers using AdaBoost algorithm
00010 // \author dac
00011 // \date   Fri Mar  1 23:49:39 2002
00012 //  Functions to train classifiers using AdaBoost algorithm
00013 //  AdaBoost combines a set of (usually simple, weak) classifiers into
00014 //  a more powerful single classifier.  Essentially it selects the
00015 //  classifiers one at a time, choosing the best at each step.
00016 //  The classifiers are trained to distinguish the examples mis-classified
00017 //  by the currently selected classifiers.
00018 
00019 #include <vcl_string.h>
00020 #include <vsl/vsl_binary_io.h>
00021 #include <clsfy/clsfy_simple_adaboost.h>
00022 #include <clsfy/clsfy_builder_1d.h>
00023 #include <mbl/mbl_data_wrapper.h>
00024 
00025 //=======================================================================
00026 
00027 //: A class for some purpose.
00028 // The purpose of this class is to prove that 1+1=3.
00029 class clsfy_adaboost_trainer
00030 {
00031  public:
00032 
00033   //: Dflt ctor
00034   clsfy_adaboost_trainer();
00035 
00036   //: Destructor
00037   virtual ~clsfy_adaboost_trainer();
00038 
00039   //: Build classifier composed of 1d classifiers working on individual vector elements
00040   //  Builds an n-component classifier, each component of which is a 1D classifier
00041   //  working on a single element of the input vector.
00042   void build_strong_classifier(clsfy_simple_adaboost& strong_classifier,
00043                                int max_n_clfrs,
00044                                clsfy_builder_1d& builder,
00045                                mbl_data_wrapper<vnl_vector<double> >& egs0,
00046                                mbl_data_wrapper<vnl_vector<double> >& egs1);
00047 
00048   //: Correctly classified examples have weights scaled by beta
00049   void clsfy_update_weights_weak(vnl_vector<double> &wts,
00050                                  const vnl_vector<double>& data,
00051                                  clsfy_classifier_1d& classifier,
00052                                  int class_number,
00053                                  double beta);
00054 
00055   //: Extracts the j-th element of each vector in data and puts into v
00056   void clsfy_get_elements(vnl_vector<double>& v,
00057                           mbl_data_wrapper<vnl_vector<double> >& data, int j);
00058 
00059   //: Version number for I/O
00060   short version_no() const;
00061 
00062   //: Name of the class
00063   vcl_string is_a() const;
00064 
00065   //: Name of the class
00066   virtual bool is_class(vcl_string const& s) const;
00067 
00068   //: Print class to os
00069   void print_summary(vcl_ostream& os) const;
00070 
00071   //: Save class to binary file stream.
00072   void b_write(vsl_b_ostream& bfs) const;
00073 
00074   //: Load class from binary file stream
00075   void b_read(vsl_b_istream& bfs);
00076 
00077  protected:
00078 #if 0
00079   // This is required if there are any references to objects
00080   // created on the heap. A deep copy should be made of anything
00081   // referred to by pointer during construction by copy. The copy
00082   // constructor is protected to stop its use for class
00083   // instantiation. It should be implemented in terms of the
00084   // assignment operator.
00085 
00086   //: Copy constructor
00087   clsfy_adaboost_trainer( const clsfy_adaboost_trainer& b );
00088 
00089   //: Assignment operator
00090   clsfy_adaboost_trainer& operator=( const clsfy_adaboost_trainer& b );
00091 #endif
00092 };
00093 
00094 //=======================================================================
00095 
00096 //: Binary file stream output operator for class reference
00097 void vsl_b_write(vsl_b_ostream& bfs, const clsfy_adaboost_trainer& b);
00098 
00099 //: Binary file stream input operator for class reference
00100 void vsl_b_read(vsl_b_istream& bfs, clsfy_adaboost_trainer& b);
00101 
00102 //: Stream output operator for class reference
00103 vcl_ostream& operator<<(vcl_ostream& os,const clsfy_adaboost_trainer& b);
00104 
00105 //: Stream output operator for class reference
00106 void vsl_print_summary(vcl_ostream& os,const clsfy_adaboost_trainer& b);
00107 
00108 #endif // clsfy_adaboost_trainer_h_

Generated on Thu Jan 10 14:43:44 2008 for contrib/mul/clsfy by  doxygen 1.4.4