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

Base class for computing PPCKO algorithm computations. Polymorphism is known at compile-time (CRTP) More...

#include <PPC_KO.hpp>

Public Member Functions

template<typename STOR_OBJ>
 PPC_KO_base (STOR_OBJ &&X, int number_threads)
 Constructor: centers data, evaluate mean function, sample covariance, sample cross-covariance and its square.
 
std::size_t m () const
 Getter for the number of evaluation of the curve/surface.
 
std::size_t n () const
 Getter for the number of time instants.
 
KO_Traits::StoringMatrix X () const
 Getter for fts data matrix (centered)
 
KO_Traits::StoringArray means () const
 Getter for the mean function.
 
KO_Traits::StoringMatrix Cov () const
 Getter for the covariance operator estimate.
 
double trace_cov () const
 Getter for the covariance operator estimate's trace.
 
KO_Traits::StoringMatrixCovReg ()
 Setter for the regularized sample covariance operator.
 
KO_Traits::StoringMatrix rho () const
 Getter for the autoregressive operator estimate.
 
KO_Traits::StoringMatrix a () const
 Getter for the predictive loadings (PPCs directions)
 
KO_Traits::StoringMatrix b () const
 Getter for the predictive factors factor (PPCs weights)
 
std::vector< double > explanatory_power () const
 Getter for the cumulative explanatory power of the PPCs.
 
double alpha () const
 Getter for the regularization parameter.
 
double & alpha ()
 Setter for the regularization parameter.
 
int k () const
 Getter for the number of retained PPCs.
 
int & k ()
 Setter for the number of retained PPCs.
 
double threshold_ppc () const
 Getter for the requested explanatory power of the retained PPCs.
 
double & threshold_ppc ()
 Setter for the requested explanatory power of the retained PPCs.
 
valid_err_variant ValidErr () const
 Getter for the validation errors.
 
valid_err_variant & ValidErr ()
 Setter for the validation errors.
 
int number_threads () const
 Getter for the number of threads for OMP.
 
std::tuple< int, KO_Traits::StoringVector, KO_Traits::StoringMatrixPPC_retained ()
 Retaining the the PPCs: pairs eigenvalue-eigenvector and their number.
 
void KO_algo ()
 Performing PPCKO algorithm once regularization parameter is selected and k or it is fixed or to be retained through explanatory power. Computes PPCs, direction and weight, their number and their cumulative explanatory power, and the estimate of the autoregressive operator.
 
KO_Traits::StoringArray prediction () const
 Performs one-step ahead prediction of the fts. The mean function is added.
 
std::vector< double > scores () const
 Computes the scores of the PPCs, defined as scalar product between the direction and the fts at the last instant.
 
std::vector< std::array< double, 2 > > sd_scores_dir_wei () const
 Computes the standard deviation of the scores of directions and weights.
 
void solve ()
 Method to solve PPCKO according to which cross-validation is performed, if any.
 

Detailed Description

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
class PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >

Base class for computing PPCKO algorithm computations. Polymorphism is known at compile-time (CRTP)

Template Parameters
Dtype of the derived class (for static polymorphism thorugh CRTP):
  • 'PPC_KO_NoCV': alpha has to be passed as paramter. k can be passed as paramter or selected through explanatory power criterion
solverif algorithm solved inverting the regularized covariance or avoiding it through gep (not possible if retaining the number of PPCs with explanatory power criterion)
k_impif k is imposed or has to be found through explanatory power criterion
valid_err_retif validation error are stored
cv_stratstrategy for splitting training/validation sets
err_evalhow to evaluate the loss between prediction on validation set and validation set

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

Constructor & Destructor Documentation

◆ PPC_KO_base()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
template<typename STOR_OBJ>
PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::PPC_KO_base ( STOR_OBJ && X,
int number_threads )
inline

Constructor: centers data, evaluate mean function, sample covariance, sample cross-covariance and its square.

Parameters
Xfts
number_threadsnumber of threads for OMP

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

Note
eventual usage of 'pragma' directive for OMP

Member Function Documentation

◆ a()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringMatrix PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::a ( ) const
inline

Getter for the predictive loadings (PPCs directions)

Returns
the private m_a

