ordinal_ble.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef __LEMGA_ORDINAL_BLE_H__
00003 #define __LEMGA_ORDINAL_BLE_H__
00004 
00011 #include "learnmodel.h"
00012 #include "multiclass_ecoc.h" // ECOC_VECTOR & ECOC_TABLE
00013 
00014 namespace lemga {
00015 typedef std::vector<std::vector<REAL> > EXT_TABLE;
00016 enum BLE_TYPE {
00017     MULTI_THRESHOLD,
00018     BLE_DEFAULT = MULTI_THRESHOLD
00019 };
00020 
00023 class Ordinal_BLE : public LearnModel {
00024 protected:
00025     pLearnModel lm;     
00026     bool full_ext;      
00027     ECOC_TABLE out_tab; 
00028     EXT_TABLE ext_tab;  
00029     UINT n_ext;
00030 
00031 public:
00032     Ordinal_BLE () : full_ext(true), n_ext(0), d_nrank(0)
00033     { set_dimensions(0, 1); }
00034     Ordinal_BLE (const Ordinal_BLE&);
00035     const Ordinal_BLE& operator= (const Ordinal_BLE&);
00036     explicit Ordinal_BLE (std::istream& is) { is >> *this; }
00037 
00038     virtual const id_t& id () const;
00039     virtual Ordinal_BLE* create () const { return new Ordinal_BLE(); }
00040     virtual Ordinal_BLE* clone () const { return new Ordinal_BLE(*this); }
00041 
00043     void set_model (const LearnModel&);
00045     const LearnModel& model () const { assert(lm != 0); return *lm; }
00046 
00048     bool full_extension () const { return full_ext; }
00049     void set_full_extension (bool = true);
00050     const ECOC_TABLE& ECOC_table () const { return out_tab; }
00051     const EXT_TABLE& extension_table () const { return ext_tab; }
00052     void set_tables (const ECOC_TABLE&, const EXT_TABLE&);
00053     void set_tables (BLE_TYPE, UINT);
00055 
00057     UINT n_rank () const { return d_nrank; }
00058 
00059     virtual bool support_weighted_data () const { return true; }
00060     virtual REAL c_error (const Output& out, const Output& y) const;
00061     virtual REAL r_error (const Output& out, const Output& y) const;
00062     virtual void set_train_data (const pDataSet&, const pDataWgt& = 0);
00063     virtual void train ();
00064     virtual void reset ();
00065     virtual Output operator() (const Input&) const;
00066 
00067 protected:
00068     pDataSet ext_d;     
00069     pDataWgt ext_w;     
00070     UINT d_nrank;       
00071     bool reset_data;    
00072 
00073     void extend_input (const Input&, UINT, Input&) const;
00074     void extend_example (const Input&, UINT, UINT, Input&, REAL&) const;
00075     void extend_data ();
00076 
00077     virtual REAL ECOC_distance (const Output&, const ECOC_VECTOR&) const;
00078     mutable std::vector<REAL> local_d;
00079     const std::vector<REAL>& distances (const Input&) const;
00080 
00081     virtual bool serialize (std::ostream&, ver_list&) const;
00082     virtual bool unserialize (std::istream&, ver_list&, const id_t& = NIL_ID);
00083 };
00084 
00085 } // namespace lemga
00086 
00087 #ifdef  __ORDINAL_BLE_H__
00088 #warning "This header file may conflict with another `ordinal_ble.h' file."
00089 #endif
00090 #define __ORDINAL_BLE_H__
00091 #endif

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