Aggregating Class Reference

An abstract class for aggregating. More...

#include <aggregating.h>

Inheritance diagram for Aggregating:

Inheritance graph
[legend]
Collaboration diagram for Aggregating:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Aggregating ()
 Aggregating (const Aggregating &)
const Aggregatingoperator= (const Aggregating &)
virtual Aggregatingcreate () const =0
 Create a new object using the default constructor.
virtual Aggregatingclone () const =0
 Create a new object by replicating itself.
void set_max_models (UINT max)
virtual bool set_aggregation_size (UINT)
 Specify the number of hypotheses used in aggregating.
UINT aggregation_size () const
virtual void set_train_data (const pDataSet &, const pDataWgt &=0)
 Set the data set and sample weight to be used in training.
virtual void reset ()
void set_base_model (const LearnModel &)
 Set the base learning model.
const LearnModelbase_model () const
UINT size () const
 Total number of hypotheses.
bool empty () const
const LearnModelmodel (UINT n) const
const LearnModeloperator[] (UINT n) const

Protected Member Functions

virtual bool serialize (std::ostream &, ver_list &) const
virtual bool unserialize (std::istream &, ver_list &, const id_t &=NIL_ID)

Protected Attributes

pcLearnModel lm_base
 The base learning model.
std::vector< pLearnModellm
 Pointers to learning models.
UINT n_in_agg
 # of models in aggregating
UINT max_n_model
 Maximal # of models allowed.

Detailed Description

An abstract class for aggregating.

Aggregating in learning stands for a series of techniques which generate several hypotheses and combine them into a large and usually better one. Bagging and AdaBoost are two famous examples of such techniques. This class provides member functions to store and retrieve hypotheses used in aggregating.

The class has a vector of hypotheses, and a base learning model, which is the ``parent'' of all those hypotheses. For users of this class, a possible calling order for training is

  1. Aggregating *ag = new Some_Aggregating_Method (6, 5);
    Create an instance of aggregating with 6 as input dimension and 5 output dimension.
  2. ag->set_base_model(a_neural_net);
    Specify the base learning model (in this example, a neural network).
  3. Follow the normal calling order for training to complete the training.

We do not provide...?

Todo:
Documentation

Definition at line 40 of file aggregating.h.


Constructor & Destructor Documentation

Aggregating  )  [inline]
 

Definition at line 48 of file aggregating.h.

Aggregating const Aggregating a  ) 
 

Note:
Brand new models are used in the new born object. Thus any future change to the learning models a will not affect this model.

Definition at line 25 of file aggregating.cpp.

References Aggregating::lm, and Aggregating::n_in_agg.


Member Function Documentation

UINT aggregation_size  )  const [inline]
 

Definition at line 71 of file aggregating.h.

References Aggregating::n_in_agg.

const LearnModel& base_model  )  const [inline]
 

Definition at line 57 of file aggregating.h.

References Aggregating::lm_base.

virtual Aggregating* clone  )  const [pure virtual]
 

Create a new object by replicating itself.

Returns:
A pointer to the new copy.
The code for a derived class Derived is always
 return new Derived(*this); 
Though seemingly redundant, it helps to copy an object without knowing the real type of the object.
See also:
C++ FAQ Lite 20.6

Implements LearnModel.

Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Bagging, Boosting, Cascade, CGBoost, LPBoost, MgnBoost, and MultiClass_ECOC.

virtual Aggregating* create  )  const [pure virtual]
 

Create a new object using the default constructor.

The code for a derived class Derived is always

 return new Derived(); 

Implements LearnModel.

Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Bagging, Boosting, Cascade, CGBoost, LPBoost, MgnBoost, and MultiClass_ECOC.

bool empty  )  const [inline]
 

Definition at line 65 of file aggregating.h.

References Aggregating::lm.

const LearnModel& model UINT  n  )  const [inline]
 

Definition at line 66 of file aggregating.h.

References Aggregating::lm.

const Aggregating & operator= const Aggregating a  ) 
 

Note:
Brand new models are used in the new born object. Thus any future change to the learning models a will not affect this model.

Definition at line 36 of file aggregating.cpp.

References Aggregating::lm, Aggregating::lm_base, Aggregating::max_n_model, and Aggregating::n_in_agg.

const LearnModel& operator[] UINT  n  )  const [inline]
 

Definition at line 67 of file aggregating.h.

References Aggregating::lm.

void reset  )  [virtual]
 

Delete learning models stored in lm. This is only used in operator= and load().

Note:
lm_base is not deleted since load() will need it
Todo:
make it public under the name clear()? Or remove it

Reimplemented from LearnModel.

Reimplemented in Boosting, CGBoost, and MultiClass_ECOC.

Definition at line 15 of file aggregating.cpp.

References Aggregating::lm, Aggregating::lm_base, Aggregating::n_in_agg, LearnModel::reset(), and LearnModel::valid_dimensions().

Referenced by MultiClass_ECOC::reset(), and Boosting::reset().

bool serialize std::ostream &  ,
ver_list
const [protected, virtual]
 

Reimplemented from LearnModel.

Reimplemented in Boosting, Cascade, CGBoost, and MultiClass_ECOC.

Definition at line 53 of file aggregating.cpp.

References Aggregating::lm, Aggregating::lm_base, and SERIALIZE_PARENT.

bool set_aggregation_size UINT  n  )  [virtual]
 

Specify the number of hypotheses used in aggregating.

Returns:
false if n is larger than size().
Usually all the hypotheses are used in aggregating. However, a smaller number n can also be specified so that only the first n hypotheses are used.

Reimplemented in CGBoost, and LPBoost.

Definition at line 114 of file aggregating.cpp.

