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.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4ea168e6bfad787aeb7b26be5d09ebc8e9bc07e4493637894fe03d680d7376d |
|
MD5 | 32d0002ac0e02fdcc5b7c1d862970bff |
|
BLAKE2b-256 | 0a717212b12c48c67d730ae6251393557407754ad2e68627aba9f0880e989eea |
Hashes for tabular_time_series-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e769eac1133131c9554123c1086e1e3942de82a016b5b16dd6d8790bad4409c6 |
|
MD5 | d7823fe7e651dc281b5f86ec9177fcfd |
|
BLAKE2b-256 | 83098e6174be8a2ba7ffed574a1ee9e795ec65c056a71e1a0e14dccfe76758fd |