Time Series Generator
Description
Emulates Teras Tensorflow TimeSeriesGenerator functionality presenting a candidate solution for the direct multi-step outputs limitation in Keras' version.
Instalation
pip install time-series-generator
Usage
import numpy as np
from time_series_generator import TimeseriesGenerator
data = np.array([[i] for i in range(50)])
targets = np.array([[i] for i in range(50)])
data_gen = TimeseriesGenerator(data, targets,
length=10, sampling_rate=2,
batch_size=2)
assert len(data_gen) == 20
batch_0 = data_gen[0]
x, y = batch_0
assert np.array_equal(x,
np.array([[[0], [2], [4], [6], [8]],
[[1], [3], [5], [7], [9]]]))
assert np.array_equal(y,
np.array([[10], [11]]))
Test
Install requirements
Windows:
.\scripts\init-env.ps1
MacOS / Linux
./scripts/init-env.sh
Run test
Run in the terminal at project root folder:
pytest -s
Keras' version limitation
A limitation of the Keras TimeseriesGenerator is that it does not directly support multi-step outputs. Specifically, it will not create the multiple steps that may be required in the target sequence.
Nevertheless, if you prepare your target sequence to have multiple steps, it will honor and use them as the output portion of each sample. This means the onus is on you to prepare the expected output for each time step.
Brownlee, Jason
Candidate Improvement proposed
Addition of the keyworded argument length_output.
# define dataset
series = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
target = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
# define generator
n_input = 2
n_output = 2
generator = TimeseriesGenerator(series, target, length=n_input, length_output=n_output, batch_size=1)
# print each sample
for i in range(len(generator)):
x, y = generator[i]
print('%s => %s' % (x, y))
Output
[[1 2]] => [[3 4]]
[[2 3]] => [[4 5]]
[[3 4]] => [[5 6]]
[[4 5]] => [[6 7]]
[[5 6]] => [[7 8]]
[[6 7]] => [[8 9]]
[[7 8]] => [[9 10]]
References
Metadata
Release files for time-series-generator 0.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| time_series_generator-0.2.8.tar.gz | 8.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| time_series_generator-0.2.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.9 kB
Release files / time_series_generator-0.2.8.tar.gz
| Download URL | time_series_generator-0.2.8.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f01c0e3418963fde34116c06215f87175fe91f51d4b76c8ef4e70dc7ef1b0e2
|
|
BLAKE2b-256 checksum How to use checksums |
3b163b566b254a0716d78dae06211f7fb61d76d466dbcbc13574e592d1a866ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
|
Release files / time_series_generator-0.2.8-py3-none-any.whl
| Download URL | time_series_generator-0.2.8-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70e9d3e024b5b89544e5c6844ebc67aed2f4e95690942796622579356498a7b0
|
|
BLAKE2b-256 checksum How to use checksums |
0798fd2b390a2748808f5a91aebf7c3eff677a00e7ba6ca4b1708115922baa14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
|
Security for time-series-generator 0.2.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.