OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
time_series_dataset.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// T I M E S E R I E S D A T A S E T C L A S S H E A D E R
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
9#pragma once
10
11#include "tabular_dataset.h"
12
13namespace opennn
14{
15
18{
19
20public:
21
26 TimeSeriesDataset(const Index = 0,
27 const Shape& = {},
28 const Shape& = {});
29
36 TimeSeriesDataset(const filesystem::path&,
37 const string&,
38 bool = true,
39 bool = false,
41
43 void fill_gaps();
44
46 Index get_past_time_steps() const;
48 Index get_future_time_steps() const;
52 bool get_multi_target() const;
53
55 Tensor3 get_data(const string& sample_role, const string& feature_role) const;
56
58 void set_past_time_steps(const Index);
60 void set_future_time_steps(const Index);
62 void set_time_variable_index(const Index);
64 void set_multi_target(const bool);
65
67 MatrixR calculate_autocorrelations(const Index = 10) const;
69 Tensor3 calculate_cross_correlations(const Index = 10) const;
72
73 void to_JSON(JsonWriter&) const override;
74 void from_JSON(const JsonDocument&) override;
75
77 void read_csv();
78
83
85 void fill_inputs(const vector<Index>&,
86 const vector<Index>&,
87 float*,
88 bool is_training,
89 bool parallelize = true,
90 int contiguous = -1) const override;
91
93 void fill_targets(const vector<Index>&,
94 const vector<Index>&,
95 float*,
96 bool is_training,
97 bool parallelize = true,
98 int contiguous = -1) const override;
99
101 void resize_input_shape(Index) override;
102
103private:
104
105 Index past_time_steps = 2;
106
107 Index future_time_steps = 1;
108
109 bool multi_target = false;
110
111 Index time_variable_index = 0;
112};
113
114}
115
116// OpenNN: Open Neural Networks Library.
117// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
118// Licensed under the GNU Lesser General Public License v2.1 or later.
Codification
Text encoding of the source data file.
Definition dataset.h:66
@ UTF8
Definition dataset.h:66
Definition json.h:72
Definition json.h:85
TabularDataset(const Index=0, const Shape &={0}, const Shape &={0})
Creates a tabular dataset with the given sample count and input/target shapes.
TimeSeriesDataset(const filesystem::path &, const string &, bool=true, bool=false, const Codification &=Codification::UTF8)
Creates a time series dataset by reading the given file with the given separator.
void set_future_time_steps(const Index)
Sets the number of future time steps used as prediction horizon.
void fill_inputs(const vector< Index > &, const vector< Index > &, float *, bool is_training, bool parallelize=true, int contiguous=-1) const override
Copies the past-window input features of the selected samples into the destination buffer.
void impute_missing_values_interpolate() override
Interpolates missing values along the time axis.
Index get_time_variable_index() const
Returns the index of the variable acting as the time axis.
TimeSeriesDataset(const Index=0, const Shape &={}, const Shape &={})
Creates a time series dataset with the given sample count and input/target shapes.
void set_multi_target(const bool)
Sets whether the dataset is configured for multi-target forecasting.
void to_JSON(JsonWriter &) const override
Writes dataset state to a JSON writer.
void from_JSON(const JsonDocument &) override
Loads dataset state from a JSON document.
void set_past_time_steps(const Index)
Sets the number of past time steps used as input context.
Index get_future_time_steps() const
Returns the number of future time steps used as prediction horizon.
void set_time_variable_index(const Index)
Sets the index of the variable acting as the time axis.
void impute_missing_values_unuse() override
Marks samples around missing values as unused (time-series aware).
void fill_gaps()
Fills missing rows between time stamps so the series has a uniform cadence.
void fill_targets(const vector< Index > &, const vector< Index > &, float *, bool is_training, bool parallelize=true, int contiguous=-1) const override
Copies the future-window target features of the selected samples into the destination buffer.
bool get_multi_target() const
Returns whether the dataset is configured for multi-target forecasting.
Tensor3 calculate_cross_correlations_spearman(const Index=10) const
Returns the Spearman cross-correlations between variables up to the given lag.
MatrixR calculate_autocorrelations(const Index=10) const
Returns the autocorrelation matrix up to the given maximum lag.
void resize_input_shape(Index) override
Resizes the input shape, accounting for the configured past/future windows.
Index get_past_time_steps() const
Returns the number of past time steps used as input context.
Tensor3 get_data(const string &sample_role, const string &feature_role) const
Returns the windowed 3D tensor for the given sample and feature roles.
void read_csv()
Reads the configured CSV file into the time series dataset.
Tensor3 calculate_cross_correlations(const Index=10) const
Returns the Pearson cross-correlations between variables up to the given lag.
Definition adaptive_moment_estimation.h:14
Tensor< float, 3, Layout|AlignedMax > Tensor3
Definition pch.h:190
Matrix< float, Dynamic, Dynamic, Layout > MatrixR
Definition pch.h:177
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42