Agent-based models of plant–pollinator networks with Bayesian inference (ABC).
Project description
NetBayesABM
Agent-based models of plant–pollinator networks with Bayesian inference (ABC).
NetBayesABM is a Python library for simulating agent-based models (ABMs) of ecological networks, focusing on plant–pollinator interactions. It provides tools to:
- Initialize agents (plants and pollinators) with different spatial configurations.
- Construct and evolve bipartite networks dynamically.
- Define and sample prior distributions (Gamma, Exponential) for interaction parameters.
- Visualize abundances, priors, networks, and degree distributions.
- Evaluate simulated networks against empirical data using multiple metrics.
🚀 Installation
Once published on PyPI, you can install with:
pip install NetBayesABM
For development (local clone):
git clone https://github.com/galeanojav/NetBayesABM.git
cd NetBayesABM
pip install -e .
📖 Quick Example
import numpy as np
import pandas as pd
from netbayesabm.classes import Environment_plant, Environment_pol
from netbayesabm.modelling import initial_network, update_totalinks, remove_zero
from netbayesabm.visualization import plot_agents, plot_priors
# --- Define plant environment (random positions) ---
df_plants = pd.DataFrame({
"Plant_id": [1, 2, 3],
"Plant_sp": ["rose", "daisy", "sunflower"],
"X": [0, 0, 0],
"Y": [0, 0, 0],
"Plant_sp_complete": ["Rosa sp.", "Bellis perennis", "Helianthus annuus"]
})
envp = Environment_plant(df_plants, random_position=True, xmin=0, xmax=10, ymin=0, ymax=10)
# --- Define pollinators ---
df_pols = pd.DataFrame({
"Pol_id": [1, 2],
"Specie": ["bee", "butterfly"],
"x": [2.0, 8.0],
"y": [3.0, 7.0],
"Radius": [3.0, 3.0]
})
envpol = Environment_pol(df_pols)
# --- Build bipartite network ---
B = initial_network(df_pols['Pol_id'].tolist(), df_plants['Plant_id'].tolist())
# --- Run short simulation ---
update_totalinks(50, envpol, envp, B, xmin=0, xmax=10, ymin=0, ymax=10)
remove_zero(B)
# --- Priors ---
prior_specialist = pd.Series(np.random.gamma(2, 2, size=1000))
prior_generalist = pd.Series(np.random.gamma(2, 2, size=1000))
plot_priors(prior_specialist, prior_generalist, "example_priors")
📁 Example
A complete analysis notebook is available in:
It includes:
- Data loading and filtering
- Network construction
- All main metrics (degree, strength, clustering, betweenness)
- Fitted models and visualizations
The example uses data (CSV files in examples/Data/).
📊 Features
- Agent and environment classes (Environment_plant, Environment_pol).
- Network initialization and evolution functions.
- Visualization utilities for abundances, priors, and degree distributions.
- Evaluation metrics (Hellinger, Jensen–Shannon, KL, Wasserstein, etc.).
- Example notebooks for a quick start.
👩💻 Authors
- Javier Galeano — [javier.galeano@upm.es]
- Blanca Arroyo-Correa — [blanca.arroyo@ebd.csic.es]
- Mario Castro — [marioc@iit.comillas.edu]
📜 License
This project is licensed under the MIT License — see the LICENSE file for details.
🔗 Links • Source code on GitHub [https://github.com/galeanojav/NetBayesABM]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netbayesabm-0.1.2.tar.gz.
File metadata
- Download URL: netbayesabm-0.1.2.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81a2f99ca8f4bd09ea6c477c289bb69dc670443a3307c9bb763b504c537c68e4
|
|
| MD5 |
e96f6ad20c3b690064ba8971c303e07e
|
|
| BLAKE2b-256 |
8eb4b6438331567468a064ea2f2ee79a055b1219bc24b97f877c62256604b176
|
File details
Details for the file netbayesabm-0.1.2-py3-none-any.whl.
File metadata
- Download URL: netbayesabm-0.1.2-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9bda7a597f6db27e8b01207941e0d1b7687c286aa0b31ff7286a6fb13a3364d
|
|
| MD5 |
d0f421c16090235e17f1363f9d9d2663
|
|
| BLAKE2b-256 |
9f5c47836635112575b6206596774f9a1a0be6a869e7f2f1c396dcaebf13acd5
|