PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
CV_k< cv_strat, err_eval, k_imp, valid_err_ret > Class Template Reference

Template class for performing cross-validation on the number of retained PPCs: derived-from-CV_base thorugh CRTP ('CV_k' its template D parameter). More...

#include <CV_k.hpp>

Inheritance diagram for CV_k< cv_strat, err_eval, k_imp, valid_err_ret >:
CV_base< CV_k< cv_strat, err_eval, k_imp, valid_err_ret >, cv_strat, err_eval, k_imp, valid_err_ret >

Public Member Functions

template<typename STOR_OBJ, typename STRATEGY>
 CV_k (STOR_OBJ &&Data, STRATEGY &&strategy, const std::vector< int > &params, double toll, double alpha, const pred_func_t< K_IMP::YES > &pred_f, int number_threads)
 Constructor for derived class: constructs firstly CV_base<CV_k,...>
 
int param_best () const
 Getter for the best number of retained PPCs.
 
std::vector< double > valid_errors () const
 Getter for validation errors.
 
double best_valid_error () const
 Getter for the best validation error.
 
double error_single_cv_iter (const int &param, const KO_Traits::StoringMatrix &training_set, const KO_Traits::StoringMatrix &validation_set) const
 Error for a single cross-validation iteration (parameter given), with fixed training and validation sets.
 
double error_single_param (const int &param, const cv_strategy_t &strat, const std::size_t &number_cv_iter) const
 Validation error for a given parameter, as the mean of the errors on the various validation sets.
 
void best_param_search ()
 Selecting the best number of retained PPCs, modifying it into the class.
 
- Public Member Functions inherited from CV_base< CV_k< cv_strat, err_eval, k_imp, valid_err_ret >, cv_strat, err_eval, k_imp, valid_err_ret >
double err_valid_set_eval (const KO_Traits::StoringVector &pred, const KO_Traits::StoringVector &valid, int number_threads) const
 Evaluation of the loss between prediction on validation set and validation set: estimate of L2 norm loss. Tag-dispacther.
 
 CV_base (STOR_OBJ &&Data, STRATEGY &&strategy, int number_threads)
 Constructor for the class.
 
KO_Traits::StoringMatrix Data () const
 Getter for the data matrix.
 
cv_strategy< cv_strat > strategy () const
 Getter for the training/validation set splitting.
 
int number_threads () const
 Getter for the number of threads for OMP.
 

Detailed Description

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
class CV_k< cv_strat, err_eval, k_imp, valid_err_ret >

Template class for performing cross-validation on the number of retained PPCs: derived-from-CV_base thorugh CRTP ('CV_k' its template D parameter).

Template Parameters
cv_stratstrategy for splitting training/validation sets
err_evalhow to evaluate the loss between prediction on validation set and validation set
k_impif k is imposed or has to be found through explanatory power criterion (necessary k_imp=K_IMP::YES since k is imposed at each cv iteration)
valid_err_retif validation error are stored

Derived class. Polymorphism is known at compile time thanks to Curiously Recursive Template Pattern (CRTP)

Constructor & Destructor Documentation

◆ CV_k()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
template<typename STOR_OBJ, typename STRATEGY>
CV_k< cv_strat, err_eval, k_imp, valid_err_ret >::CV_k ( STOR_OBJ && Data,
STRATEGY && strategy,
const std::vector< int > & params,
double toll,
double alpha,
const pred_func_t< K_IMP::YES > & pred_f,
int number_threads )
inline

Constructor for derived class: constructs firstly CV_base<CV_k,...>

Parameters
Datafts data matrix
strategysplitting training/validation strategy
paramsinput space for number of retained PPCs
tolltolerance between consecutive validation errors for looking for element with bigger value in the input space
alpharegularization parameter
pred_ffunction to make validation set prediction (overloading with k imposed)
number_threadsnumber of threads for OMP

Universal constructor: move semantic used to optimazing handling big size objects

Member Function Documentation

◆ best_valid_error()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
double CV_k< cv_strat, err_eval, k_imp, valid_err_ret >::best_valid_error ( ) const
inline

Getter for the best validation error.

Returns
the private m_best_valid_error

◆ error_single_cv_iter()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
double CV_k< cv_strat, err_eval, k_imp, valid_err_ret >::error_single_cv_iter ( const int & param,
const KO_Traits::StoringMatrix & training_set,
const KO_Traits::StoringMatrix & validation_set ) const
inline

Error for a single cross-validation iteration (parameter given), with fixed training and validation sets.

Parameters
paramparameter that is being evaluated through cross-validation
training_settraining set
validation_setvalidation set
Returns
the error, according to 'err_eval' class template parameter, between prediction on validation set and validation set

◆ error_single_param()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
double CV_k< cv_strat, err_eval, k_imp, valid_err_ret >::error_single_param ( const int & param,
const cv_strategy_t & strat,
const std::size_t & number_cv_iter ) const
inline

Validation error for a given parameter, as the mean of the errors on the various validation sets.

Parameters
paramelement of the input space for number of retained PPCs
stratstrategy for splitting training and validation set
number_cv_itertotal number of different splits
Returns
the average of the errors between prediction on validation set and validation set, for each split
Note
eventual usage of 'pragma' directive for OMP

◆ param_best()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
int CV_k< cv_strat, err_eval, k_imp, valid_err_ret >::param_best ( ) const
inline

Getter for the best number of retained PPCs.

Returns
the private m_param_best

◆ valid_errors()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
std::vector< double > CV_k< cv_strat, err_eval, k_imp, valid_err_ret >::valid_errors ( ) const
inline

Getter for validation errors.

Returns
the private m_valid_errors

The documentation for this class was generated from the following file: