PPCKO: Principal Predictive Components for Estimating an Autoregressive Operator
 
Loading...
Searching...
No Matches
strategy_cv_imp.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#include "strategy_cv.hpp"
21
22
28
29
36template<CV_STRAT cv_strat>
37void
38cv_strategy<cv_strat>::train_validation_set_strategy(int min_dim_ts, int max_dim_ts, CV_STRAT_T<CV_STRAT::AUGMENTING_WINDOW>)
39{
40 std::size_t min_size_ts = static_cast<std::size_t>(min_dim_ts);
41 std::size_t max_size_ts = static_cast<std::size_t>(max_dim_ts);
42
43 //training set is defined as the instant from the beginning up to a given one
44 //validation set is defined as the next one after the end of training set
45 m_strategy.reserve(max_size_ts - min_size_ts);
46
47 for(std::size_t i = min_size_ts; i < max_size_ts; ++i)
48 {
49 //train set: i: Eigen takes the first i columns starting from 1
50 std::vector<int> train_set;
51 train_set.reserve(1);
52 train_set.emplace_back(i);
53
54 //validation set: i: Eigen takes the i-th column starting from 0
55 std::vector<int> validation_set;
56 validation_set.reserve(1);
57 validation_set.emplace_back(i);
58
59 m_strategy.emplace_back(std::make_pair(train_set,validation_set));
60 }
61}
62
63
64
72template<CV_STRAT cv_strat>
74cv_strategy<cv_strat>::train_validation_set(const KO_Traits::StoringMatrix &data, const iter_cv_t &strat, CV_STRAT_T<CV_STRAT::AUGMENTING_WINDOW>)
75const
76{
77 return std::make_pair( data.leftCols(strat.first.front()), data.col(strat.second.front()) );
78}
Contains the class for creating the split training/validation set.
std::pair< std::vector< int >, std::vector< int > > iter_cv_t
Definition strategy_cv.hpp:62
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
Eigen::MatrixXd StoringMatrix
Matrix data structure.
Definition traits_ko.hpp:49