ALPHA VERSION, STILL UNDER CONSTRUCTION. More...
Public Types | |
typedef TLearner | Learner |
Typedef of internal learners used. | |
typedef TLearner | Learner |
Typedef of internal learners used. | |
Public Member Functions | |
const Matrix & | clsf_confusion_matrix () const |
Gets the confusion matrix. | |
const Matrix & | clsf_confusion_matrix () const |
Gets the confusion matrix. | |
index_t | clsf_n_correct () |
Functions for type 0: classification ONLY. | |
index_t | clsf_n_correct () |
Functions for type 0: classification ONLY. | |
index_t | clsf_n_incorrect () |
Gets the number incorrect over all folds. | |
index_t | clsf_n_incorrect () |
Gets the number incorrect over all folds. | |
double | clsf_portion_correct () |
Gets the portion calculated correct. | |
double | clsf_portion_correct () |
Gets the portion calculated correct. | |
const Dataset & | data () const |
Gets the dataset. | |
const Dataset & | data () const |
Gets the dataset. | |
void | Init (int learner_typeid, int default_k, const Dataset *data_input, struct datanode *module_root, const char *learner_fx_name, const char *kfold_fx_name="kfold") |
Uses FastExec to initialize this. | |
void | Init (int learner_typeid, int default_k, const Dataset *data_input, struct datanode *module_root, const char *learner_fx_name, const char *kfold_fx_name="kfold") |
Uses FastExec to initialize this. | |
void | Run (bool randomized) |
Runs cross-validation. | |
void | Run (bool randomized) |
Runs cross-validation. |
ALPHA VERSION, STILL UNDER CONSTRUCTION.
k-fold Cross-validator for general learners (can support Classification, Regression, Density Estimation and other learners)
For classification, the Stratified Cross-Validation is used to ensure that approximately same portion of data (training/validation) are used for each class.
For regression, density estimation and other learners, training and validation data are then drawn from the partitions of input dataset (may be firstly randomized if necessary).
Definition at line 361 of file crossvalidation.h.
typedef TLearner GeneralCrossValidator< TLearner >::Learner |
Typedef of internal learners used.
Definition at line 366 of file crossvalidation.h.
typedef TLearner GeneralCrossValidator< TLearner >::Learner |
Typedef of internal learners used.
Definition at line 366 of file crossvalidation.h.
const Matrix& GeneralCrossValidator< TLearner >::clsf_confusion_matrix | ( | ) | const [inline] |
Gets the confusion matrix.
The element at row i column j is the number of training samples where the actual classification is i but the predicted classification is j.
Definition at line 464 of file crossvalidation.h.
const Matrix& GeneralCrossValidator< TLearner >::clsf_confusion_matrix | ( | ) | const [inline] |
Gets the confusion matrix.
The element at row i column j is the number of training samples where the actual classification is i but the predicted classification is j.
Definition at line 464 of file crossvalidation.h.
index_t GeneralCrossValidator< TLearner >::clsf_n_correct | ( | ) | [inline] |
Functions for type 0: classification ONLY.
Gets the number correctly classified over all folds.
Definition at line 447 of file crossvalidation.h.
index_t GeneralCrossValidator< TLearner >::clsf_n_correct | ( | ) | [inline] |
Functions for type 0: classification ONLY.
Gets the number correctly classified over all folds.
Definition at line 447 of file crossvalidation.h.
Referenced by GeneralCrossValidator< TLearner >::Run().
index_t GeneralCrossValidator< TLearner >::clsf_n_incorrect | ( | ) | [inline] |
Gets the number incorrect over all folds.
Definition at line 451 of file crossvalidation.h.
References Dataset::n_points().
index_t GeneralCrossValidator< TLearner >::clsf_n_incorrect | ( | ) | [inline] |
Gets the number incorrect over all folds.
Definition at line 451 of file crossvalidation.h.
References Dataset::n_points().
Referenced by GeneralCrossValidator< TLearner >::Run().
double GeneralCrossValidator< TLearner >::clsf_portion_correct | ( | ) | [inline] |
Gets the portion calculated correct.
Definition at line 455 of file crossvalidation.h.
References Dataset::n_points().
double GeneralCrossValidator< TLearner >::clsf_portion_correct | ( | ) | [inline] |
Gets the portion calculated correct.
Definition at line 455 of file crossvalidation.h.
References Dataset::n_points().
Referenced by GeneralCrossValidator< TLearner >::Run().
const Dataset& GeneralCrossValidator< TLearner >::data | ( | ) | const [inline] |
Gets the dataset.
Definition at line 433 of file crossvalidation.h.
const Dataset& GeneralCrossValidator< TLearner >::data | ( | ) | const [inline] |
Gets the dataset.
Definition at line 433 of file crossvalidation.h.
void GeneralCrossValidator< TLearner >::Init | ( | int | learner_typeid, | |
int | default_k, | |||
const Dataset * | data_input, | |||
struct datanode * | module_root, | |||
const char * | learner_fx_name, | |||
const char * | kfold_fx_name = "kfold" | |||
) |
Uses FastExec to initialize this.
See details about this class for more information.
learner_typeid | type id of the learner; 0:classification 1:regression 2:density estimation; 3:others | |
default_k | the default number of folds (overridden by command-line parameter kfold/k) | |
data_input | the input dataset (with labels in the last feature for classification case) | |
module_root | the fastexec module this is under (usually use fx_root) | |
learner_fx_name | short name to give it under fastexec | |
kfold_fx_name | the fastexec name of the cross-validator |
void GeneralCrossValidator< TLearner >::Init | ( | int | learner_typeid, | |
int | default_k, | |||
const Dataset * | data_input, | |||
struct datanode * | module_root, | |||
const char * | learner_fx_name, | |||
const char * | kfold_fx_name = "kfold" | |||
) | [inline] |
Uses FastExec to initialize this.
See details about this class for more information.
learner_typeid | type id of the learner; 0:classification 1:regression 2:density estimation; 3:others | |
default_k | the default number of folds (overridden by command-line parameter kfold/k) | |
data_input | the input dataset (with labels in the last feature for classification case) | |
module_root | the fastexec module this is under (usually use fx_root) | |
learner_fx_name | short name to give it under fastexec | |
kfold_fx_name | the fastexec name of the cross-validator |
initialization for general parameters
initialization for type 0: classification ONLY
Definition at line 540 of file crossvalidation.h.
References fx_param_int(), fx_submodule(), and Dataset::n_labels().
Referenced by main().
void GeneralCrossValidator< TLearner >::Run | ( | bool | randomized | ) |
Runs cross-validation.
randomized | whether to use a random permutation of the data, or just to stride it |
void GeneralCrossValidator< TLearner >::Run | ( | bool | randomized | ) | [inline] |
Runs cross-validation.
randomized | whether to use a random permutation of the data, or just to stride it |
for type 0: Classification ONLY
For type 1:regression & 2:density estimation
Definition at line 574 of file crossvalidation.h.
References ArrayList< TElem >::Clear(), GeneralCrossValidator< TLearner >::clsf_n_correct(), GeneralCrossValidator< TLearner >::clsf_n_incorrect(), GeneralCrossValidator< TLearner >::clsf_portion_correct(), fx_copy_module(), fx_format_result(), fx_param_bool(), fx_submodule(), fx_timer_start(), fx_timer_stop(), Dataset::GetLabels(), ArrayList< TElem >::Init(), ArrayList< TElem >::InitCopy(), datanode::key, math::MakeIdentityPermutation(), math::MakeRandomPermutation(), GenVector< T >::MakeSubvector(), Dataset::matrix(), Dataset::n_features(), Dataset::n_labels(), Dataset::n_points(), ArrayList< TElem >::size(), and Dataset::SplitTrainTest().
Referenced by main().