PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
strategy_cv.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 STRAT_CVPPC_HPP
21#define STRAT_CVPPC_HPP
22
23#include <iostream>
24#include <functional>
25#include <string>
26#include <vector>
27#include <map>
28#include <algorithm>
29#include <iterator>
30#include <numeric>
31#include <concepts>
32#include <memory>
33#include <utility>
34#include <type_traits>
35
36
37#include "traits_ko.hpp"
38
39
45
46
51template <CV_STRAT cv_strat>
52using CV_STRAT_T = std::integral_constant<CV_STRAT, cv_strat>;
53
54
58using cv_strategy_t = std::vector<std::pair<std::vector<int>,std::vector<int>>>;
62using iter_cv_t = std::pair<std::vector<int>,std::vector<int>>;
66using train_valid_set_t = std::pair<KO_Traits::StoringMatrix,KO_Traits::StoringMatrix>;
67
68
74template<CV_STRAT cv_strat>
76{
77private:
78
82 void train_validation_set_strategy(int min_dim_ts, int max_dim_ts, CV_STRAT_T<CV_STRAT::AUGMENTING_WINDOW>);
83
85 cv_strategy_t m_strategy;
86
92 train_valid_set_t train_validation_set(const KO_Traits::StoringMatrix &data, const iter_cv_t &strat, CV_STRAT_T<CV_STRAT::AUGMENTING_WINDOW>) const;
93
94public:
95
101 cv_strategy(int min_dim_ts, int max_dim_ts) { this->train_validation_set_strategy(min_dim_ts,max_dim_ts);}
102
107 inline cv_strategy_t strategy() const {return m_strategy;}
108
115 void train_validation_set_strategy(int min_dim_ts, int max_dim_ts) { return train_validation_set_strategy(min_dim_ts, max_dim_ts, CV_STRAT_T<cv_strat>{});};
116
123
124};
125
126
127#include "strategy_cv_imp.hpp"
128
129#endif //STRAT_CVPPC_HPP
cv_strategy_t strategy() const
Getter for the splitting training/validation.
Definition strategy_cv.hpp:107
cv_strategy(int min_dim_ts, int max_dim_ts)
Constructor taking minimum and maximum dimension of the training set.
Definition strategy_cv.hpp:101
train_valid_set_t train_validation_set(const KO_Traits::StoringMatrix &data, const iter_cv_t &strat) const
For a fixed given split training/validation according to augmenting window strategy,...
Definition strategy_cv.hpp:122
void train_validation_set_strategy(int min_dim_ts, int max_dim_ts)
Creating the training/validation split. Tag-dispacther.
Definition strategy_cv.hpp:115
std::pair< std::vector< int >, std::vector< int > > iter_cv_t
Definition strategy_cv.hpp:62
std::vector< std::pair< std::vector< int >, std::vector< int > > > cv_strategy_t
Definition strategy_cv.hpp:58
std::pair< KO_Traits::StoringMatrix, KO_Traits::StoringMatrix > train_valid_set_t
Definition strategy_cv.hpp:66
std::integral_constant< CV_STRAT, cv_strat > CV_STRAT_T
Definition strategy_cv.hpp:52
Definition of methods for creating training/validation splitting and recovering corresponding trainin...
Eigen::MatrixXd StoringMatrix
Matrix data structure.
Definition traits_ko.hpp:49
Contains customized types and enumerator for customized template parameters, exploited in the algorit...