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 = [0, 1, 2, 3, 4, 5, 6]
>> p, n = 2, 2
>> ts = TimeSeriesGenerator(data, p, n)
>> for X, y in ts:
... print(X.shape, y.shape)
... print(X, y)
[0, 1] [2, 3]
[1, 2] [3, 4]
[2, 3] [4, 5]
[3, 4] [5, 6]
>> p, n, s = 2, 2, 4
>> ts = TimeSeriesGenerator(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)
[0, 1, 2, 3] [4, 5]
[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.21.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47224a7b5ce26f3c1b2d21ec45a4c92fe47c2d744ccd1307e187021f585abe92 |
|
MD5 | cd70d0e60f60cb6bc2ef748a305bab3f |
|
BLAKE2b-256 | 0ab3063516571a9c62aaa173cbc5bccc602be82ff2197e30ab73f637000bb759 |
Hashes for tabular_time_series-0.2.21-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b08f1f6e082e2f71ffa0b9766d99ee3cc89c135428bd98df75744a29643d31 |
|
MD5 | cf9e8137557ac73eaab8136e5c09ee9c |
|
BLAKE2b-256 | 61292c0dceca7c57fa3aa18ef3180a5facfebd86ae6f9f7ed8aa87782163056b |