{"id":13569523,"url":"https://github.com/bambinos/bambi","last_synced_at":"2025-05-13T22:05:36.702Z","repository":{"id":37559071,"uuid":"58900431","full_name":"bambinos/bambi","owner":"bambinos","description":"BAyesian Model-Building Interface (Bambi) in Python.","archived":false,"fork":false,"pushed_at":"2025-04-16T14:16:16.000Z","size":635679,"stargazers_count":1150,"open_issues_count":93,"forks_count":133,"subscribers_count":28,"default_branch":"main","last_synced_at":"2025-04-29T13:52:59.339Z","etag":null,"topics":["bayesian-inference","bayesian-statistics","python","regression-models","statistical-analysis","statistical-modeling"],"latest_commit_sha":null,"homepage":"https://bambinos.github.io/bambi/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bambinos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://numfocus.org/donate-to-pymc3"]}},"created_at":"2016-05-16T03:21:00.000Z","updated_at":"2025-04-25T09:59:38.000Z","dependencies_parsed_at":"2023-10-20T18:17:02.173Z","dependency_job_id":"35700bd3-9b1e-4f6c-9d27-6627b9fb31f5","html_url":"https://github.com/bambinos/bambi","commit_stats":{"total_commits":671,"total_committers":34,"mean_commits":"19.735294117647058","dds":0.6959761549925485,"last_synced_commit":"6f2f39924b69dfcec1fe3816e0cab4ff316d80a8"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bambinos%2Fbambi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bambinos%2Fbambi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bambinos%2Fbambi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bambinos%2Fbambi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bambinos","download_url":"https://codeload.github.com/bambinos/bambi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036817,"owners_count":22003653,"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","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","bayesian-statistics","python","regression-models","statistical-analysis","statistical-modeling"],"created_at":"2024-08-01T14:00:41.009Z","updated_at":"2025-05-13T22:05:31.673Z","avatar_url":"https://github.com/bambinos.png","language":"Python","funding_links":["https://numfocus.org/donate-to-pymc3"],"categories":["Python","\u003cspan id=\"head76\"\u003e2.5. GLM\u003c/span\u003e","Software","概率统计","其他_机器学习与深度学习","Uncategorized","Machine Learning Frameworks"],"sub_categories":["Venn Diagrams","Uncategorized"],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/bambinos/bambi/main/docs/logos/RGB/Bambi_logo.png\" width=200\u003e\u003c/img\u003e\n\n[![PyPi version](https://badge.fury.io/py/bambi.svg)](https://badge.fury.io/py/bambi)\n[![Build Status](https://github.com/bambinos/bambi/actions/workflows/test.yml/badge.svg)](https://github.com/bambinos/bambi/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/bambinos/bambi/branch/master/graph/badge.svg?token=ZqH0KCLKAE)](https://codecov.io/gh/bambinos/bambi)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\nBAyesian Model-Building Interface in Python\n\n## Overview\n\nBambi is a high-level Bayesian model-building interface written in Python. It's built on top of the [PyMC](https://github.com/pymc-devs/pymc) probabilistic programming framework, and is designed to make it extremely easy to fit mixed-effects models common in social sciences settings using a Bayesian approach.\n\n## Installation\n\nBambi requires a working Python interpreter (3.10+). We recommend installing Python and key numerical libraries using the [Anaconda Distribution](https://www.anaconda.com/products/individual#Downloads), which has one-click installers available on all major platforms.\n\nAssuming a standard Python environment is installed on your machine (including pip), Bambi itself can be installed in one line using pip:\n\n    pip install bambi\n\nAlternatively, if you want the bleeding edge version of the package you can install from GitHub:\n\n    pip install git+https://github.com/bambinos/bambi.git\n\n### Dependencies\n\nBambi requires working versions of ArviZ, formulae, NumPy, pandas and PyMC. Dependencies are listed in `pyproject.toml` and should all be installed by the Bambi installer; no further action should be required.\n\n## Examples\n\nIn the following two examples we assume the following basic setup\n\n```python\nimport arviz as az\nimport bambi as bmb\nimport numpy as np\nimport pandas as pd\n```\n\n### Linear regression\n\nA simple fixed effects model is shown in the example below.\n\n```python\n# Read in a dataset from the package content\ndata = bmb.load_data(\"sleepstudy\")\n\n# See first rows\ndata.head()\n \n# Initialize the fixed effects only model\nmodel = bmb.Model('Reaction ~ Days', data)\n\n# Get model description\nprint(model)\n\n# Fit the model using 1000 on each chain\nresults = model.fit(draws=1000)\n\n# Key summary and diagnostic info on the model parameters\naz.summary(results)\n\n# Use ArviZ to plot the results\naz.plot_trace(results)\n```\n``` \n   Reaction  Days  Subject\n0  249.5600     0      308\n1  258.7047     1      308\n2  250.8006     2      308\n3  321.4398     3      308\n4  356.8519     4      308\n```\n```\n       Formula: Reaction ~ Days\n        Family: gaussian\n          Link: mu = identity\n  Observations: 180\n        Priors:\n    target = mu\n        Common-level effects\n            Intercept ~ Normal(mu: 298.5079, sigma: 261.0092)\n            Days ~ Normal(mu: 0.0, sigma: 48.8915)\n\n        Auxiliary parameters\n            sigma ~ HalfStudentT(nu: 4.0, sigma: 56.1721)\n```\n```\n                   mean     sd   hdi_3%  hdi_97%  mcse_mean  mcse_sd  ess_bulk  ess_tail  r_hat\nIntercept       251.552  6.658  238.513  263.417      0.083    0.059    6491.0    2933.0    1.0\nDays             10.437  1.243    8.179   12.793      0.015    0.011    6674.0    3242.0    1.0\nReaction_sigma   47.949  2.550   43.363   52.704      0.035    0.025    5614.0    2974.0    1.0\n```\n\nFirst, we create and build a Bambi `Model`. Then, the method `model.fit()` tells the sampler to start\nrunning and it returns an `InferenceData` object, which can be passed to several ArviZ functions\nsuch as `az.summary()` to get a summary of the parameters distribution and sample diagnostics or\n`az.plot_trace()` to visualize them.\n\n### Logistic regression\n\nIn this example we will use a simulated dataset created as shown below.\n\n```python\ndata = pd.DataFrame({\n    \"g\": np.random.choice([\"Yes\", \"No\"], size=50),\n    \"x1\": np.random.normal(size=50),\n    \"x2\": np.random.normal(size=50)\n})\n```\n\nHere we just add the `family` argument set to `\"bernoulli\"` to tell Bambi we are modelling a binary\nresponse. By default, it uses a logit link. We can also use some syntax sugar to specify which event\nwe want to model. We just say `g['Yes']` and Bambi will understand we want to model the probability\nof a `\"Yes\"` response. But this notation is not mandatory. If we use `\"g ~ x1 + x2\"`, Bambi will\npick one of the events to model and will inform us which one it picked.\n\n```python\nmodel = bmb.Model(\"g['Yes'] ~ x1 + x2\", data, family=\"bernoulli\")\nfitted = model.fit()\n```\n\nAfter this, we can evaluate the model as before. \n\n### More\n\nFor a more in-depth introduction to Bambi see our [Quickstart](https://github.com/bambinos/bambi#quickstart) and check the notebooks in the [Examples](https://bambinos.github.io/bambi/notebooks/) webpage.\n\n## Documentation\n\nThe Bambi documentation can be found in the [official docs](https://bambinos.github.io/bambi/index.html)\n\n## Citation\n\nIf you use Bambi and want to cite it please use\n\n```bibtex\n@article{Capretto2022,\n title={Bambi: A Simple Interface for Fitting Bayesian Linear Models in Python},\n volume={103},\n url={https://www.jstatsoft.org/index.php/jss/article/view/v103i15},\n doi={10.18637/jss.v103.i15},\n number={15},\n journal={Journal of Statistical Software},\n author={Capretto, Tomás and Piho, Camen and Kumar, Ravin and Westfall, Jacob and Yarkoni, Tal and Martin, Osvaldo A},\n year={2022},\n pages={1–29}\n}\n```\n\n## Contributions\n\nBambi is a community project and welcomes contributions. Additional information can be found in the [Contributing](https://github.com/bambinos/bambi/blob/main/CONTRIBUTING.md) Readme.\n\nFor a list of contributors see the [GitHub contributor](https://github.com/bambinos/bambi/graphs/contributors) page\n\n## Donations\n\nIf you want to support Bambi financially, you can [make a donation](https://numfocus.org/donate-to-pymc) to our sister project PyMC.\n\n## Code of Conduct\n\nBambi wishes to maintain a positive community. Additional details can be found in the [Code of Conduct](https://github.com/bambinos/bambi/blob/main/CODE_OF_CONDUCT.md)\n\n## License\n\n[MIT License](https://github.com/bambinos/bambi/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbambinos%2Fbambi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbambinos%2Fbambi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbambinos%2Fbambi/lists"}