#include <crossval.h>
Inheritance diagram for CrossVal:
Public Member Functions | |
CrossVal () | |
CrossVal (const CrossVal &) | |
const CrossVal & | operator= (const CrossVal &) |
virtual CrossVal * | create () const =0 |
Create a new object using the default constructor. | |
virtual CrossVal * | clone () const =0 |
Create a new object by replicating itself. | |
void | add_model (const LearnModel &) |
add a candidate model to be cross-validated | |
UINT | size () const |
the number of candidate models under cross-validation | |
const LearnModel & | model (UINT n) const |
the n-th candidate model | |
UINT | rounds () const |
how many rounds of cross-validation? | |
void | set_rounds (UINT r) |
specifiy the number of rounds of cross-validation | |
bool | full_train () const |
train the best model on the full set? | |
void | set_full_train (bool f=true) |
virtual void | set_train_data (const pDataSet &, const pDataWgt &=0) |
Set the data set and sample weight to be used in training. | |
virtual void | train () |
Train with preset data set and sample weight. | |
virtual void | reset () |
virtual Output | operator() (const Input &x) const |
virtual Output | get_output (UINT i) const |
Get the output of the hypothesis on the idx-th input. | |
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 | error (UINT n) const |
the cross-validation error of the n-th candidate model | |
const LearnModel & | best_model () const |
the best model (trained if full_train() == true) | |
Protected Member Functions | |
virtual std::vector< REAL > | cv_round () const =0 |
one round of the cross-validation operation | |
virtual bool | serialize (std::ostream &, ver_list &) const |
virtual bool | unserialize (std::istream &, ver_list &, const id_t &=NIL_ID) |
Protected Attributes | |
bool | fullset |
train the best model on the full set? | |
std::vector< pcLearnModel > | lm |
all candidate models | |
std::vector< REAL > | err |
cross-validation errors | |
UINT | n_rounds |
# of CV rounds, to beat the variance | |
pLearnModel | best_lm |
the best model (trained on the full set) | |
int | best |
Definition at line 21 of file crossval.h.
|
Definition at line 33 of file crossval.h. |
|
Definition at line 15 of file crossval.cpp. References CrossVal::best, CrossVal::best_lm, and CrossVal::lm. |
|
add a candidate model to be cross-validated
Definition at line 93 of file crossval.cpp. References LearnModel::clone(), CrossVal::err, CrossVal::lm, and LearnModel::set_dimensions(). |
|
the best model (trained if full_train() == true)
Definition at line 79 of file crossval.h. References CrossVal::best, CrossVal::best_lm, and CrossVal::lm. |
|
Create a new object by replicating itself.
return new Derived(*this);
Implements LearnModel. Implemented in vFoldCrossVal, and HoldoutCrossVal. |
|
Create a new object using the default constructor. The code for a derived class Derived is always return new Derived(); Implements LearnModel. Implemented in vFoldCrossVal, and HoldoutCrossVal. |
|
one round of the cross-validation operation
Implemented in vFoldCrossVal, and HoldoutCrossVal. Referenced by CrossVal::train(). |
|
the cross-validation error of the n-th candidate model
Definition at line 76 of file crossval.h. References CrossVal::err, and CrossVal::size(). |
|
train the best model on the full set?
Definition at line 53 of file crossval.h. References CrossVal::fullset. |
|
Get the output of the hypothesis on the idx-th input.
Reimplemented from LearnModel. Definition at line 62 of file crossval.h. References CrossVal::best, CrossVal::best_lm, and LearnModel::ptd. |
|
Report the (unnormalized) margin of the example i.
Reimplemented from LearnModel. Definition at line 71 of file crossval.h. References CrossVal::best, CrossVal::best_lm, and LearnModel::ptd. |
|
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 from LearnModel. Definition at line 65 of file crossval.h. References CrossVal::best, and CrossVal::best_lm. |
|
Report the (unnormalized) margin of an example (x, y).
Reimplemented from LearnModel. Definition at line 68 of file crossval.h. References CrossVal::best, and CrossVal::best_lm. |
|
the n-th candidate model
Definition at line 45 of file crossval.h. References CrossVal::lm, and CrossVal::size(). |
|
Implements LearnModel. Definition at line 59 of file crossval.h. References CrossVal::best, and CrossVal::best_lm. |
|
Definition at line 26 of file crossval.cpp. References CrossVal::best, CrossVal::best_lm, CrossVal::err, CrossVal::fullset, CrossVal::lm, and CrossVal::n_rounds. |
|
Cleaning up the learning model but keeping most settings.
Reimplemented from LearnModel. Definition at line 128 of file crossval.cpp. References CrossVal::best, CrossVal::best_lm, CrossVal::err, and LearnModel::reset(). |
|
how many rounds of cross-validation?
Definition at line 49 of file crossval.h. References CrossVal::n_rounds. |
|
Reimplemented from LearnModel. Reimplemented in vFoldCrossVal, and HoldoutCrossVal. Definition at line 45 of file crossval.cpp. References CrossVal::best, CrossVal::best_lm, CrossVal::err, CrossVal::lm, SERIALIZE_PARENT, and CrossVal::size(). |
|
Definition at line 54 of file crossval.h. References CrossVal::fullset. |
|
specifiy the number of rounds of cross-validation
Definition at line 51 of file crossval.h. References CrossVal::n_rounds. Referenced by vFoldCrossVal::set_folds(), and HoldoutCrossVal::set_holdout(). |
|
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 from LearnModel. Definition at line 99 of file crossval.cpp. References CrossVal::best, CrossVal::best_lm, CrossVal::lm, and LearnModel::set_train_data(). Referenced by vFoldCrossVal::cv_round(). |
|
the number of candidate models under cross-validation
Definition at line 43 of file crossval.h. References CrossVal::err, and CrossVal::lm. Referenced by vFoldCrossVal::cv_round(), CrossVal::error(), CrossVal::model(), and CrossVal::serialize(). |
|
Train with preset data set and sample weight.
Implements LearnModel. Definition at line 108 of file crossval.cpp. References CrossVal::best, CrossVal::best_lm, CrossVal::cv_round(), CrossVal::err, CrossVal::fullset, CrossVal::lm, CrossVal::n_rounds, LearnModel::ptd, LearnModel::ptw, and LearnModel::set_dimensions(). |
|
Reimplemented from LearnModel. Reimplemented in vFoldCrossVal, and HoldoutCrossVal. Definition at line 63 of file crossval.cpp. References CrossVal::best, Object::create(), CrossVal::err, CrossVal::lm, Object::NIL_ID, UNSERIALIZE_PARENT, and LearnModel::valid_dimensions(). |
|
best_lm was actually lm[best]
Definition at line 28 of file crossval.h. Referenced by CrossVal::best_model(), CrossVal::CrossVal(), CrossVal::get_output(), CrossVal::margin(), CrossVal::margin_norm(), CrossVal::margin_of(), CrossVal::operator()(), CrossVal::operator=(), CrossVal::reset(), CrossVal::serialize(), CrossVal::set_train_data(), CrossVal::train(), and CrossVal::unserialize(). |
|
the best model (trained on the full set)
Definition at line 27 of file crossval.h. Referenced by CrossVal::best_model(), CrossVal::CrossVal(), CrossVal::get_output(), CrossVal::margin(), CrossVal::margin_norm(), CrossVal::margin_of(), CrossVal::operator()(), CrossVal::operator=(), CrossVal::reset(), CrossVal::serialize(), CrossVal::set_train_data(), and CrossVal::train(). |
|
cross-validation errors
Definition at line 25 of file crossval.h. Referenced by CrossVal::add_model(), CrossVal::error(), CrossVal::operator=(), CrossVal::reset(), CrossVal::serialize(), CrossVal::size(), CrossVal::train(), and CrossVal::unserialize(). |
|
train the best model on the full set?
Definition at line 23 of file crossval.h. Referenced by CrossVal::full_train(), CrossVal::operator=(), CrossVal::set_full_train(), and CrossVal::train(). |
|
all candidate models
Definition at line 24 of file crossval.h. Referenced by CrossVal::add_model(), CrossVal::best_model(), CrossVal::CrossVal(), vFoldCrossVal::cv_round(), CrossVal::model(), CrossVal::operator=(), CrossVal::serialize(), CrossVal::set_train_data(), CrossVal::size(), CrossVal::train(), and CrossVal::unserialize(). |
|
# of CV rounds, to beat the variance
Definition at line 26 of file crossval.h. Referenced by CrossVal::operator=(), CrossVal::rounds(), CrossVal::set_rounds(), and CrossVal::train(). |