No project description provided
Project description
Tabular Time Series
Summary
This repo was created as I did not find a function able to transform a time-series (1D) into a tabular format (X, y).
Usage
TimeSeriesGenerator
The docstring is as follows. Given a 1D array data = [0, 1, 2, 3, 4, 5, 6]
, generates X, y
following the parameters p
(autoregressive), s
(seasonal) and n
(lenght of y).
Therefore, it makes it possible to train a neural network (e.g.) that 2 autoregressive entries (e.g. p = 2
) and predicts the next two (n = 2
) using 2 (n = 2
) entries with lag 4 (s = 4
).
>> data = np.array([0, 1, 2, 3, 4, 5, 6])
>> p, n = 2, 2
>> ts = TimeSeries(data, p, n)
>> for X, y in ts:
... print(X.shape, y.shape)
... print(X, y)
(2,) (2,)
[0. 1.] [2 3]
(2,) (2,)
[1. 2.] [3 4]
(2,) (2,)
[2. 3.] [4 5]
(2,) (2,)
[3. 4.] [5 6]
>> p, n, s = 2, 2, 4
>> ts = TimeSeries(data, p, n, s)
>> for X, y in ts:
... diff = np.where(data == y[0])[0].item() - np.where(data == X[0])[0].item()
... print(X.shape, y.shape, diff) == (n + p,) (n,) s
... print(X, y)
(4,) (2,)
[0 1 2 3] [4 5]
(4,) (2,)
[1 2 3 4] [5 6]
get_df
Considering that many times a batch array is needed for training, get_df
can be used to generate a pandas
DataFrame that will contain columns in the format:
y(t - 0)
, ...,y(t - p)
autogressive entriesy(t + 0)
, ...,y(t + n)
predict entriesy(ts{s}_0})
, ...,y(ts{s}_n})
seasonal entries
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tabular-time-series-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5f8293c3d35aabbe8432001d3451a8d1948bcec719a0363c05593da532c1fc7 |
|
MD5 | 1f71b9121cadfbf9ea99e523126c254a |
|
BLAKE2b-256 | 5d77f56752d8e24b6ec83feff5a5adb04a39a1b9200d7d0e289550afade56d3b |
Hashes for tabular_time_series-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de6ee6f4312393f8028c1b2f4b49807cf98d736839676b4475cd2244a105ec98 |
|
MD5 | f9fd9ae0d12abe1b50c23988f04e74af |
|
BLAKE2b-256 | 82a445d2fb3ae84d13e773d2c38b05bc6948a040dad11112d225e6cdf6e48189 |