About PyBSTS
PyBSTS is an adaptation of R's implementation of Steven L. Scott's BSTS library. It has similar interface, but re-written for Python memory model. It is a Cython+Numpy based implementation and thus dependendecies for these packages.
Package Contents
PyBSTS package installs pybsts and causal_impact libraries.
Quick start
- Install the package
pip install pybsts
- Build BSTS model
import pybsts
import numpy as np
y = np.array([1.0, 2.0, 3.0, 4.0, 4.5])
specification = {"ar_order": 1, "local_trend": {"local_level": True},
"sigma_prior": np.std(y, ddof=1), "initial_value": y[0]}
b = pybsts.PyBsts("gaussian", specification, {"ping": 10, "niter":100, "seed": 1, "burn": 10})
b.fit(y, seed=1)
res = b.predict(seed=1)
print(res)
y = np.array([1.0, 2.0, 3.0, 4.0, 4.5])
X = np.array([[1.0, 2.0, 0.0, 0.0, 0.0], [0.0, 0.0, 3.0, 4.0, 0.0]])
specification = {"local_trend": {"static_intercept": True},
"predictors_prior": {"predictors_squared_normalized": np.dot(X, X.T)/X.shape[1]},
"sigma_prior": np.std(y, ddof=1), "initial_value": y[0], "mean_value": np.mean(y),
"predictor_names": ["first", "second"]}
b = pybsts.PyBsts("gaussian", specification,
{"ping": 10, "niter":100, "burn": 10, "forecast_horizon": 2, "seed": 1})
b.fit(X.T, y, seed=1)
res = b.predict(np.array([[1.0, 0.0], [2.0, 0.0]]), [6, 7], seed=1)
print(res)
- Build CausalImpact model
import causal_impact
import numpy as np
y = np.array([1.0, 2.0, 3.0, 4.0, 4.5, 3.5, 2.5, 2.6])
X = np.array([[1.0, 2.0, 0.0, 0.0, 0.0, 3.5, 0.0, 0.0], [0.0, 0.0, 3.0, 4.0, 4.4, 0.0, 2.5, 2.5]])
b = causal_impact.CausalImpact(X, y, range(0, 5), range(6, 8), niter=1000, burn=100, seed=1,
seasons=[{"number_of_seasons": 3, "duration": 1}])
res = b.analyze()
print(res[0], res[1])
print(b.summary())
Current status
Here is a list of implemented models (see BSTS Library Documentation ):
- stationary (non-dynamic) gaussian regression with local.level + seasons
- stationary (non-dynamic) gaussian regression with local.linear.trend + seasons
- stationary (non-dynamic) gaussian regression with semilocal.linear.trend + seasons
- stationary (non-dynamic) gaussian regression with static.intercept + seasons
- any of the above + ar
- any of the above + auto.ar
Metadata
Release files for pybsts 1.0.7
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 | Actions |
|---|---|---|---|---|
| pybsts-1.0.7.tar.gz | 2.1 MB | Without provenance | Details for pybsts-1.0.7.tar.gz |
Release files / pybsts-1.0.7.tar.gz
| Download URL | pybsts-1.0.7.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66d5965a7e153d3f1a1f6b7da3c0fc5112707d69dfed662250fea83c6cb9fda7
|
|
BLAKE2b-256 checksum How to use checksums |
3006cc79b67393ffb356904d3061f7cf2166b3d9bfe33306e43a75eb1281b7d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for pybsts 1.0.7
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.