# <img alt="Biolith logo" src="assets/biolith.svg" style="height: 2em;"> Biolith: <ins>B</ins>ayes<ins>i</ins>an Ec<ins>ol</ins>ogical Modeling <ins>i</ins>n Py<ins>th</ins>on
[](https://github.com/timmh/biolith/actions/workflows/test.yml) [](https://pypi.org/project/biolith/) [](https://doi.org/10.5281/zenodo.15706627)
Biolith is a Python package designed for Bayesian ecological modeling and analysis with a focus on occupancy modeling. It has similar goals to [Unmarked](https://github.com/biodiverse/unmarked) and [spOccupancy](https://github.com/biodiverse/spOccupancy/), but is written in Python and uses [NumPyro](https://num.pyro.ai) and [JAX](https://jax.readthedocs.io) to enable rapid model fitting and iteration.
## Features
- **Hackable**: Models are easy to understand and implement, no likelihood derivations needed.
- **Fast**: Models can be fit on GPUs, which is _fast_.
- **Familiar**: Everything is written in Python, making it easy to integrate into existing pipelines.
## Installation
You can install Biolith using pip:
```bash
pip install biolith
```
## Usage
Here is a simple example using simulated data to get you started:
```python
from biolith.models import occu, simulate
from biolith.utils import fit
# Simulate dataset
data, true_params = simulate()
# Fit model to simulated data
results = fit(occu, **data)
# Compare estimated occupancy probability to the true mean occupancy
print(f"Mean estimated psi: {results.samples['psi'].mean():.2f}")
print(f"Mean true occupancy: {true_params['z'].mean():.2f}")
```
## Real-world Example
To see a real-world example on camera trap data, see [this Jupyter Notebook](./assets/CameraTrapExample.ipynb) from the [EFI Statistical Methods Seminar Series](https://github.com/eco4cast/Statistical-Methods-Seminar-Series/tree/main/beery-haucke_biolith) or [](https://colab.research.google.com/github/timmh/biolith/blob/main/assets/CameraTrapExample.ipynb)
## Documentation
API Documentation and examples are available [here](https://timm.haucke.xyz/biolith/).
## Development
Run `python -m unittest` to run unit tests.
Run `scripts/format.sh` to format the codebase. Execute `scripts/check.sh` to run
isort, docformatter and black in check mode along with pylint and pyright.
To install the pre-commit hook for formatting and code linting, run:
```bash
./scripts/install_precommit.sh
```
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contact
For questions or feedback, please open an issue or email [haucke@mit.edu](mailto:haucke@mit.edu).
## Acknowledgements
This work was supported by the AI and Biodiversity Change (ABC) Global Center, which is funded by the [US National Science Foundation under Award No. 2330423](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2330423&HistoricalAwards=false) and [Natural Sciences and Engineering Research Council of Canada under Award No. 585136](https://www.nserc-crsng.gc.ca/ase-oro/Details-Detailles_eng.asp?id=782440). This work draws on research supported in part by the Social Sciences and Humanities Research Council.
Raw data
{
"_id": null,
"home_page": null,
"name": "biolith",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, occupancy, numpyro, bayesian, ecology",
"author": "Timm Haucke",
"author_email": "haucke@mit.edu",
"download_url": "https://files.pythonhosted.org/packages/ab/75/aece0ac84685b07f813c72e82411879537d15ecbf2d7b373d5ca0a818c80/biolith-0.0.9.tar.gz",
"platform": null,
"description": "# <img alt=\"Biolith logo\" src=\"assets/biolith.svg\" style=\"height: 2em;\"> Biolith: <ins>B</ins>ayes<ins>i</ins>an Ec<ins>ol</ins>ogical Modeling <ins>i</ins>n Py<ins>th</ins>on\n\n[](https://github.com/timmh/biolith/actions/workflows/test.yml) [](https://pypi.org/project/biolith/) [](https://doi.org/10.5281/zenodo.15706627)\n\nBiolith is a Python package designed for Bayesian ecological modeling and analysis with a focus on occupancy modeling. It has similar goals to [Unmarked](https://github.com/biodiverse/unmarked) and [spOccupancy](https://github.com/biodiverse/spOccupancy/), but is written in Python and uses [NumPyro](https://num.pyro.ai) and [JAX](https://jax.readthedocs.io) to enable rapid model fitting and iteration.\n\n## Features\n\n- **Hackable**: Models are easy to understand and implement, no likelihood derivations needed.\n- **Fast**: Models can be fit on GPUs, which is _fast_.\n- **Familiar**: Everything is written in Python, making it easy to integrate into existing pipelines.\n\n## Installation\n\nYou can install Biolith using pip:\n\n```bash\npip install biolith\n```\n\n## Usage\n\nHere is a simple example using simulated data to get you started:\n\n```python\nfrom biolith.models import occu, simulate\nfrom biolith.utils import fit\n\n# Simulate dataset\ndata, true_params = simulate()\n\n# Fit model to simulated data\nresults = fit(occu, **data)\n\n# Compare estimated occupancy probability to the true mean occupancy\nprint(f\"Mean estimated psi: {results.samples['psi'].mean():.2f}\")\nprint(f\"Mean true occupancy: {true_params['z'].mean():.2f}\")\n```\n\n## Real-world Example\nTo see a real-world example on camera trap data, see [this Jupyter Notebook](./assets/CameraTrapExample.ipynb) from the [EFI Statistical Methods Seminar Series](https://github.com/eco4cast/Statistical-Methods-Seminar-Series/tree/main/beery-haucke_biolith) or [](https://colab.research.google.com/github/timmh/biolith/blob/main/assets/CameraTrapExample.ipynb)\n\n## Documentation\nAPI Documentation and examples are available [here](https://timm.haucke.xyz/biolith/).\n\n## Development\n\nRun `python -m unittest` to run unit tests.\n\nRun `scripts/format.sh` to format the codebase. Execute `scripts/check.sh` to run\nisort, docformatter and black in check mode along with pylint and pyright.\n\nTo install the pre-commit hook for formatting and code linting, run:\n\n```bash\n./scripts/install_precommit.sh\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contact\n\nFor questions or feedback, please open an issue or email [haucke@mit.edu](mailto:haucke@mit.edu).\n\n## Acknowledgements\nThis work was supported by the AI and Biodiversity Change (ABC) Global Center, which is funded by the [US National Science Foundation under Award No. 2330423](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2330423&HistoricalAwards=false) and [Natural Sciences and Engineering Research Council of Canada under Award No. 585136](https://www.nserc-crsng.gc.ca/ase-oro/Details-Detailles_eng.asp?id=782440). This work draws on research supported in part by the Social Sciences and Humanities Research Council.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Bayesian Ecological Modeling in Python ",
"version": "0.0.9",
"project_urls": {
"Documentation": "https://timm.haucke.xyz/biolith/",
"Source": "https://github.com/timmh/biolith"
},
"split_keywords": [
"python",
" occupancy",
" numpyro",
" bayesian",
" ecology"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8e00afcc30d6f4e5c06205c744b2764916ec49d7a6822920d3e2ac0072fe1c47",
"md5": "ed576a3ab6b55a7e468e410a2d061e1c",
"sha256": "2e0ad47d62357c8751c55231b86bfc9e935ac69508042a9604d500f306b3d9f3"
},
"downloads": -1,
"filename": "biolith-0.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ed576a3ab6b55a7e468e410a2d061e1c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 46066,
"upload_time": "2025-07-21T05:10:16",
"upload_time_iso_8601": "2025-07-21T05:10:16.721752Z",
"url": "https://files.pythonhosted.org/packages/8e/00/afcc30d6f4e5c06205c744b2764916ec49d7a6822920d3e2ac0072fe1c47/biolith-0.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ab75aece0ac84685b07f813c72e82411879537d15ecbf2d7b373d5ca0a818c80",
"md5": "5cdd68da0f41fe6b76b45fa9b8db6343",
"sha256": "985d3e1dccd671d4d62877076d078915356d9358144845a2f8d43570e7ff80bd"
},
"downloads": -1,
"filename": "biolith-0.0.9.tar.gz",
"has_sig": false,
"md5_digest": "5cdd68da0f41fe6b76b45fa9b8db6343",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 29664,
"upload_time": "2025-07-21T05:10:18",
"upload_time_iso_8601": "2025-07-21T05:10:18.279184Z",
"url": "https://files.pythonhosted.org/packages/ab/75/aece0ac84685b07f813c72e82411879537d15ecbf2d7b373d5ca0a818c80/biolith-0.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-21 05:10:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "timmh",
"github_project": "biolith",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
"==",
"2.2.4"
]
]
},
{
"name": "pandas",
"specs": [
[
"==",
"2.2.3"
]
]
},
{
"name": "jax",
"specs": [
[
"==",
"0.5.2"
]
]
},
{
"name": "numpyro",
"specs": [
[
"==",
"0.18.0"
]
]
},
{
"name": "funsor",
"specs": [
[
"==",
"0.4.5"
]
]
},
{
"name": "black",
"specs": []
},
{
"name": "isort",
"specs": []
},
{
"name": "docformatter",
"specs": []
},
{
"name": "pylint",
"specs": []
},
{
"name": "pyright",
"specs": []
},
{
"name": "sphinx",
"specs": []
},
{
"name": "sphinx_rtd_theme",
"specs": []
},
{
"name": "myst_parser",
"specs": []
}
],
"lcname": "biolith"
}