https://github.com/timmh/biolith
Bayesian Ecological Modeling in Python
https://github.com/timmh/biolith
bayesian ecology numpyro occupancy-modeling
Last synced: about 1 month ago
JSON representation
Bayesian Ecological Modeling in Python
- Host: GitHub
- URL: https://github.com/timmh/biolith
- Owner: timmh
- License: mit
- Created: 2025-01-29T18:48:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-23T20:39:48.000Z (about 1 month ago)
- Last Synced: 2026-02-24T00:24:35.890Z (about 1 month ago)
- Topics: bayesian, ecology, numpyro, occupancy-modeling
- Language: Jupyter Notebook
- Homepage: https://timm.haucke.xyz/biolith/
- Size: 7.6 MB
- Stars: 29
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
README
#
Biolith: Bayesian Ecological Modeling in Python
[](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
Install Biolith using pip:
```bash
pip install biolith
```
### Accelerator support
For NVIDIA GPU support, check your CUDA version with `nvidia-smi` and install the corresponding JAX variant:
```bash
# CUDA 13.x
pip install biolith[cuda13]
```
For AMD GPUs:
```bash
pip install biolith[rocm]
```
For Google Cloud TPU VMs:
```bash
pip install biolith[tpu]
```
## 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
Make sure to install development dependencies, e.g. using:
```bash
pip install -e ".[dev]"
```
Run `pytest` 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.