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

Template class for performing cross-validation on the regularization parameter: derived-from-CV_base thorugh CRTP ('CV_alpha' its template D parameter). More...

#include <CV_alpha.hpp>

Inheritance diagram for CV_alpha< cv_strat, err_eval, k_imp, valid_err_ret >:
CV_base< CV_alpha< 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_alpha (STOR_OBJ &&Data, STRATEGY &&strategy, const std::vector< double > &params, int k, const pred_func_t< k_imp > &pred_f, int number_threads)
 Constructor if number of PPCs k is known (k_imp=K_IMP::YES), for derived class: constructs firstly CV_base<CV_alpha,...>
 
template<typename STOR_OBJ, typename STRATEGY>
 CV_alpha (STOR_OBJ &&Data, STRATEGY &&strategy, const std::vector< double > &params, double threshold_ppc, const pred_func_t< k_imp > &pred_f, int number_threads)
 Constructor if number of PPCs k is not known (k_imp=K_IMP::NO), but has to be retained using explanatory power criterion, for derived class: constructs firstly CV_base<CV_alpha,...>
 
double param_best () const
 Getter for the best regularization parameter.
 
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 double &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 double &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 regularization parameter, modifying it into the class.
 
- Public Member Functions inherited from CV_base< CV_alpha< 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_alpha< cv_strat, err_eval, k_imp, valid_err_ret >

Template class for performing cross-validation on the regularization parameter: derived-from-CV_base thorugh CRTP ('CV_alpha' 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
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_alpha() [1/2]

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_alpha< cv_strat, err_eval, k_imp, valid_err_ret >::CV_alpha ( STOR_OBJ && Data,
STRATEGY && strategy,
const std::vector< double > & params,
int k,
const pred_func_t< k_imp > & pred_f,
int number_threads )
inline

Constructor if number of PPCs k is known (k_imp=K_IMP::YES), for derived class: constructs firstly CV_base<CV_alpha,...>

Parameters
Datafts data matrix
strategysplitting training/validation strategy
paramsinput space for regularization parameter
knumber of retained PPCs
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

◆ CV_alpha() [2/2]

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_alpha< cv_strat, err_eval, k_imp, valid_err_ret >::CV_alpha ( STOR_OBJ && Data,
STRATEGY && strategy,
const std::vector< double > & params,
double threshold_ppc,
const pred_func_t< k_imp > & pred_f,
int number_threads )
inline

Constructor if number of PPCs k is not known (k_imp=K_IMP::NO), but has to be retained using explanatory power criterion, for derived class: constructs firstly CV_base<CV_alpha,...>

Parameters
Datafts data matrix
strategysplitting training/validation strategy
paramsinput space for regularization parameter
threshold_ppcrequested explanatory power for PPCs
pred_ffunction to make validation set prediction (overloading with k not imposed)
number_threadsnumber of threads for OMP

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

Member Function Documentation

◆ best_param_search()

template<CV_STRAT cv_strat, CV_ERR_EVAL err_eval, K_IMP k_imp, VALID_ERR_RET valid_err_ret>
void CV_alpha< cv_strat, err_eval, k_imp, valid_err_ret >::best_param_search ( )
inline

Selecting the best regularization parameter, modifying it into the class.

Note
eventual usage of 'pragma' directive for OMP

◆ 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_alpha< 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_alpha< cv_strat, err_eval, k_imp, valid_err_ret >::error_single_cv_iter ( const double & 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_alpha< cv_strat, err_eval, k_imp, valid_err_ret >::error_single_param ( const double & 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 regularization parameter
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>
double CV_alpha< cv_strat, err_eval, k_imp, valid_err_ret >::param_best ( ) const
inline

Getter for the best regularization parameter.

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_alpha< 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: