PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
traits_ko.hpp
Go to the documentation of this file.
1// Copyright (c) 2024 Andrea Enrico Franzoni (andreaenrico.franzoni@gmail.com)
2//
3// This file is part of PPCKO
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of PPCKO and associated documentation files (the PPCKO software), to deal
7// PPCKO without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of PPCKO, and to permit persons to whom PPCKO is
10// furnished to do so, subject to the following conditions:
11//
12// PPCKO IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17// OUT OF OR IN CONNECTION WITH PPCKO OR THE USE OR OTHER DEALINGS IN
18// PPCKO.
19
20#ifndef KO_TRAITS_HPP
21#define KO_TRAITS_HPP
22
23#include <Eigen/Dense>
24#include <tuple>
25#include <vector>
26#include <array>
27#include <variant>
28#include <type_traits>
29#include <cmath>
30#include <string>
31
37
38
39
46{
47public:
48
49 using StoringMatrix = Eigen::MatrixXd;
50
51 using StoringVector = Eigen::VectorXd;
52
53 using StoringArray = Eigen::ArrayXd;
54
55};
56
57
62struct CV_algo
63{
64 static constexpr std::string CV1 = "NoCV";
65 static constexpr std::string CV2 = "CV_alpha";
66 static constexpr std::string CV3 = "CV_k";
67 static constexpr std::string CV4 = "CV";
68};
69
70
76{
79};
80
81
87{
88 NO = 0,
89 YES = 1,
90};
91
92
98{
99 NO_err = 0,
101};
102
103
109{
111};
112
113
119{
120 MSE = 0,
121};
122
123
127using valid_err_cv_1_t = std::vector<double>;
128using valid_err_cv_2_t = std::vector<std::vector<double>>;
129using valid_err_variant = std::variant<valid_err_cv_1_t,valid_err_cv_2_t>;
130
131
135using results_err_t = std::tuple<KO_Traits::StoringVector, double, int, std::vector<double>, std::vector<double>, KO_Traits::StoringMatrix, KO_Traits::StoringMatrix, std::vector<std::array<double,2>>, KO_Traits::StoringArray, valid_err_variant>;
136using results_no_err_t = std::tuple<KO_Traits::StoringVector, double, int, std::vector<double>, std::vector<double>, KO_Traits::StoringMatrix, KO_Traits::StoringMatrix, std::vector<std::array<double,2>>, KO_Traits::StoringArray>;
137
142template <VALID_ERR_RET valid_err_ret>
143using results_t = typename std::conditional<valid_err_ret,results_err_t,results_no_err_t>::type; //if errors are returned: the tuple will have one more element
144
145
146
147#endif /*KO_TRAITS_HPP*/
Contains PPCKO versions implemented.
Definition traits_ko.hpp:63
static constexpr std::string CV1
No cv for parameters.
Definition traits_ko.hpp:64
static constexpr std::string CV4
Cv for both regularization parameter and number of retained PPCs.
Definition traits_ko.hpp:67
static constexpr std::string CV2
Cv for regularization parameter.
Definition traits_ko.hpp:65
static constexpr std::string CV3
Cv for number of retained PPCs.
Definition traits_ko.hpp:66
Contains the customized types for fts, covariances, PPCs, etc...
Definition traits_ko.hpp:46
Eigen::VectorXd StoringVector
Vector data structure.
Definition traits_ko.hpp:51
Eigen::MatrixXd StoringMatrix
Matrix data structure.
Definition traits_ko.hpp:49
Eigen::ArrayXd StoringArray
Array data structure: more efficient for coefficient-wise operations.
Definition traits_ko.hpp:53
VALID_ERR_RET
If validation error has to be stored and returned.
Definition traits_ko.hpp:98
@ YES_err
Validation errors are stored and returned.
Definition traits_ko.hpp:100
@ NO_err
Validation errors are not stored and not returned (memory saving)
Definition traits_ko.hpp:99
typename std::conditional< valid_err_ret, results_err_t, results_no_err_t >::type results_t
Definition traits_ko.hpp:143
CV_STRAT
Strategy for training/validation splitting during cv.
Definition traits_ko.hpp:109
@ AUGMENTING_WINDOW
Fixing an instant: training set are all the instant up to it, validation the next one....
Definition traits_ko.hpp:110
std::vector< double > valid_err_cv_1_t
Definition traits_ko.hpp:127
std::tuple< KO_Traits::StoringVector, double, int, std::vector< double >, std::vector< double >, KO_Traits::StoringMatrix, KO_Traits::StoringMatrix, std::vector< std::array< double, 2 > >, KO_Traits::StoringArray, valid_err_variant > results_err_t
Definition traits_ko.hpp:135
SOLVER
The available solvers for PPCKO algorithm.
Definition traits_ko.hpp:76
@ ex_solver
Inverted square root regularzied covariance and retrieving PPCs from phi.
Definition traits_ko.hpp:77
@ gep_solver
Using GEP to avoid to avoid inverted square root.
Definition traits_ko.hpp:78
CV_ERR_EVAL
How to compute validation errors during cv.
Definition traits_ko.hpp:119
@ MSE
Estimate of the L2 norm loss.
Definition traits_ko.hpp:120
K_IMP
If the number of PPCs k is a parameter.
Definition traits_ko.hpp:87
@ NO
k is not passed as parameter, has to be found using cumulative explanatory power
Definition traits_ko.hpp:88
@ YES
k is already known (it will be fixed if doing cv on it)
Definition traits_ko.hpp:89