tsbootstrap 0.1.4__tar.gz โ 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tsbootstrap-0.2.0/PKG-INFO +396 -0
- tsbootstrap-0.2.0/README.md +289 -0
- tsbootstrap-0.2.0/pyproject.toml +358 -0
- tsbootstrap-0.2.0/src/tsbootstrap/__init__.py +99 -0
- tsbootstrap-0.2.0/src/tsbootstrap/adapters/__init__.py +37 -0
- tsbootstrap-0.2.0/src/tsbootstrap/adapters/estimators.py +358 -0
- tsbootstrap-0.2.0/src/tsbootstrap/api.py +305 -0
- tsbootstrap-0.2.0/src/tsbootstrap/block/__init__.py +8 -0
- tsbootstrap-0.2.0/src/tsbootstrap/block/indices.py +101 -0
- tsbootstrap-0.2.0/src/tsbootstrap/block/pwsd.py +138 -0
- tsbootstrap-0.2.0/src/tsbootstrap/block/stationary.py +49 -0
- tsbootstrap-0.2.0/src/tsbootstrap/block/tapered.py +67 -0
- tsbootstrap-0.2.0/src/tsbootstrap/diagnostics.py +110 -0
- tsbootstrap-0.2.0/src/tsbootstrap/dispatch.py +128 -0
- tsbootstrap-0.2.0/src/tsbootstrap/engines/__init__.py +1 -0
- tsbootstrap-0.2.0/src/tsbootstrap/engines/arma_scipy.py +120 -0
- tsbootstrap-0.2.0/src/tsbootstrap/engines/var.py +140 -0
- tsbootstrap-0.2.0/src/tsbootstrap/errors.py +177 -0
- tsbootstrap-0.2.0/src/tsbootstrap/metadata.py +145 -0
- tsbootstrap-0.2.0/src/tsbootstrap/methods.py +235 -0
- tsbootstrap-0.2.0/src/tsbootstrap/model/__init__.py +9 -0
- tsbootstrap-0.2.0/src/tsbootstrap/model/arima.py +134 -0
- tsbootstrap-0.2.0/src/tsbootstrap/model/fit.py +190 -0
- tsbootstrap-0.2.0/src/tsbootstrap/model/recursive.py +354 -0
- tsbootstrap-0.2.0/src/tsbootstrap/model/stability.py +94 -0
- tsbootstrap-0.2.0/src/tsbootstrap/py.typed +2 -0
- tsbootstrap-0.2.0/src/tsbootstrap/results.py +175 -0
- tsbootstrap-0.2.0/src/tsbootstrap/rng.py +181 -0
- tsbootstrap-0.2.0/src/tsbootstrap/uq/__init__.py +36 -0
- tsbootstrap-0.2.0/src/tsbootstrap/uq/adaptive.py +102 -0
- tsbootstrap-0.2.0/src/tsbootstrap/uq/calibration.py +105 -0
- tsbootstrap-0.2.0/src/tsbootstrap/uq/conformal.py +402 -0
- tsbootstrap-0.2.0/src/tsbootstrap/uq/forecast.py +65 -0
- tsbootstrap-0.2.0/src/tsbootstrap/validation.py +143 -0
- tsbootstrap-0.2.0/src/tsbootstrap.egg-info/PKG-INFO +396 -0
- tsbootstrap-0.2.0/src/tsbootstrap.egg-info/SOURCES.txt +39 -0
- {tsbootstrap-0.1.4 โ tsbootstrap-0.2.0}/src/tsbootstrap.egg-info/requires.txt +35 -18
- tsbootstrap-0.1.4/PKG-INFO +0 -444
- tsbootstrap-0.1.4/README.md +0 -354
- tsbootstrap-0.1.4/pyproject.toml +0 -232
- tsbootstrap-0.1.4/src/tsbootstrap/__init__.py +0 -70
- tsbootstrap-0.1.4/src/tsbootstrap/base_bootstrap.py +0 -933
- tsbootstrap-0.1.4/src/tsbootstrap/base_bootstrap_configs.py +0 -622
- tsbootstrap-0.1.4/src/tsbootstrap/block_bootstrap.py +0 -1230
- tsbootstrap-0.1.4/src/tsbootstrap/block_bootstrap_configs.py +0 -634
- tsbootstrap-0.1.4/src/tsbootstrap/block_generator.py +0 -528
- tsbootstrap-0.1.4/src/tsbootstrap/block_length_sampler.py +0 -182
- tsbootstrap-0.1.4/src/tsbootstrap/block_resampler.py +0 -618
- tsbootstrap-0.1.4/src/tsbootstrap/bootstrap.py +0 -917
- tsbootstrap-0.1.4/src/tsbootstrap/markov_sampler.py +0 -1073
- tsbootstrap-0.1.4/src/tsbootstrap/py.typed +0 -0
- tsbootstrap-0.1.4/src/tsbootstrap/ranklags.py +0 -272
- tsbootstrap-0.1.4/src/tsbootstrap/registry/__init__.py +0 -13
- tsbootstrap-0.1.4/src/tsbootstrap/registry/_lookup.py +0 -201
- tsbootstrap-0.1.4/src/tsbootstrap/registry/_tags.py +0 -287
- tsbootstrap-0.1.4/src/tsbootstrap/registry/tests/__init__.py +0 -1
- tsbootstrap-0.1.4/src/tsbootstrap/registry/tests/test_tags.py +0 -267
- tsbootstrap-0.1.4/src/tsbootstrap/tests/__init__.py +0 -1
- tsbootstrap-0.1.4/src/tsbootstrap/tests/scenarios/__init__.py +0 -1
- tsbootstrap-0.1.4/src/tsbootstrap/tests/scenarios/scenarios.py +0 -278
- tsbootstrap-0.1.4/src/tsbootstrap/tests/scenarios/scenarios_bootstrap.py +0 -162
- tsbootstrap-0.1.4/src/tsbootstrap/tests/scenarios/scenarios_getter.py +0 -113
- tsbootstrap-0.1.4/src/tsbootstrap/tests/test_all_bootstraps.py +0 -258
- tsbootstrap-0.1.4/src/tsbootstrap/tests/test_all_estimators.py +0 -169
- tsbootstrap-0.1.4/src/tsbootstrap/tests/test_class_register.py +0 -83
- tsbootstrap-0.1.4/src/tsbootstrap/tests/test_switch.py +0 -63
- tsbootstrap-0.1.4/src/tsbootstrap/time_series_model.py +0 -571
- tsbootstrap-0.1.4/src/tsbootstrap/time_series_simulator.py +0 -428
- tsbootstrap-0.1.4/src/tsbootstrap/tsfit.py +0 -1030
- tsbootstrap-0.1.4/src/tsbootstrap/utils/__init__.py +0 -5
- tsbootstrap-0.1.4/src/tsbootstrap/utils/dependencies.py +0 -230
- tsbootstrap-0.1.4/src/tsbootstrap/utils/estimator_checks.py +0 -114
- tsbootstrap-0.1.4/src/tsbootstrap/utils/odds_and_ends.py +0 -342
- tsbootstrap-0.1.4/src/tsbootstrap/utils/types.py +0 -72
- tsbootstrap-0.1.4/src/tsbootstrap/utils/validate.py +0 -751
- tsbootstrap-0.1.4/src/tsbootstrap.egg-info/PKG-INFO +0 -444
- tsbootstrap-0.1.4/src/tsbootstrap.egg-info/SOURCES.txt +0 -57
- tsbootstrap-0.1.4/tests/test_base_bootstrap_configs.py +0 -629
- tsbootstrap-0.1.4/tests/test_block_bootstrap.py +0 -474
- tsbootstrap-0.1.4/tests/test_block_bootstrap_configs.py +0 -484
- tsbootstrap-0.1.4/tests/test_block_generator.py +0 -430
- tsbootstrap-0.1.4/tests/test_block_length_sampler.py +0 -227
- tsbootstrap-0.1.4/tests/test_block_resampler.py +0 -466
- tsbootstrap-0.1.4/tests/test_bootstrap.py +0 -1617
- tsbootstrap-0.1.4/tests/test_markov_sampler.py +0 -1140
- tsbootstrap-0.1.4/tests/test_odds_and_ends.py +0 -52
- tsbootstrap-0.1.4/tests/test_ranklags.py +0 -172
- tsbootstrap-0.1.4/tests/test_time_series_model.py +0 -595
- tsbootstrap-0.1.4/tests/test_time_series_simulator.py +0 -812
- tsbootstrap-0.1.4/tests/test_tsfit.py +0 -696
- tsbootstrap-0.1.4/tests/test_validate.py +0 -678
- {tsbootstrap-0.1.4 โ tsbootstrap-0.2.0}/LICENSE +0 -0
- {tsbootstrap-0.1.4 โ tsbootstrap-0.2.0}/setup.cfg +0 -0
- {tsbootstrap-0.1.4 โ tsbootstrap-0.2.0}/src/tsbootstrap.egg-info/dependency_links.txt +0 -0
- {tsbootstrap-0.1.4 โ tsbootstrap-0.2.0}/src/tsbootstrap.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tsbootstrap
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A Python package to generate bootstrapped time series
|
|
5
|
+
Author-email: Sankalp Gilda <sankalp.gilda@gmail.com>
|
|
6
|
+
Maintainer-email: Sankalp Gilda <sankalp.gilda@gmail.com>, Franz Kiraly <franz.kiraly@sktime.net>, Benedikt Heidrich <benedikt.heidrich@sktime.net>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2023 Sankalp Gilda
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Classifier: Development Status :: 4 - Beta
|
|
30
|
+
Classifier: Intended Audience :: Science/Research
|
|
31
|
+
Classifier: Intended Audience :: Developers
|
|
32
|
+
Classifier: Operating System :: MacOS
|
|
33
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
34
|
+
Classifier: Operating System :: Unix
|
|
35
|
+
Classifier: Programming Language :: Python
|
|
36
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Requires-Python: <3.14,>=3.10
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: numpy
|
|
45
|
+
Requires-Dist: scipy
|
|
46
|
+
Requires-Dist: pydantic
|
|
47
|
+
Requires-Dist: scikit-base
|
|
48
|
+
Requires-Dist: narwhals
|
|
49
|
+
Provides-Extra: models
|
|
50
|
+
Requires-Dist: statsmodels; extra == "models"
|
|
51
|
+
Provides-Extra: uq
|
|
52
|
+
Requires-Dist: scikit-learn; extra == "uq"
|
|
53
|
+
Provides-Extra: accel
|
|
54
|
+
Requires-Dist: numba; extra == "accel"
|
|
55
|
+
Provides-Extra: profile
|
|
56
|
+
Requires-Dist: scalene; extra == "profile"
|
|
57
|
+
Requires-Dist: line_profiler; extra == "profile"
|
|
58
|
+
Requires-Dist: memory_profiler; extra == "profile"
|
|
59
|
+
Requires-Dist: py-spy; extra == "profile"
|
|
60
|
+
Requires-Dist: snakeviz; extra == "profile"
|
|
61
|
+
Provides-Extra: docs
|
|
62
|
+
Requires-Dist: furo; extra == "docs"
|
|
63
|
+
Requires-Dist: jupyter; extra == "docs"
|
|
64
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
65
|
+
Requires-Dist: nbsphinx>=0.8.6; extra == "docs"
|
|
66
|
+
Requires-Dist: numpydoc; extra == "docs"
|
|
67
|
+
Requires-Dist: pydata-sphinx-theme; extra == "docs"
|
|
68
|
+
Requires-Dist: Sphinx!=7.2.0,<8.0.0; extra == "docs"
|
|
69
|
+
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
70
|
+
Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
|
|
71
|
+
Requires-Dist: sphinx-design<0.6.0; extra == "docs"
|
|
72
|
+
Requires-Dist: sphinx-gallery<0.15.0; extra == "docs"
|
|
73
|
+
Requires-Dist: sphinx-issues<4.0.0; extra == "docs"
|
|
74
|
+
Requires-Dist: sphinx-version-warning; extra == "docs"
|
|
75
|
+
Requires-Dist: tabulate>=0.9.0; extra == "docs"
|
|
76
|
+
Provides-Extra: dev
|
|
77
|
+
Requires-Dist: hypothesis[numpy]; extra == "dev"
|
|
78
|
+
Requires-Dist: hypothesis-crosshair; extra == "dev"
|
|
79
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
80
|
+
Requires-Dist: pytest; extra == "dev"
|
|
81
|
+
Requires-Dist: pytest-xdist[psutil]; extra == "dev"
|
|
82
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
83
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
84
|
+
Requires-Dist: sktime; extra == "dev"
|
|
85
|
+
Requires-Dist: polars; extra == "dev"
|
|
86
|
+
Requires-Dist: statsmodels; extra == "dev"
|
|
87
|
+
Requires-Dist: arch; extra == "dev"
|
|
88
|
+
Requires-Dist: pandas; extra == "dev"
|
|
89
|
+
Requires-Dist: scikit-learn; extra == "dev"
|
|
90
|
+
Requires-Dist: numba; extra == "dev"
|
|
91
|
+
Requires-Dist: asv; extra == "dev"
|
|
92
|
+
Requires-Dist: mutmut>=3; extra == "dev"
|
|
93
|
+
Requires-Dist: github-actions; extra == "dev"
|
|
94
|
+
Requires-Dist: importlib-metadata; extra == "dev"
|
|
95
|
+
Requires-Dist: pip-tools; extra == "dev"
|
|
96
|
+
Requires-Dist: mypy; extra == "dev"
|
|
97
|
+
Requires-Dist: pyright; extra == "dev"
|
|
98
|
+
Requires-Dist: ruff; extra == "dev"
|
|
99
|
+
Requires-Dist: autoflake; extra == "dev"
|
|
100
|
+
Requires-Dist: typos; extra == "dev"
|
|
101
|
+
Requires-Dist: tox; extra == "dev"
|
|
102
|
+
Requires-Dist: tox-gh-actions; extra == "dev"
|
|
103
|
+
Requires-Dist: pycobertura; extra == "dev"
|
|
104
|
+
Requires-Dist: tomlkit; extra == "dev"
|
|
105
|
+
Requires-Dist: memory-profiler>=0.60.0; extra == "dev"
|
|
106
|
+
Dynamic: license-file
|
|
107
|
+
|
|
108
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
109
|
+
[](#contributors)
|
|
110
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<div align="center">
|
|
114
|
+
<div style="float: left; margin-right: 20px;">
|
|
115
|
+
<img src="https://github.com/astrogilda/tsbootstrap/blob/main/tsbootstrap_logo.png" width="120" />
|
|
116
|
+
</div>
|
|
117
|
+
<h3>Generate bootstrapped samples from time-series data. The full documentation is available <a href="https://tsbootstrap.readthedocs.io/en/latest/">here</a>.</h3>
|
|
118
|
+
<div style="clear: both;"></div>
|
|
119
|
+
<br>
|
|
120
|
+
<p align="center">
|
|
121
|
+
<img src="https://img.shields.io/badge/Markdown-000000.svg?stylee&logo=Markdown&logoColor=white" alt="Markdown" />
|
|
122
|
+
<img src="https://img.shields.io/badge/Python-3776AB.svg?stylee&logo=Python&logoColor=white" alt="Python" />
|
|
123
|
+
<img src="https://img.shields.io/badge/Pytest-0A9EDC.svg?stylee&logo=Pytest&logoColor=white" alt="pytest" />
|
|
124
|
+
<img src="https://img.shields.io/badge/GitHub%20Actions-2088FF.svg?style&logo=GitHub-Actions&logoColor=white" alt="actions" />
|
|
125
|
+
</p>
|
|
126
|
+
<a href="https://arxiv.org/abs/2404.15227"><img src="https://img.shields.io/static/v1?label=arXiv&message=2404.15227&color=B31B1B&logo=arXiv" alt="preprint">
|
|
127
|
+
</a>
|
|
128
|
+
<a href="https://pypi.org/project/tsbootstrap/">
|
|
129
|
+
<img src="https://img.shields.io/pypi/v/tsbootstrap?color=5D6D7E&logo=pypi" alt="pypi-version" />
|
|
130
|
+
</a>
|
|
131
|
+
<a href="https://pypi.org/project/tsbootstrap/">
|
|
132
|
+
<img src="https://img.shields.io/pypi/pyversions/tsbootstrap?color=5D6D7E&logo=python" alt="pypi-python-version" />
|
|
133
|
+
</a>
|
|
134
|
+
<a href="https://pepy.tech/project/tsbootstrap">
|
|
135
|
+
<img src="https://static.pepy.tech/badge/tsbootstrap" alt="Downloads"/>
|
|
136
|
+
</a>
|
|
137
|
+
<img src="https://img.shields.io/github/license/eli64s/readme-ai?color=5D6D7E" alt="github-license" />
|
|
138
|
+
</a>
|
|
139
|
+
<img src="https://github.com/astrogilda/tsbootstrap/workflows/CI/badge.svg" alt="Build Status"/>
|
|
140
|
+
<a href="https://codecov.io/gh/astrogilda/tsbootstrap"><img src="https://codecov.io/gh/astrogilda/tsbootstrap/branch/main/graph/badge.svg" alt="codecov"/></a>
|
|
141
|
+
<a href="https://doi.org/10.5281/zenodo.8226495"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.8226495.svg" alt="DOI"/></a>
|
|
142
|
+
<a href="https://codeclimate.com/github/astrogilda/tsbootstrap/maintainability"><img src="https://api.codeclimate.com/v1/badges/d80a0615a8c00f31565c/maintainability" alt="Code Quality"/></a>
|
|
143
|
+
<img src="https://img.shields.io/github/last-commit/astrogilda/tsbootstrap" alt="Last Commit"/>
|
|
144
|
+
<img src="https://img.shields.io/github/issues/astrogilda/tsbootstrap" alt="Issues"/>
|
|
145
|
+
<img src="https://img.shields.io/github/issues-pr/astrogilda/tsbootstrap" alt="Pull Requests"/>
|
|
146
|
+
<img src="https://img.shields.io/github/v/tag/astrogilda/tsbootstrap" alt="Tag"/>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
## ๐ Table of Contents
|
|
152
|
+
|
|
153
|
+
1. [๐ Getting Started](#-getting-started)
|
|
154
|
+
2. [๐งฉ Modules](#-modules)
|
|
155
|
+
3. [๐บ Roadmap](#-roadmap)
|
|
156
|
+
4. [๐ค Contributing](#-contributing)
|
|
157
|
+
5. [๐ License](#-license)
|
|
158
|
+
6. [๐ Time Series Bootstrapping Methods intro](#time-series-bootstrapping)
|
|
159
|
+
7. [๐ Contributors](#-contributors)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## ๐ Getting Started
|
|
166
|
+
|
|
167
|
+
### ๐ฎ Using tsbootstrap
|
|
168
|
+
|
|
169
|
+
`tsbootstrap` exposes one typed entry point, `bootstrap`, configured with a method
|
|
170
|
+
specification. The same call works for every method.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
import numpy as np
|
|
174
|
+
from tsbootstrap import bootstrap, MovingBlock
|
|
175
|
+
|
|
176
|
+
x = np.random.default_rng(0).standard_normal(200)
|
|
177
|
+
|
|
178
|
+
result = bootstrap(x, method=MovingBlock(block_length="auto"), n_bootstraps=999, random_state=0)
|
|
179
|
+
|
|
180
|
+
samples = result.values() # (n_bootstraps, n) resampled series
|
|
181
|
+
oob = result.get_oob_mask() # (n_bootstraps, n) out-of-bag mask
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Choose a method spec for the structure you need (block lengths default to the
|
|
185
|
+
automatic Politis-White selection):
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from tsbootstrap import StationaryBlock, ResidualBootstrap, SieveAR, AR, ARIMA, diagnose
|
|
189
|
+
|
|
190
|
+
bootstrap(x, method=StationaryBlock(avg_block_length="auto"))
|
|
191
|
+
|
|
192
|
+
# recursive model-based bootstraps (need the model extra: pip install "tsbootstrap[models]")
|
|
193
|
+
bootstrap(x, method=ResidualBootstrap(model=AR(order=2)))
|
|
194
|
+
bootstrap(x, method=ResidualBootstrap(model=ARIMA(order=(1, 1, 1))))
|
|
195
|
+
bootstrap(x, method=SieveAR())
|
|
196
|
+
|
|
197
|
+
# not sure which fits? ask:
|
|
198
|
+
print(diagnose(x).recommended_methods)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Inputs can be NumPy arrays, lists, or pandas / Polars DataFrames and Series. The
|
|
202
|
+
result is a `BootstrapResult` carrying the samples, provenance metadata, and
|
|
203
|
+
out-of-bag / in-bag primitives. For the sktime ecosystem, the same methods are
|
|
204
|
+
also available as estimator classes (`MovingBlockBootstrap`, `ResidualBootstrap`,
|
|
205
|
+
โฆ) under `tsbootstrap.adapters`.
|
|
206
|
+
|
|
207
|
+
### ๐ฆ Installation
|
|
208
|
+
|
|
209
|
+
Requires Python 3.10 or higher.
|
|
210
|
+
|
|
211
|
+
```sh
|
|
212
|
+
pip install tsbootstrap # core: i.i.d. and block methods
|
|
213
|
+
pip install "tsbootstrap[models]" # adds AR / ARIMA / VAR / sieve (statsmodels)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The model-based methods import statsmodels lazily and raise a clear install hint if
|
|
217
|
+
the `models` extra is missing.
|
|
218
|
+
|
|
219
|
+
## ๐งฉ Modules
|
|
220
|
+
|
|
221
|
+
The package is small and layered around the functional core:
|
|
222
|
+
|
|
223
|
+
| Area | Module(s) | Role |
|
|
224
|
+
| --- | --- | --- |
|
|
225
|
+
| Public API | `api.py`, `methods.py`, `results.py`, `errors.py`, `diagnostics.py` | the `bootstrap()` entry point, typed method specs, structured results, error taxonomy, and `diagnose()` |
|
|
226
|
+
| Infrastructure | `rng.py`, `validation.py`, `dispatch.py`, `metadata.py` | deterministic RNG contract, input coercion (incl. the narwhals DataFrame boundary), spec โ executor dispatch, method metadata |
|
|
227
|
+
| Block methods | `block/` | vectorized index kernels, true Politis-Romano stationary, energy-normalized tapering, PWSD block length, OOB primitives |
|
|
228
|
+
| Model methods | `model/`, `engines/` | model fitting, stability guards, and recursive AR/ARMA/VAR simulation |
|
|
229
|
+
| Ecosystem | `adapters/` | skbase / sktime estimator classes over the functional core |
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
## ๐บ Roadmap
|
|
233
|
+
|
|
234
|
+
This is an abridged version; for the complete and evolving list of plans and improvements, see [Issue #144](https://github.com/astrogilda/tsbootstrap/issues/144).
|
|
235
|
+
|
|
236
|
+
- **Performance and Scaling**: handling large datasets, distributed backend integration (`Dask`, `Spark`, `Ray`), profiling/optimization
|
|
237
|
+
- **Tuning and AutoML**: adaptive block length, adaptive resampling, evaluation based parameter selection
|
|
238
|
+
- **Real-time and Stream Data**: stream bootstraps, data update interface
|
|
239
|
+
- **Stage 2 `sktime` Integration**: evaluation module, datasets, benchmarks, sktime forecasters in bootstraps
|
|
240
|
+
- **API and Capability Extension**: panel/hierarchical data, exogenous data, update/stream, model state management
|
|
241
|
+
- **Scope Extension (TBD)**: time series augmentation, fully probabilistic models
|
|
242
|
+
|
|
243
|
+
## ๐ค Contributing
|
|
244
|
+
|
|
245
|
+
We welcome contributions.
|
|
246
|
+
|
|
247
|
+
See our [good first issues ](https://github.com/astrogilda/tsbootstrap/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
|
|
248
|
+
for getting started.
|
|
249
|
+
|
|
250
|
+
Below is a quick start guide to contributing.
|
|
251
|
+
|
|
252
|
+
### Developer setup
|
|
253
|
+
|
|
254
|
+
1. Fork the tsbootstrap repository
|
|
255
|
+
|
|
256
|
+
2. Clone the fork to local:
|
|
257
|
+
```sh
|
|
258
|
+
git clone https://github.com/astrogilda/tsbootstrap
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
3. In the local repository root, set up a python environment, e.g., `venv` or `conda`.
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
4. Editable install via `pip`, including developer dependencies:
|
|
265
|
+
```
|
|
266
|
+
pip install -e ".[dev]"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
The editable install ensures that changes to the package are reflected in
|
|
270
|
+
your environment.
|
|
271
|
+
|
|
272
|
+
5. Set up git hooks and pre-commit:
|
|
273
|
+
```sh
|
|
274
|
+
# Install pre-commit hooks
|
|
275
|
+
pre-commit install
|
|
276
|
+
|
|
277
|
+
# Configure git to use the project's hooks
|
|
278
|
+
git config core.hooksPath .githooks
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
This ensures that docs requirements stay in sync with `pyproject.toml` and
|
|
282
|
+
other code quality checks run automatically.
|
|
283
|
+
|
|
284
|
+
### Verifying the Installation
|
|
285
|
+
|
|
286
|
+
After installation, you can verify that tsbootstrap has been installed correctly by checking its version or by trying to import it in Python:
|
|
287
|
+
```
|
|
288
|
+
python -c "import tsbootstrap; print(tsbootstrap.__version__)"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
This command should output the version number of tsbootstrap without any errors, indicating that the installation was successful.
|
|
292
|
+
|
|
293
|
+
### Contribution workflow
|
|
294
|
+
|
|
295
|
+
Please follow these steps:
|
|
296
|
+
|
|
297
|
+
3. Create a new branch with a descriptive name (e.g., `new-feature-branch` or `bugfix-issue-123`).
|
|
298
|
+
```sh
|
|
299
|
+
git checkout -b new-feature-branch
|
|
300
|
+
```
|
|
301
|
+
4. Make changes to the project's codebase.
|
|
302
|
+
5. Commit your changes to your local branch with a clear commit message that explains the changes you've made.
|
|
303
|
+
```sh
|
|
304
|
+
git commit -m 'Implemented new feature.'
|
|
305
|
+
```
|
|
306
|
+
6. Push your changes to your forked repository on GitHub using the following command
|
|
307
|
+
```sh
|
|
308
|
+
git push origin new-feature-branch
|
|
309
|
+
```
|
|
310
|
+
7. Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary.
|
|
311
|
+
The project maintainers will review your changes and provide feedback or merge them into the main branch.
|
|
312
|
+
|
|
313
|
+
### ๐งช Running Tests
|
|
314
|
+
|
|
315
|
+
To run all tests, in your developer environment, run:
|
|
316
|
+
|
|
317
|
+
```sh
|
|
318
|
+
pytest tests/
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The sktime adapter classes can be validated with sktime's estimator checks:
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
from sktime.utils import check_estimator
|
|
325
|
+
from tsbootstrap.adapters import MovingBlockBootstrap
|
|
326
|
+
|
|
327
|
+
check_estimator(MovingBlockBootstrap)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Contribution guide
|
|
331
|
+
|
|
332
|
+
For more detailed information on how to contribute, please refer to our [CONTRIBUTING.md](https://github.com/astrogilda/tsbootstrap/blob/main/CONTRIBUTING.md) guide.
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## ๐ License
|
|
336
|
+
|
|
337
|
+
This project is licensed under the `โน๏ธ MIT` License. See the [LICENSE](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository) file for additional info.
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
## ๐ Contributors
|
|
341
|
+
|
|
342
|
+
Thanks goes to these wonderful people:
|
|
343
|
+
|
|
344
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
345
|
+
<!-- prettier-ignore-start -->
|
|
346
|
+
<!-- markdownlint-disable -->
|
|
347
|
+
|
|
348
|
+
<!-- markdownlint-restore -->
|
|
349
|
+
<!-- prettier-ignore-end -->
|
|
350
|
+
|
|
351
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
352
|
+
|
|
353
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
## ๐ Time Series Bootstrapping
|
|
360
|
+
`tsbootstrap` implements bootstrapping methods for time series data. It generates resampled copies of univariate and multivariate series that preserve their chronological order and dependence structure.
|
|
361
|
+
|
|
362
|
+
### Overview
|
|
363
|
+
Traditional bootstrap methods resample observations independently, which breaks the dependence in a time series: each observation usually depends on the ones before it. Time series bootstraps resample while preserving chronological order and correlation, so the resulting uncertainty estimates stay valid under that dependence.
|
|
364
|
+
|
|
365
|
+
### Bootstrapping methodology
|
|
366
|
+
`tsbootstrap` resamples either the observations directly (i.i.d. and block methods) or
|
|
367
|
+
the innovations of a fitted model (residual and sieve methods), respecting the
|
|
368
|
+
chronological order and dependence structure of the data.
|
|
369
|
+
|
|
370
|
+
### Block bootstrap
|
|
371
|
+
Block methods resample blocks of consecutive observations to preserve short-range
|
|
372
|
+
dependence. The block length defaults to the automatic Politis-White (2004) selection.
|
|
373
|
+
|
|
374
|
+
- **Moving block** (`MovingBlock`): overlapping fixed-length blocks (Kunsch 1989).
|
|
375
|
+
- **Circular block** (`CircularBlock`): blocks wrap around the series end (Politis-Romano 1992).
|
|
376
|
+
- **Stationary block** (`StationaryBlock`): geometric block lengths with independent uniform
|
|
377
|
+
restart points (Politis-Romano 1994).
|
|
378
|
+
- **Non-overlapping block** (`NonOverlappingBlock`): disjoint blocks (Carlstein 1986).
|
|
379
|
+
- **Tapered block** (`TaperedBlock(window=...)`): blocks weighted by an energy-normalized
|
|
380
|
+
window (Bartlett, Blackman, Hamming, Hann, or Tukey; Paparoditis-Politis 2001).
|
|
381
|
+
|
|
382
|
+
### Residual bootstrap
|
|
383
|
+
For dependent data with a good model fit, `ResidualBootstrap(model=...)` regenerates the
|
|
384
|
+
series **recursively** from the fitted dynamics and resampled, centered innovations (not
|
|
385
|
+
`fitted + residuals`). Supported models: `AR`, `ARIMA`, and `VAR` (multivariate). A
|
|
386
|
+
non-stationary fit is refused (or skipped, per `stability_policy`) rather than producing
|
|
387
|
+
explosive paths.
|
|
388
|
+
|
|
389
|
+
### Sieve bootstrap
|
|
390
|
+
`SieveAR` selects an autoregressive order on the original series, then runs the AR recursion;
|
|
391
|
+
suited to data with autoregressive structure.
|
|
392
|
+
|
|
393
|
+
### Deferred to a later release
|
|
394
|
+
Markov resampling, the distribution bootstrap, GARCH/volatility models, and
|
|
395
|
+
frequency-domain / seasonal block methods are planned for a future version. The
|
|
396
|
+
statistic-preserving method has been removed.
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
2
|
+
[](#contributors)
|
|
3
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<div align="center">
|
|
7
|
+
<div style="float: left; margin-right: 20px;">
|
|
8
|
+
<img src="https://github.com/astrogilda/tsbootstrap/blob/main/tsbootstrap_logo.png" width="120" />
|
|
9
|
+
</div>
|
|
10
|
+
<h3>Generate bootstrapped samples from time-series data. The full documentation is available <a href="https://tsbootstrap.readthedocs.io/en/latest/">here</a>.</h3>
|
|
11
|
+
<div style="clear: both;"></div>
|
|
12
|
+
<br>
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="https://img.shields.io/badge/Markdown-000000.svg?stylee&logo=Markdown&logoColor=white" alt="Markdown" />
|
|
15
|
+
<img src="https://img.shields.io/badge/Python-3776AB.svg?stylee&logo=Python&logoColor=white" alt="Python" />
|
|
16
|
+
<img src="https://img.shields.io/badge/Pytest-0A9EDC.svg?stylee&logo=Pytest&logoColor=white" alt="pytest" />
|
|
17
|
+
<img src="https://img.shields.io/badge/GitHub%20Actions-2088FF.svg?style&logo=GitHub-Actions&logoColor=white" alt="actions" />
|
|
18
|
+
</p>
|
|
19
|
+
<a href="https://arxiv.org/abs/2404.15227"><img src="https://img.shields.io/static/v1?label=arXiv&message=2404.15227&color=B31B1B&logo=arXiv" alt="preprint">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://pypi.org/project/tsbootstrap/">
|
|
22
|
+
<img src="https://img.shields.io/pypi/v/tsbootstrap?color=5D6D7E&logo=pypi" alt="pypi-version" />
|
|
23
|
+
</a>
|
|
24
|
+
<a href="https://pypi.org/project/tsbootstrap/">
|
|
25
|
+
<img src="https://img.shields.io/pypi/pyversions/tsbootstrap?color=5D6D7E&logo=python" alt="pypi-python-version" />
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://pepy.tech/project/tsbootstrap">
|
|
28
|
+
<img src="https://static.pepy.tech/badge/tsbootstrap" alt="Downloads"/>
|
|
29
|
+
</a>
|
|
30
|
+
<img src="https://img.shields.io/github/license/eli64s/readme-ai?color=5D6D7E" alt="github-license" />
|
|
31
|
+
</a>
|
|
32
|
+
<img src="https://github.com/astrogilda/tsbootstrap/workflows/CI/badge.svg" alt="Build Status"/>
|
|
33
|
+
<a href="https://codecov.io/gh/astrogilda/tsbootstrap"><img src="https://codecov.io/gh/astrogilda/tsbootstrap/branch/main/graph/badge.svg" alt="codecov"/></a>
|
|
34
|
+
<a href="https://doi.org/10.5281/zenodo.8226495"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.8226495.svg" alt="DOI"/></a>
|
|
35
|
+
<a href="https://codeclimate.com/github/astrogilda/tsbootstrap/maintainability"><img src="https://api.codeclimate.com/v1/badges/d80a0615a8c00f31565c/maintainability" alt="Code Quality"/></a>
|
|
36
|
+
<img src="https://img.shields.io/github/last-commit/astrogilda/tsbootstrap" alt="Last Commit"/>
|
|
37
|
+
<img src="https://img.shields.io/github/issues/astrogilda/tsbootstrap" alt="Issues"/>
|
|
38
|
+
<img src="https://img.shields.io/github/issues-pr/astrogilda/tsbootstrap" alt="Pull Requests"/>
|
|
39
|
+
<img src="https://img.shields.io/github/v/tag/astrogilda/tsbootstrap" alt="Tag"/>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## ๐ Table of Contents
|
|
45
|
+
|
|
46
|
+
1. [๐ Getting Started](#-getting-started)
|
|
47
|
+
2. [๐งฉ Modules](#-modules)
|
|
48
|
+
3. [๐บ Roadmap](#-roadmap)
|
|
49
|
+
4. [๐ค Contributing](#-contributing)
|
|
50
|
+
5. [๐ License](#-license)
|
|
51
|
+
6. [๐ Time Series Bootstrapping Methods intro](#time-series-bootstrapping)
|
|
52
|
+
7. [๐ Contributors](#-contributors)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ๐ Getting Started
|
|
59
|
+
|
|
60
|
+
### ๐ฎ Using tsbootstrap
|
|
61
|
+
|
|
62
|
+
`tsbootstrap` exposes one typed entry point, `bootstrap`, configured with a method
|
|
63
|
+
specification. The same call works for every method.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import numpy as np
|
|
67
|
+
from tsbootstrap import bootstrap, MovingBlock
|
|
68
|
+
|
|
69
|
+
x = np.random.default_rng(0).standard_normal(200)
|
|
70
|
+
|
|
71
|
+
result = bootstrap(x, method=MovingBlock(block_length="auto"), n_bootstraps=999, random_state=0)
|
|
72
|
+
|
|
73
|
+
samples = result.values() # (n_bootstraps, n) resampled series
|
|
74
|
+
oob = result.get_oob_mask() # (n_bootstraps, n) out-of-bag mask
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Choose a method spec for the structure you need (block lengths default to the
|
|
78
|
+
automatic Politis-White selection):
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from tsbootstrap import StationaryBlock, ResidualBootstrap, SieveAR, AR, ARIMA, diagnose
|
|
82
|
+
|
|
83
|
+
bootstrap(x, method=StationaryBlock(avg_block_length="auto"))
|
|
84
|
+
|
|
85
|
+
# recursive model-based bootstraps (need the model extra: pip install "tsbootstrap[models]")
|
|
86
|
+
bootstrap(x, method=ResidualBootstrap(model=AR(order=2)))
|
|
87
|
+
bootstrap(x, method=ResidualBootstrap(model=ARIMA(order=(1, 1, 1))))
|
|
88
|
+
bootstrap(x, method=SieveAR())
|
|
89
|
+
|
|
90
|
+
# not sure which fits? ask:
|
|
91
|
+
print(diagnose(x).recommended_methods)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Inputs can be NumPy arrays, lists, or pandas / Polars DataFrames and Series. The
|
|
95
|
+
result is a `BootstrapResult` carrying the samples, provenance metadata, and
|
|
96
|
+
out-of-bag / in-bag primitives. For the sktime ecosystem, the same methods are
|
|
97
|
+
also available as estimator classes (`MovingBlockBootstrap`, `ResidualBootstrap`,
|
|
98
|
+
โฆ) under `tsbootstrap.adapters`.
|
|
99
|
+
|
|
100
|
+
### ๐ฆ Installation
|
|
101
|
+
|
|
102
|
+
Requires Python 3.10 or higher.
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
pip install tsbootstrap # core: i.i.d. and block methods
|
|
106
|
+
pip install "tsbootstrap[models]" # adds AR / ARIMA / VAR / sieve (statsmodels)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The model-based methods import statsmodels lazily and raise a clear install hint if
|
|
110
|
+
the `models` extra is missing.
|
|
111
|
+
|
|
112
|
+
## ๐งฉ Modules
|
|
113
|
+
|
|
114
|
+
The package is small and layered around the functional core:
|
|
115
|
+
|
|
116
|
+
| Area | Module(s) | Role |
|
|
117
|
+
| --- | --- | --- |
|
|
118
|
+
| Public API | `api.py`, `methods.py`, `results.py`, `errors.py`, `diagnostics.py` | the `bootstrap()` entry point, typed method specs, structured results, error taxonomy, and `diagnose()` |
|
|
119
|
+
| Infrastructure | `rng.py`, `validation.py`, `dispatch.py`, `metadata.py` | deterministic RNG contract, input coercion (incl. the narwhals DataFrame boundary), spec โ executor dispatch, method metadata |
|
|
120
|
+
| Block methods | `block/` | vectorized index kernels, true Politis-Romano stationary, energy-normalized tapering, PWSD block length, OOB primitives |
|
|
121
|
+
| Model methods | `model/`, `engines/` | model fitting, stability guards, and recursive AR/ARMA/VAR simulation |
|
|
122
|
+
| Ecosystem | `adapters/` | skbase / sktime estimator classes over the functional core |
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
## ๐บ Roadmap
|
|
126
|
+
|
|
127
|
+
This is an abridged version; for the complete and evolving list of plans and improvements, see [Issue #144](https://github.com/astrogilda/tsbootstrap/issues/144).
|
|
128
|
+
|
|
129
|
+
- **Performance and Scaling**: handling large datasets, distributed backend integration (`Dask`, `Spark`, `Ray`), profiling/optimization
|
|
130
|
+
- **Tuning and AutoML**: adaptive block length, adaptive resampling, evaluation based parameter selection
|
|
131
|
+
- **Real-time and Stream Data**: stream bootstraps, data update interface
|
|
132
|
+
- **Stage 2 `sktime` Integration**: evaluation module, datasets, benchmarks, sktime forecasters in bootstraps
|
|
133
|
+
- **API and Capability Extension**: panel/hierarchical data, exogenous data, update/stream, model state management
|
|
134
|
+
- **Scope Extension (TBD)**: time series augmentation, fully probabilistic models
|
|
135
|
+
|
|
136
|
+
## ๐ค Contributing
|
|
137
|
+
|
|
138
|
+
We welcome contributions.
|
|
139
|
+
|
|
140
|
+
See our [good first issues ](https://github.com/astrogilda/tsbootstrap/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
|
|
141
|
+
for getting started.
|
|
142
|
+
|
|
143
|
+
Below is a quick start guide to contributing.
|
|
144
|
+
|
|
145
|
+
### Developer setup
|
|
146
|
+
|
|
147
|
+
1. Fork the tsbootstrap repository
|
|
148
|
+
|
|
149
|
+
2. Clone the fork to local:
|
|
150
|
+
```sh
|
|
151
|
+
git clone https://github.com/astrogilda/tsbootstrap
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
3. In the local repository root, set up a python environment, e.g., `venv` or `conda`.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
4. Editable install via `pip`, including developer dependencies:
|
|
158
|
+
```
|
|
159
|
+
pip install -e ".[dev]"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The editable install ensures that changes to the package are reflected in
|
|
163
|
+
your environment.
|
|
164
|
+
|
|
165
|
+
5. Set up git hooks and pre-commit:
|
|
166
|
+
```sh
|
|
167
|
+
# Install pre-commit hooks
|
|
168
|
+
pre-commit install
|
|
169
|
+
|
|
170
|
+
# Configure git to use the project's hooks
|
|
171
|
+
git config core.hooksPath .githooks
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This ensures that docs requirements stay in sync with `pyproject.toml` and
|
|
175
|
+
other code quality checks run automatically.
|
|
176
|
+
|
|
177
|
+
### Verifying the Installation
|
|
178
|
+
|
|
179
|
+
After installation, you can verify that tsbootstrap has been installed correctly by checking its version or by trying to import it in Python:
|
|
180
|
+
```
|
|
181
|
+
python -c "import tsbootstrap; print(tsbootstrap.__version__)"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This command should output the version number of tsbootstrap without any errors, indicating that the installation was successful.
|
|
185
|
+
|
|
186
|
+
### Contribution workflow
|
|
187
|
+
|
|
188
|
+
Please follow these steps:
|
|
189
|
+
|
|
190
|
+
3. Create a new branch with a descriptive name (e.g., `new-feature-branch` or `bugfix-issue-123`).
|
|
191
|
+
```sh
|
|
192
|
+
git checkout -b new-feature-branch
|
|
193
|
+
```
|
|
194
|
+
4. Make changes to the project's codebase.
|
|
195
|
+
5. Commit your changes to your local branch with a clear commit message that explains the changes you've made.
|
|
196
|
+
```sh
|
|
197
|
+
git commit -m 'Implemented new feature.'
|
|
198
|
+
```
|
|
199
|
+
6. Push your changes to your forked repository on GitHub using the following command
|
|
200
|
+
```sh
|
|
201
|
+
git push origin new-feature-branch
|
|
202
|
+
```
|
|
203
|
+
7. Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary.
|
|
204
|
+
The project maintainers will review your changes and provide feedback or merge them into the main branch.
|
|
205
|
+
|
|
206
|
+
### ๐งช Running Tests
|
|
207
|
+
|
|
208
|
+
To run all tests, in your developer environment, run:
|
|
209
|
+
|
|
210
|
+
```sh
|
|
211
|
+
pytest tests/
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The sktime adapter classes can be validated with sktime's estimator checks:
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
from sktime.utils import check_estimator
|
|
218
|
+
from tsbootstrap.adapters import MovingBlockBootstrap
|
|
219
|
+
|
|
220
|
+
check_estimator(MovingBlockBootstrap)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Contribution guide
|
|
224
|
+
|
|
225
|
+
For more detailed information on how to contribute, please refer to our [CONTRIBUTING.md](https://github.com/astrogilda/tsbootstrap/blob/main/CONTRIBUTING.md) guide.
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## ๐ License
|
|
229
|
+
|
|
230
|
+
This project is licensed under the `โน๏ธ MIT` License. See the [LICENSE](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository) file for additional info.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
## ๐ Contributors
|
|
234
|
+
|
|
235
|
+
Thanks goes to these wonderful people:
|
|
236
|
+
|
|
237
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
238
|
+
<!-- prettier-ignore-start -->
|
|
239
|
+
<!-- markdownlint-disable -->
|
|
240
|
+
|
|
241
|
+
<!-- markdownlint-restore -->
|
|
242
|
+
<!-- prettier-ignore-end -->
|
|
243
|
+
|
|
244
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
245
|
+
|
|
246
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
## ๐ Time Series Bootstrapping
|
|
253
|
+
`tsbootstrap` implements bootstrapping methods for time series data. It generates resampled copies of univariate and multivariate series that preserve their chronological order and dependence structure.
|
|
254
|
+
|
|
255
|
+
### Overview
|
|
256
|
+
Traditional bootstrap methods resample observations independently, which breaks the dependence in a time series: each observation usually depends on the ones before it. Time series bootstraps resample while preserving chronological order and correlation, so the resulting uncertainty estimates stay valid under that dependence.
|
|
257
|
+
|
|
258
|
+
### Bootstrapping methodology
|
|
259
|
+
`tsbootstrap` resamples either the observations directly (i.i.d. and block methods) or
|
|
260
|
+
the innovations of a fitted model (residual and sieve methods), respecting the
|
|
261
|
+
chronological order and dependence structure of the data.
|
|
262
|
+
|
|
263
|
+
### Block bootstrap
|
|
264
|
+
Block methods resample blocks of consecutive observations to preserve short-range
|
|
265
|
+
dependence. The block length defaults to the automatic Politis-White (2004) selection.
|
|
266
|
+
|
|
267
|
+
- **Moving block** (`MovingBlock`): overlapping fixed-length blocks (Kunsch 1989).
|
|
268
|
+
- **Circular block** (`CircularBlock`): blocks wrap around the series end (Politis-Romano 1992).
|
|
269
|
+
- **Stationary block** (`StationaryBlock`): geometric block lengths with independent uniform
|
|
270
|
+
restart points (Politis-Romano 1994).
|
|
271
|
+
- **Non-overlapping block** (`NonOverlappingBlock`): disjoint blocks (Carlstein 1986).
|
|
272
|
+
- **Tapered block** (`TaperedBlock(window=...)`): blocks weighted by an energy-normalized
|
|
273
|
+
window (Bartlett, Blackman, Hamming, Hann, or Tukey; Paparoditis-Politis 2001).
|
|
274
|
+
|
|
275
|
+
### Residual bootstrap
|
|
276
|
+
For dependent data with a good model fit, `ResidualBootstrap(model=...)` regenerates the
|
|
277
|
+
series **recursively** from the fitted dynamics and resampled, centered innovations (not
|
|
278
|
+
`fitted + residuals`). Supported models: `AR`, `ARIMA`, and `VAR` (multivariate). A
|
|
279
|
+
non-stationary fit is refused (or skipped, per `stability_policy`) rather than producing
|
|
280
|
+
explosive paths.
|
|
281
|
+
|
|
282
|
+
### Sieve bootstrap
|
|
283
|
+
`SieveAR` selects an autoregressive order on the original series, then runs the AR recursion;
|
|
284
|
+
suited to data with autoregressive structure.
|
|
285
|
+
|
|
286
|
+
### Deferred to a later release
|
|
287
|
+
Markov resampling, the distribution bootstrap, GARCH/volatility models, and
|
|
288
|
+
frequency-domain / seasonal block methods are planned for a future version. The
|
|
289
|
+
statistic-preserving method has been removed.
|