◆ alpha() [1/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
double & PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::alpha ( )
inline

Setter for the regularization parameter.

Returns
the private m_alpha (non-const)

◆ alpha() [2/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
double PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::alpha ( ) const
inline

Getter for the regularization parameter.

Returns
the private m_alpha

◆ b()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringMatrix PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::b ( ) const
inline

Getter for the predictive factors factor (PPCs weights)

Returns
the private m_b

◆ Cov()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringMatrix PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::Cov ( ) const
inline

Getter for the covariance operator estimate.

Returns
the private m_Cov

◆ CovReg()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringMatrix & PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::CovReg ( )
inline

Setter for the regularized sample covariance operator.

Returns
the private m_CovReg (non-const)

◆ explanatory_power()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
std::vector< double > PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::explanatory_power ( ) const
inline

Getter for the cumulative explanatory power of the PPCs.

Returns
the private m_explanatory_power

◆ k() [1/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
int & PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::k ( )
inline

Setter for the number of retained PPCs.

Returns
the private m_k (non-const)

◆ k() [2/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
int PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::k ( ) const
inline

Getter for the number of retained PPCs.

Returns
the private m_k

◆ KO_algo()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
void PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::KO_algo ( )

Performing PPCKO algorithm once regularization parameter is selected and k or it is fixed or to be retained through explanatory power. Computes PPCs, direction and weight, their number and their cumulative explanatory power, and the estimate of the autoregressive operator.

Modifying the private members of the class corresponding to the computed quantities

Modifying the private members of the class corresponding to the computed quantities.

◆ m()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
std::size_t PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::m ( ) const
inline

Getter for the number of evaluation of the curve/surface.

Returns
the private m_m

◆ means()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringArray PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::means ( ) const
inline

Getter for the mean function.

Returns
the private m_means

◆ n()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
std::size_t PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::n ( ) const
inline

Getter for the number of time instants.

Returns
the private m_n

◆ number_threads()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
int PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::number_threads ( ) const
inline

Getter for the number of threads for OMP.

Returns
the private m_number_threads

◆ PPC_retained()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
std::tuple< int, KO_Traits::StoringVector, KO_Traits::StoringMatrix > PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::PPC_retained ( )

Retaining the the PPCs: pairs eigenvalue-eigenvector and their number.

Returns
a tuple containing: the number of retained PPCs, the eigenvalues of phi/of GEP, the eigenvectors of phi/of GEP

The PPCs are computed according to the solver strategy using 'Spectra'. Only the first k pairs eigenvalue/eigenvactor are evaluated, corresponding to the k laregest eigenvalues, if k imposed. If instead (only for 'SOLVER::ex_solver') are computed using the explanatory power criterion, the k pairs eigenvalues-eigenvectors are computed increasing the number of computed ones until the requested explanatory power is reached

◆ prediction()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringArray PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::prediction ( ) const

Performs one-step ahead prediction of the fts. The mean function is added.

Returns
the array of the prediction

◆ rho()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringMatrix PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::rho ( ) const
inline

Getter for the autoregressive operator estimate.

Returns
the private m_rho

◆ scores()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
std::vector< double > PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::scores ( ) const

Computes the scores of the PPCs, defined as scalar product between the direction and the fts at the last instant.

Returns
a vector containing the score of each PPC

◆ sd_scores_dir_wei()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
std::vector< std::array< double, 2 > > PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::sd_scores_dir_wei ( ) const

Computes the standard deviation of the scores of directions and weights.

Returns
a vector (of size equal to the number of PPCs) containing arrays with two elements (standard deviation of direction and weight score of the PPC)
  • Scores of directions are computed as the scalar product of the direction and the fts in the instants between 2 and n.
    • Scores of weights are computed as the scalar product of the weight and the fts in the instants between 1 and n-1

◆ solve()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
void PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::solve ( )
inline

Method to solve PPCKO according to which cross-validation is performed, if any.

Entails downcasting of base class with a static cast of pointer to the derived-known-at-compile-time class, CRTP fashion

◆ threshold_ppc() [1/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
double & PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::threshold_ppc ( )
inline

Setter for the requested explanatory power of the retained PPCs.

Returns
the private m_threshold_ppc (non-const)

◆ threshold_ppc() [2/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
double PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::threshold_ppc ( ) const
inline

Getter for the requested explanatory power of the retained PPCs.

Returns
the private m_threshold_ppc

◆ trace_cov()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
double PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::trace_cov ( ) const
inline

Getter for the covariance operator estimate's trace.

Returns
the private m_trace_cov

◆ ValidErr() [1/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
valid_err_variant & PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::ValidErr ( )
inline

Setter for the validation errors.

Returns
the private m_valid_err (non-const)

◆ ValidErr() [2/2]

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
valid_err_variant PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::ValidErr ( ) const
inline

Getter for the validation errors.

Returns
the private m_valid_err

◆ X()

template<class D, SOLVER solver, K_IMP k_imp, VALID_ERR_RET valid_err_ret, CV_STRAT cv_strat, CV_ERR_EVAL cv_err_eval>
KO_Traits::StoringMatrix PPC_KO_base< D, solver, k_imp, valid_err_ret, cv_strat, cv_err_eval >::X ( ) const
inline

Getter for fts data matrix (centered)

Returns
the private m_X

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