#include <learnmodel.h>
Inheritance diagram for LearnModel:
Public Member Functions | |
LearnModel (UINT n_in=0, UINT n_out=0) | |
virtual Output | operator() (const Input &) const =0 |
virtual Output | get_output (UINT idx) const |
Get the output of the hypothesis on the idx-th input. | |
bool | valid_dimensions (UINT, UINT) const |
bool | valid_dimensions (const LearnModel &l) const |
bool | exact_dimensions (UINT i, UINT o) const |
bool | exact_dimensions (const LearnModel &l) const |
bool | exact_dimensions (const DataSet &d) const |
virtual LearnModel * | create () const =0 |
Create a new object using the default constructor. | |
virtual LearnModel * | clone () const =0 |
Create a new object by replicating itself. | |
UINT | n_input () const |
UINT | n_output () const |
void | set_log_file (FILE *f) |
virtual bool | support_weighted_data () const |
Whether the learning model/algorithm supports unequally weighted data. | |
virtual REAL | r_error (const Output &out, const Output &y) const |
Error measure for regression problems. | |
virtual REAL | c_error (const Output &out, const Output &y) const |
Error measure for classification problems. | |
REAL | train_r_error () const |
Training error (regression). | |
REAL | train_c_error () const |
Training error (classification). | |
REAL | test_r_error (const pDataSet &) const |
Test error (regression). | |
REAL | test_c_error (const pDataSet &) const |
Test error (classification). | |
virtual void | initialize () |
virtual void | set_train_data (const pDataSet &, const pDataWgt &=0) |
Set the data set and sample weight to be used in training. | |
const pDataSet & | train_data () const |
Return pointer to the embedded training data set. | |
virtual void | train ()=0 |
Train with preset data set and sample weight. | |
virtual void | reset () |
virtual REAL | margin_norm () const |
The normalization term for margins. | |
virtual REAL | margin_of (const Input &x, const Output &y) const |
Report the (unnormalized) margin of an example (x, y). | |
virtual REAL | margin (UINT i) const |
Report the (unnormalized) margin of the example i. | |
REAL | min_margin () const |
The minimal (unnormalized) in-sample margin. | |
Protected Member Functions | |
void | set_dimensions (UINT, UINT) |
void | set_dimensions (const LearnModel &l) |
void | set_dimensions (const DataSet &d) |
virtual bool | serialize (std::ostream &, ver_list &) const |
virtual bool | unserialize (std::istream &, ver_list &, const id_t &=NIL_ID) |
Protected Attributes | |
UINT | _n_in |
input dimension of the model | |
UINT | _n_out |
output dimension of the model | |
pDataSet | ptd |
pointer to the training data set | |
pDataWgt | ptw |
pointer to the sample weight (for training) | |
UINT | n_samples |
equal to ptd->size() | |
FILE * | logf |
file to record train/validate error |
I try to provide + r_error and c_error for regression problems, r_error should be defined; for classification problems, c_error should be defined; these two errors can both be present
The training data is stored with the learning model (as a pointer) Say: why (the benefit of store with, a pointer); maybe not a pointer Say: what's the impact of doing this (what will be changed from normal implementation) Say: wgt: could be null if the model doesn't support ...otherwise shoud be a probability vector (randome_sample)...
The flowchart of the learning ...
lm->reset();
.lm->set_train_data(sample_data);
err = lm->train();
y = (*lm)(x);
Do we really need two errors?
Definition at line 64 of file learnmodel.h.
|
Definition at line 70 of file learnmodel.cpp. |
|
Error measure for classification problems.
Reimplemented in MultiClass_ECOC, and Ordinal_BLE. Definition at line 112 of file learnmodel.cpp. References INFINITESIMAL, and LearnModel::n_output(). Referenced by CGBoost::linear_weight(), AdaBoost::linear_weight(), lemga::lp_add_hypothesis(), LearnModel::test_c_error(), and LearnModel::train_c_error(). |
|
Create a new object by replicating itself.
return new Derived(*this);
Implements Object. Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Aggregating, Bagging, Boosting, Cascade, CGBoost, CrossVal, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. Referenced by CrossVal::add_model(), Aggregating::set_base_model(), and Ordinal_BLE::set_model(). |
|
Create a new object using the default constructor. The code for a derived class Derived is always return new Derived(); Implements Object. Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Aggregating, Bagging, Boosting, Cascade, CGBoost, CrossVal, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. |
|
Definition at line 179 of file learnmodel.h. References LearnModel::exact_dimensions(), dataset::size(), dataset::x(), and dataset::y(). |
|
Definition at line 177 of file learnmodel.h. References LearnModel::exact_dimensions(), LearnModel::n_input(), and LearnModel::n_output(). |
|
Definition at line 175 of file learnmodel.h. References LearnModel::valid_dimensions(). Referenced by LearnModel::exact_dimensions(), Boosting::get_output(), CGBoost::linear_weight(), AdaBoost::linear_weight(), Boosting::operator()(), Bagging::operator()(), LearnModel::set_dimensions(), and Aggregating::unserialize(). |
|
Get the output of the hypothesis on the idx-th input.
Reimplemented in Boosting, CrossVal, and MultiClass_ECOC. Definition at line 139 of file learnmodel.h. References LearnModel::operator()(), LearnModel::ptd, and LearnModel::ptw. Referenced by FeedForwardNN::cost(), lemga::op::inner_product(), CGBoost::linear_weight(), AdaBoost::linear_weight(), lemga::lp_add_hypothesis(), LearnModel::train_c_error(), and LearnModel::train_r_error(). |
|
Reimplemented in FeedForwardNN, NNLayer, Perceptron, and SVM. Definition at line 110 of file learnmodel.h. |
|
Report the (unnormalized) margin of the example i.
Reimplemented in Boosting, CrossVal, and MultiClass_ECOC. Definition at line 164 of file learnmodel.h. References LearnModel::margin_of(), LearnModel::ptd, and LearnModel::ptw. Referenced by LearnModel::min_margin(). |
|
The normalization term for margins. The margin concept can be normalized or unnormalized. For example, for a perceptron model, the unnormalized margin would be the wegithed sum of the input features, and the normalized margin would be the distance to the hyperplane, and the normalization term is the norm of the hyperplane weight. Since the normalization term is usually a constant, it would be more efficient if it is precomputed instead of being calculated every time when a margin is asked for. The best way is to use a cache. Here I use a easier way: let the users decide when to compute the normalization term. Reimplemented in Bagging, Boosting, CrossVal, Perceptron, and SVM. Definition at line 158 of file learnmodel.h. |
|
Report the (unnormalized) margin of an example (x, y).
Reimplemented in Bagging, Boosting, CrossVal, MultiClass_ECOC, Perceptron, and SVM. Definition at line 199 of file learnmodel.cpp. References OBJ_FUNC_UNDEFINED. Referenced by LearnModel::margin(). |
|
The minimal (unnormalized) in-sample margin.
Definition at line 203 of file learnmodel.cpp. References INFINITESIMAL, INFINITY, LearnModel::margin(), LearnModel::n_samples, and LearnModel::ptw. |
|
Definition at line 81 of file learnmodel.h. References LearnModel::_n_in. Referenced by FeedForwardNN::add_top(), NNLayer::back_propagate(), LearnModel::exact_dimensions(), NNLayer::feed_forward(), SVM::operator()(), Stump::operator()(), Pulse::operator()(), Perceptron::operator()(), FeedForwardNN::operator()(), LearnModel::set_dimensions(), Pulse::set_index(), SVM::signed_margin(), and LearnModel::valid_dimensions(). |
|
|
Implemented in Bagging, Boosting, Cascade, CrossVal, FeedForwardNN, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. Referenced by LearnModel::get_output(). |
|
Error measure for regression problems.
Reimplemented in Ordinal_BLE. Definition at line 94 of file learnmodel.cpp. References LearnModel::_n_out, and LearnModel::n_output(). Referenced by FeedForwardNN::_cost(), LearnModel::test_r_error(), and LearnModel::train_r_error(). |
|
Cleaning up the learning model but keeping most settings.
Reimplemented in Aggregating, Boosting, CGBoost, CrossVal, MultiClass_ECOC, and Ordinal_BLE. Definition at line 195 of file learnmodel.cpp. References LearnModel::_n_in, and LearnModel::_n_out. Referenced by Ordinal_BLE::reset(), CrossVal::reset(), and Aggregating::reset(). |
|
Reimplemented in Aggregating, Boosting, Cascade, CGBoost, CrossVal, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. Definition at line 74 of file learnmodel.cpp. References LearnModel::_n_in, LearnModel::_n_out, and SERIALIZE_PARENT. |
|
Definition at line 187 of file learnmodel.h. References LearnModel::exact_dimensions(), LearnModel::set_dimensions(), dataset::x(), and dataset::y(). |
|
Definition at line 185 of file learnmodel.h. References LearnModel::n_input(), LearnModel::n_output(), and LearnModel::set_dimensions(). |
|
|
Definition at line 84 of file learnmodel.h. References LearnModel::logf. |
|
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
In order to make the life easier, when support_weighted_data() returns
Reimplemented in Aggregating, Boosting, CrossVal, MultiClass_ECOC, and Ordinal_BLE. Definition at line 165 of file learnmodel.cpp. References EPSILON, LearnModel::n_samples, LearnModel::ptd, LearnModel::ptw, and LearnModel::support_weighted_data(). Referenced by Ordinal_BLE::set_train_data(), CrossVal::set_train_data(), Aggregating::set_train_data(), Bagging::train(), and AdaBoost_ECOC::train_with_full_partition(). |
|
Whether the learning model/algorithm supports unequally weighted data.
Reimplemented in Bagging, Boosting, Cascade, FeedForwardNN, MultiClass_ECOC, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. Definition at line 94 of file learnmodel.h. Referenced by LearnModel::set_train_data(). |
|
Test error (classification).
Definition at line 142 of file learnmodel.cpp. References LearnModel::c_error(). |
|
Test error (regression).
Definition at line 134 of file learnmodel.cpp. References LearnModel::r_error(). |
|
Train with preset data set and sample weight.
Implemented in AdaBoost, Bagging, Boosting, Cascade, CGBoost, CrossVal, FeedForwardNN, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. Referenced by Bagging::train(), and AdaBoost_ECOC::train_with_full_partition(). |
|
Training error (classification).
Definition at line 126 of file learnmodel.cpp. References LearnModel::c_error(), LearnModel::get_output(), LearnModel::n_samples, LearnModel::ptd, and LearnModel::ptw. Referenced by Perceptron::log_error(), and Boosting::train(). |
|
Return pointer to the embedded training data set.
Definition at line 118 of file learnmodel.h. References LearnModel::ptd. Referenced by Boosting::get_output(), lemga::op::inner_product(), CGBoost::linear_weight(), AdaBoost::linear_weight(), and lemga::lp_add_hypothesis(). |
|
Training error (regression).
Definition at line 118 of file learnmodel.cpp. References LearnModel::get_output(), LearnModel::n_samples, LearnModel::ptd, LearnModel::ptw, and LearnModel::r_error(). |
|
Reimplemented in Aggregating, Boosting, Cascade, CGBoost, CrossVal, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM. Definition at line 80 of file learnmodel.cpp. References LearnModel::_n_in, LearnModel::_n_out, LearnModel::n_samples, Object::NIL_ID, LearnModel::ptd, LearnModel::ptw, and UNSERIALIZE_PARENT. |
|
Definition at line 172 of file learnmodel.h. References LearnModel::n_input(), LearnModel::n_output(), and LearnModel::valid_dimensions(). |
|
Definition at line 214 of file learnmodel.cpp. References LearnModel::_n_in, and LearnModel::_n_out. Referenced by LearnModel::exact_dimensions(), Ordinal_BLE::operator()(), Aggregating::reset(), Aggregating::set_base_model(), LearnModel::set_dimensions(), CrossVal::unserialize(), Aggregating::unserialize(), and LearnModel::valid_dimensions(). |
|
|
|
file to record train/validate error
Definition at line 72 of file learnmodel.h. Referenced by FeedForwardNN::log_cost(), Perceptron::log_error(), and LearnModel::set_log_file(). |
|
|
|