References Aggregating::n_in_agg, and Aggregating::size().

Referenced by CGBoost::set_aggregation_size().

void set_base_model const LearnModel blm  ) 
 

Set the base learning model.

Todo:
Allowed to call when !empty()?

Definition at line 102 of file aggregating.cpp.

References LearnModel::clone(), Aggregating::lm_base, and LearnModel::valid_dimensions().

void set_max_models UINT  max  )  [inline]
 

Definition at line 60 of file aggregating.h.

References Aggregating::max_n_model.

Referenced by MultiClass_ECOC::set_ECOC_table().

void set_train_data const pDataSet pd,
const pDataWgt pw = 0
[virtual]
 

Set the data set and sample weight to be used in training.

If the learning model/algorithm can only do training using uniform sample weight, i.e., support_weighted_data() returns false, a ``boostrapped'' copy of the original data set will be generated and used in the following training. The boostrapping is done by randomly pick samples (with replacement) w.r.t. the given weight pw.

In order to make the life easier, when support_weighted_data() returns true, a null pw will be replaced by a uniformly distributed probability vector. So we have the following invariant

Invariant:
support_weighted_data() == (ptw != 0)
Parameters:
pd gives the data set.
pw gives the sample weight, whose default value is 0.
See also:
support_weighted_data(), train()

Reimplemented from LearnModel.

Reimplemented in Boosting, and MultiClass_ECOC.

Definition at line 122 of file aggregating.cpp.

References Aggregating::lm, LearnModel::ptd, LearnModel::ptw, and LearnModel::set_train_data().

Referenced by MultiClass_ECOC::set_train_data(), and Boosting::set_train_data().

UINT size  )  const [inline]
 

Total number of hypotheses.

Definition at line 64 of file aggregating.h.

References Aggregating::lm.

Referenced by _boost_gd::_boost_gd(), MultiClass_ECOC::ECOC_partition(), Bagging::operator()(), MultiClass_ECOC::serialize(), CGBoost::serialize(), CGBoost::set_aggregation_size(), Aggregating::set_aggregation_size(), MultiClass_ECOC::set_ECOC_table(), Boosting::train(), Bagging::train(), and CGBoost::unserialize().

bool unserialize std::istream &  ,
ver_list ,
const id_t = NIL_ID
[protected, virtual]
 

Reimplemented from LearnModel.

Reimplemented in Boosting, Cascade, CGBoost, and MultiClass_ECOC.

Definition at line 66 of file aggregating.cpp.

References LearnModel::_n_in, LearnModel::_n_out, Object::create(), LearnModel::exact_dimensions(), Aggregating::lm, Aggregating::lm_base, Object::NIL_ID, UNSERIALIZE_PARENT, and LearnModel::valid_dimensions().


Member Data Documentation

std::vector<pLearnModel> lm [protected]
 

Pointers to learning models.

Definition at line 43 of file aggregating.h.

Referenced by Aggregating::Aggregating(), MultiClass_ECOC::distances(), Aggregating::empty(), Boosting::get_output(), _boost_gd::gradient(), Aggregating::model(), Cascade::operator()(), Boosting::operator()(), Bagging::operator()(), Aggregating::operator=(), Aggregating::operator[](), Aggregating::reset(), MultiClass_ECOC::serialize(), Cascade::serialize(), Boosting::serialize(), Aggregating::serialize(), Aggregating::set_train_data(), _boost_gd::set_weight(), Aggregating::size(), MultiClass_ECOC::train(), Boosting::train(), Bagging::train(), MultiClass_ECOC::unserialize(), Cascade::unserialize(), Boosting::unserialize(), Aggregating::unserialize(), Boosting::update_smpwgt(), and _boost_gd::weight().

pcLearnModel lm_base [protected]
 

The base learning model.

Definition at line 42 of file aggregating.h.

Referenced by Aggregating::base_model(), Aggregating::operator=(), Aggregating::reset(), Aggregating::serialize(), Aggregating::set_base_model(), MultiClass_ECOC::train(), LPBoost::train(), Boosting::train(), Bagging::train(), AdaBoost_ECOC::train_with_full_partition(), AdaBoost_ERP::train_with_partial_partition(), MultiClass_ECOC::train_with_partition(), Boosting::train_with_smpwgt(), and Aggregating::unserialize().

UINT max_n_model [protected]
 

Maximal # of models allowed.

Definition at line 45 of file aggregating.h.

Referenced by _boost_gd::_boost_gd(), Aggregating::operator=(), MultiClass_ECOC::set_ECOC_table(), Aggregating::set_max_models(), MultiClass_ECOC::train(), Boosting::train(), Bagging::train(), and Boosting::train_with_smpwgt().

UINT n_in_agg [protected]
 

# of models in aggregating

Definition at line 44 of file aggregating.h.

Referenced by Aggregating::Aggregating(), Aggregating::aggregation_size(), MultiClass_ECOC::distances(), Boosting::get_output(), CGBoost::linear_smpwgt(), AdaBoost::linear_smpwgt(), Bagging::margin_norm(), Boosting::model_weight_sum(), Cascade::operator()(), Boosting::operator()(), Bagging::operator()(), Aggregating::operator=(), Aggregating::reset(), Boosting::sample_weight(), Aggregating::set_aggregation_size(), _boost_cg::set_weight(), _boost_gd::set_weight(), AdaBoost_ECOC::setup_aux(), MultiClass_ECOC::train(), Boosting::train(), Bagging::train(), Boosting::train_with_smpwgt(), AdaBoost_ECOC::update_aux(), and Boosting::update_smpwgt().


The documentation for this class was generated from the following files:
Generated on Wed Nov 8 08:16:39 2006 for LEMGA by  doxygen 1.4.6