Bayesian Neural Fields for Spatiotemporal Prediction
This is not an officially supported Google product.
Spatially referenced time series (i.e., spatiotemporal) datasets are ubiquitous in scientific, engineering, and business-intelligence applications. This repository contains an implementation of the Bayesian Neural Field (BayesNF) a novel spatiotemporal modeling method that integrates hierarchical probabilistic modeling for accurate uncertainty estimation with deep neural networks for high-capacity function approximation.
Bayesian Neural Fields infer joint probability distributions over field values at arbitrary points in time and space, which makes the model suitable for many data-analysis tasks including spatial interpolation, temporal forecasting, and variography. Posterior inference is conducted using variationally learned surrogates trained via mini-batch stochastic gradient descent for handling large-scale data.
Installation
bayesnf can be installed from the Python Package Index
(PyPI) using:
python -m pip install bayesnf
The typical install time is 1 minute. This software is tested on Python 3.11
with a standard Debian GNU/Linux setup. The large-scale experiments in
scripts/ were run using TPU v3-8 accelerators.
To run BayesNF locally on medium to large-scale data, a GPU is
required at minimum.
Documentation and Tutorials
Please visit https://google.github.io/bayesnf
Quick start
# Load a dataframe with "long" format spatiotemporal data.
df_train = pd.read_csv('chickenpox.5.train.csv',
index_col=0, parse_dates=['datetime'])
# Build a BayesianNeuralFieldEstimator
model = BayesianNeuralFieldMAP(
width=256,
depth=2,
freq='W',
seasonality_periods=['M', 'Y'],
num_seasonal_harmonics=[2, 10],
feature_cols=['datetime', 'latitude', 'longitude'],
target_col='chickenpox',
observation_model='NORMAL',
timetype='index',
standardize=['latitude', 'longitude'],
interactions=[(0, 1), (0, 2), (1, 2)])
# Fit the model.
model = model.fit(
df_train,
seed=jax.random.PRNGKey(0),
ensemble_size=ensemble_size,
num_epochs=num_epochs)
# Make predictions of means and quantiles on test data.
df_test = pd.read_csv('chickenpox.5.test.csv',
index_col=0, parse_dates=['datetime'])
yhat, yhat_quantiles = model.predict(df_test, quantiles=(0.025, 0.5, 0.975))
Metadata
Release files for bayesnf 0.1.3
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 |
|---|---|---|---|---|
| bayesnf-0.1.3.tar.gz | 23.6 kB | Without provenance | Details for bayesnf-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bayesnf-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for bayesnf-0.1.3-py3-none-any.whl |
Total release size: 48.8 kB
Release files / bayesnf-0.1.3.tar.gz
| Download URL | bayesnf-0.1.3.tar.gz |
|---|---|
| Size | 23.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d771885c3d9b716e8d9166bca9d016f962a763b0a5b1323ea1c594d76f0ae51f
|
|
BLAKE2b-256 checksum How to use checksums |
491c5a5eee557682937d0af345844a74f8a552e894808524b82e9e478941bf09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Release files / bayesnf-0.1.3-py3-none-any.whl
| Download URL | bayesnf-0.1.3-py3-none-any.whl |
|---|---|
| Size | 25.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
619f30058f3d76a9d1baeb67e613fc165c700d402172ab573888a417dc233320
|
|
BLAKE2b-256 checksum How to use checksums |
69f6093c2686e59a10ce323f5dc87359d83dea54c16fcd6742eca351233822cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Security for bayesnf 0.1.3
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.