{"id":14810921,"url":"https://github.com/google/bayesnf","last_synced_at":"2025-09-16T13:30:55.263Z","repository":{"id":220560703,"uuid":"731215022","full_name":"google/bayesnf","owner":"google","description":"Bayesian Neural Field models for prediction in large-scale spatiotemporal datasets","archived":false,"fork":false,"pushed_at":"2024-09-12T19:15:53.000Z","size":14989,"stargazers_count":137,"open_issues_count":11,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-10T17:07:59.325Z","etag":null,"topics":["bayesian-inference","data-science","machine-learning","spatiotemporal-data-analysis","statistics"],"latest_commit_sha":null,"homepage":"https://google.github.io/bayesnf/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-13T15:30:55.000Z","updated_at":"2025-09-08T14:13:03.000Z","dependencies_parsed_at":"2024-05-01T18:07:35.846Z","dependency_job_id":"f12e5010-eeab-4741-9316-672199651f9b","html_url":"https://github.com/google/bayesnf","commit_stats":null,"previous_names":["google/bayesnf"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/google/bayesnf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fbayesnf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fbayesnf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fbayesnf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fbayesnf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/bayesnf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fbayesnf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274609465,"owners_count":25316621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian-inference","data-science","machine-learning","spatiotemporal-data-analysis","statistics"],"created_at":"2024-09-18T07:01:46.855Z","updated_at":"2025-09-16T13:30:55.195Z","avatar_url":"https://github.com/google.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Bayesian Neural Fields for Spatiotemporal Prediction\n\n[![Unittests](https://github.com/google/bayesnf/actions/workflows/pytest_and_autopublish.yml/badge.svg)](https://github.com/google/bayesnf/actions/workflows/pytest_and_autopublish.yml)\n[![PyPI version](https://badge.fury.io/py/bayesnf.svg)](https://badge.fury.io/py/bayesnf)\n\n*This is not an officially supported Google product.*\n\nSpatially referenced time series (i.e., spatiotemporal) datasets are\nubiquitous in scientific, engineering, and business-intelligence\napplications. This repository contains an implementation of the _Bayesian\nNeural Field_ (BayesNF), a spatiotemporal modeling method that\nintegrates hierarchical Bayesian inference for accurate uncertainty\nestimation with deep neural networks for high-capacity function\napproximation.\n\nBayesNF infer joint probability distributions over field values at\narbitrary points in time and space, which makes the model suitable for many\ndata-analysis tasks including spatial interpolation, temporal forecasting,\nand variography. Posterior inference is conducted using variationally\nlearned surrogates trained via mini-batch stochastic gradient descent for\nhandling large-scale data. The system is build on the\n[JAX](https://jax.readthedocs.io/en/latest/) machine learning platform.\n\nThe probabilistic model and inference algorithm are described in the\nfollowing [paper](https://www.nature.com/articles/s41467-024-51477-5):\n\n_Scalable spatiotemporal prediction with Bayesian neural fields_. Feras Saad,\nJacob Burnim, Colin Carroll, Brian Patton, Urs Köster, Rif A. Saurous,\nMatthew Hoffman. Nature Communications **15**, 7942 (2024).\nhttps://doi.org/10.1038/s41467-024-51477-5\n\n\n```bibtex\n@article{\ntitle     = {Scalable Spatiotemporal Prediction with {Bayesian} Neural Fields},\nauthors   = {Saad, Feras and Burnim, Jacob and Carroll, Colin and Patton, Brian and Köster, Urs  and Saurous, Rif A. and Hoffman, Matthew}\njournal   = {Nature Communications},\nvolume    = {15},\nissue     = {7942},\nyear      = {2024},\ndoi       = {10.1038/s41467-024-51477-5},\npublisher = {Springer Nature},\n}\n```\n\n## Installation\n\n`bayesnf` can be installed from the Python Package Index\n([PyPI](https://pypi.org/project/bayesnf/)) using:\n\n```\n$ python -m pip install bayesnf\n```\n\nThe typical install time is 1 minute. This software is tested on Python 3.10\nwith a standard Debian GNU/Linux setup. The large-scale experiments in\n`scripts/` were run using [TPU v3-8 accelerators](https://cloud.google.com/tpu/docs/supported-tpu-configurations#tpu-v3-config).\nTo run BayesNF locally on medium to large-scale data, a GPU is\nrequired at minimum.\n\nInstallation into a virtual environment is highly recommended, using the\nfollowing steps:\n\n```\n$ python -m venv pyenv\n$ source pyenv/bin/activate\n$ python -m pip install -U bayesnf\n```\n\nThe versions of dependencies will depend on the Python version.\nGithub Actions tests the software using Python 3.10.\nIf encountering any version issues, please refer to the following file\nfor the versions of libraries used in the test suite:\n[requirements.Python3.10.14.txt](https://github.com/google/bayesnf/blob/main/requirements.Python3.10.14.txt).\nThese specific versions can be installed into the virtual environment\nusing the following command:\n\n```\n$ python -m pip install -r requirements.Python3.10.14.txt\n```\n\n\n## Documentation and Tutorials\n\nPlease visit \u003chttps://google.github.io/bayesnf\u003e\n\n## Quick start\n\n```python\n\n# Load a dataframe with \"long\" format spatiotemporal data.\ndf_train = pd.read_csv('chickenpox.5.train.csv',\n  index_col=0, parse_dates=['datetime'])\n\n# Build a BayesianNeuralFieldEstimator\nmodel = BayesianNeuralFieldMAP(\n  width=256,\n  depth=2,\n  freq='W',\n  seasonality_periods=['M', 'Y'],\n  num_seasonal_harmonics=[2, 10],\n  feature_cols=['datetime', 'latitude', 'longitude'],\n  target_col='chickenpox',\n  observation_model='NORMAL',\n  timetype='index',\n  standardize=['latitude', 'longitude'],\n  interactions=[(0, 1), (0, 2), (1, 2)])\n\n# Fit the model.\nmodel = model.fit(\n  df_train,\n  seed=jax.random.PRNGKey(0),\n  ensemble_size=ensemble_size,\n  num_epochs=num_epochs)\n\n# Make predictions of means and quantiles on test data.\ndf_test = pd.read_csv('chickenpox.5.test.csv',\n  index_col=0, parse_dates=['datetime'])\n\nyhat, yhat_quantiles = model.predict(df_test, quantiles=(0.025, 0.5, 0.975))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fbayesnf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fbayesnf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fbayesnf/lists"}