adaboost_ecoc.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef __LEMGA_MULTICLASS_ADABOOST_ECOC_H__
00003 #define __LEMGA_MULTICLASS_ADABOOST_ECOC_H__
00004 
00011 #include "multiclass_ecoc.h"
00012 #include "shared_ptr.h"
00013 
00014 namespace lemga {
00015 
00016 typedef std::vector<DataWgt> JointWgt;
00017 typedef const_shared_ptr<JointWgt> pJointWgt;
00018 
00021 class AdaBoost_ECOC : public MultiClass_ECOC {
00022 public:
00023     enum PARTITION_METHOD {
00024         RANDOM_HALF,
00025         MAX_CUT, MAX_CUT_GREEDY,
00026         RANDOM_2,
00027         MAX_2
00028     };
00029 
00030 protected:
00031     PARTITION_METHOD par_method;
00032 
00033 public:
00034     AdaBoost_ECOC () : MultiClass_ECOC(), par_method(MAX_CUT_GREEDY) {}
00035     AdaBoost_ECOC (const MultiClass_ECOC& s)
00036         : MultiClass_ECOC(s), par_method(MAX_CUT_GREEDY) {}
00037     explicit AdaBoost_ECOC (std::istream& is) { is >> *this; }
00038 
00039     virtual const id_t& id () const;
00040     virtual AdaBoost_ECOC* create () const { return new AdaBoost_ECOC(); }
00041     virtual AdaBoost_ECOC* clone () const {
00042         return new AdaBoost_ECOC(*this); }
00043 
00044     void set_partition_method (PARTITION_METHOD m) { par_method = m; }
00045 
00046 protected:
00049     JointWgt joint_wgt;
00052     mutable std::vector<bool> cur_err;
00054     mutable pDataWgt cur_smpwgt;
00055     pDataWgt smpwgt_with_partition (const ECOC_VECTOR&) const;
00056     pLearnModel train_with_full_partition (const ECOC_VECTOR&) const;
00057 
00058     virtual void setup_aux ();
00059     virtual bool ECOC_partition (UINT, ECOC_VECTOR&) const;
00060     virtual pLearnModel train_with_partition (ECOC_VECTOR&) const;
00061     virtual REAL assign_weight (const ECOC_VECTOR&, const LearnModel&) const;
00062     virtual void update_aux (const ECOC_VECTOR&);
00063 
00064     std::vector<std::vector<REAL> > confusion_matrix () const;
00065     ECOC_VECTOR max_cut (UINT) const;
00066     ECOC_VECTOR max_cut_greedy (UINT) const;
00067     ECOC_VECTOR random_half (UINT) const;
00068 };
00069 
00070 } // namespace lemga
00071 
00072 #ifdef  __ADABOOST_ECOC_H__
00073 #warning "This header file may conflict with another `adaboost_ecoc.h' file."
00074 #endif
00075 #define __ADABOOST_ECOC_H__
00076 #endif

Generated on Wed Nov 8 08:15:20 2006 for LEMGA by  doxygen 1.4.6