https://github.com/bayer-group/pybalance

A library for minimizing the effects of confounding covariates

https://github.com/bayer-group/pybalance

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: wiley.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.5%) to scientific vocabulary

Keywords

beat-undefined confounding machine-learning python statistical-analysis
Last synced: 5 months ago · JSON representation

Repository

A library for minimizing the effects of confounding covariates

Basic Info
  • Host: GitHub
  • Owner: Bayer-Group
  • License: bsd-3-clause
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage:
  • Size: 33.2 MB
Statistics
  • Stars: 14
  • Watchers: 2
  • Forks: 0
  • Open Issues: 8
  • Releases: 10
Topics
beat-undefined confounding machine-learning python statistical-analysis
Created over 2 years ago · Last pushed 9 months ago
Metadata Files
Readme Contributing License Codeowners

README.md

https://bayer-group.github.io/pybalance/index.html

Confounding Adjustment

In scientific experiments, researchers aim to identify cause and effect by holding all variables except one constant. Any difference in outcome can then be attributed to the manipulated variable.

However, in many practical cases, it is not possible to control the variables of interest. For instance, it is unethical to conduct a randomized trial to test the effects of smoking on long-term health outcomes; yet the answer to this question is of extreme interest to policy makers, insurance companies and regulatory agencies. Similarly, in social science research, when studying the impact of education on income, researchers cannot manipulate individuals' education levels while holding all other variables constant.

In these cases, observational data can form the basis for "natural experiments" but care must be taken in interpreting these data. One major issue with interpreting these data is known as "confounding".

A classic example of confounding is the association between coffee consumption and heart disease. Initially, a study might find a positive correlation between high coffee consumption and increased risk of heart disease. However, this apparent relationship could be confounded by the fact that heavy coffee drinkers are more likely to also smoke, which is a known risk factor for heart disease. In this case, smoking acts as a confounding variable, as it distorts the true relationship between coffee consumption and heart disease. To address this, researchers need to adjust for smoking status and potentially other relevant variables to accurately assess the independent impact of coffee consumption on heart disease risk.

In general, any comparative analysis of two non-randomized populations will differ systematically in a number of covariate dimensions and these systematic differences must be adjusted for as part of any causal inference analysis. That is where pybalance comes in.

PyBalance

pybalance is a suite of tools in python for performing confounding adjustment in non-randomized populations. In pybalance, we start with measures of "balance" (how similar two populations are) and directly optimize this metric. This approach is different, and we think almost always better, from the well-known propensity score approach, in which the probability of treatment assignment is modelled, but balance metrics are almost always anyway implicitly defining the success criterion (see our demo). Our approach here is to explicitly define and directly optimize the balance metric that is relevant for the given problem.

The pybalance library implements several routines for optimizing balance. To learn more about these methods, head on over to the demos. Then give the code a spin for yourself by following the installation instructions. Any questions or issues please feel free to open an issue or start a discussion.

An application of this library to build an external control arm in a pharmaceutical setting is presented here.

Features

  • Implements linear and non-linear optimization approaches for matching.
  • Utilizes integer program solvers and evolutionary solvers for optimization.
  • Includes implementation of propensity score matching for comparison.
  • Offers a variety of balance calculators and matchers.
  • Provides visualization tools for analysis.
  • Supports simulation of datasets for testing and demonstration purposes.

Limitations

At the moment, pybalance only implements matching routines. Suport for weighting methods is on our roadmap and will appear in a future release.

Citation

If you use pybalance for your research, please acknowledge this with a citation to our paper.

Owner

  • Name: Bayer Open Source
  • Login: Bayer-Group
  • Kind: organization

Science for a better life

GitHub Events

Total
  • Release event: 3
  • Watch event: 1
  • Delete event: 4
  • Member event: 1
  • Push event: 12
  • Pull request event: 4
  • Create event: 7
Last Year
  • Release event: 3
  • Watch event: 1
  • Delete event: 4
  • Member event: 1
  • Push event: 12
  • Pull request event: 4
  • Create event: 7

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 102
  • Total Committers: 2
  • Avg Commits per committer: 51.0
  • Development Distribution Score (DDS): 0.088
Past Year
  • Commits: 45
  • Committers: 2
  • Avg Commits per committer: 22.5
  • Development Distribution Score (DDS): 0.089
Top Committers
Name Email Commits
Stephen Privitera s****a@b****m 93
abhishek-ch a****h 9
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 11
  • Total pull requests: 26
  • Average time to close issues: 4 months
  • Average time to close pull requests: 15 days
  • Total issue authors: 2
  • Total pull request authors: 3
  • Average comments per issue: 1.27
  • Average comments per pull request: 0.19
  • Merged pull requests: 18
  • Bot issues: 0
  • Bot pull requests: 4
Past Year
  • Issues: 5
  • Pull requests: 14
  • Average time to close issues: about 24 hours
  • Average time to close pull requests: about 2 hours
  • Issue authors: 2
  • Pull request authors: 2
  • Average comments per issue: 2.6
  • Average comments per pull request: 0.07
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sprivite (9)
  • abhishek-ch (2)
Pull Request Authors
  • sprivite (28)
  • dependabot[bot] (4)
  • abhishek-ch (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (4)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 42 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 8
  • Total maintainers: 2
pypi.org: pybalance

Population Matching

  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 42 Last month
Rankings
Dependent packages count: 10.0%
Downloads: 21.1%
Average: 32.5%
Dependent repos count: 66.3%
Maintainers (2)
Last synced: 6 months ago

Dependencies

.github/workflows/docker-image.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • docker/login-action v2 composite
  • mr-smithers-excellent/docker-build-push v5 composite
.github/workflows/sphinx.yml actions
  • actions/checkout v3 composite
  • actions/configure-pages v1 composite
  • actions/deploy-pages main composite
  • actions/download-artifact master composite
  • actions/setup-python v4 composite
  • actions/upload-artifact master composite
  • actions/upload-pages-artifact v1 composite
environments/Dockerfile docker
  • python 3.8-slim-buster build
environments/requirements.txt pypi
  • PyYAML >=6.0
  • boto3 *
  • cvxpy ==1.3.1
  • fsspec *
  • matplotlib >=3.7.1
  • numpy >=1.24.3
  • ortools ==9.4.1874
  • pandas >=2.0.1
  • pyarrow >=12.0.0
  • pytest >=7.3.1
  • s3fs *
  • scikit-learn ==1.2.1
  • scipy >=1.10.1
  • seaborn >=0.12.2
  • torch >=2.0.0
environments/requirements_dev.txt pypi
  • black * development
  • ipython * development
  • jupyter * development
  • jupyterlab * development
  • mypy * development
  • nbsphinx * development
  • notebook * development
  • recommonmark * development
  • sphinx_rtd_theme * development
environments/requirements_gpu.txt pypi
  • Babel ==2.12.1
  • Jinja2 ==3.1.2
  • MarkupSafe ==2.1.3
  • Pillow ==9.5.0
  • PyYAML ==6.0
  • Pygments ==2.15.1
  • Send2Trash ==1.8.2
  • Sphinx ==6.2.1
  • absl-py ==1.4.0
  • alabaster ==0.7.13
  • anyio ==3.7.0
  • argon2-cffi ==21.3.0
  • argon2-cffi-bindings ==21.2.0
  • arrow ==1.2.3
  • asttokens ==2.2.1
  • async-lru ==2.0.2
  • attrs ==23.1.0
  • backcall ==0.2.0
  • beautifulsoup4 ==4.12.2
  • black ==23.3.0
  • bleach ==6.0.0
  • boto3 ==1.26.153
  • botocore ==1.29.153
  • certifi ==2023.5.7
  • cffi ==1.15.1
  • charset-normalizer ==3.1.0
  • click ==8.1.3
  • cmake ==3.26.4
  • comm ==0.1.3
  • commonmark ==0.9.1
  • contourpy ==1.1.0
  • cvxpy ==1.3.1
  • cycler ==0.11.0
  • debugpy ==1.6.7
  • decorator ==5.1.1
  • defusedxml ==0.7.1
  • docutils ==0.18.1
  • ecos ==2.0.12
  • exceptiongroup ==1.1.1
  • executing ==1.2.0
  • fastjsonschema ==2.17.1
  • filelock ==3.12.2
  • fonttools ==4.40.0
  • fqdn ==1.5.1
  • fsspec ==2023.6.0
  • idna ==3.4
  • imagesize ==1.4.1
  • iniconfig ==2.0.0
  • ipykernel ==6.23.2
  • ipython ==8.14.0
  • ipython-genutils ==0.2.0
  • isoduration ==20.11.0
  • jedi ==0.18.2
  • jmespath ==1.0.1
  • joblib ==1.2.0
  • json5 ==0.9.14
  • jsonpointer ==2.3
  • jsonschema ==4.17.3
  • jupyter-events ==0.6.3
  • jupyter-lsp ==2.2.0
  • jupyter_client ==8.2.0
  • jupyter_core ==5.3.0
  • jupyter_server ==2.6.0
  • jupyter_server_terminals ==0.4.4
  • jupyterlab ==4.0.2
  • jupyterlab-pygments ==0.2.2
  • jupyterlab_server ==2.23.0
  • kiwisolver ==1.4.4
  • lit ==16.0.5.post0
  • matplotlib ==3.7.1
  • matplotlib-inline ==0.1.6
  • mistune ==2.0.5
  • mpmath ==1.3.0
  • mypy ==1.3.0
  • mypy-extensions ==1.0.0
  • nbclassic ==1.0.0
  • nbclient ==0.8.0
  • nbconvert ==7.5.0
  • nbformat ==5.9.0
  • nbsphinx ==0.9.2
  • nest-asyncio ==1.5.6
  • networkx ==3.1
  • notebook ==6.5.4
  • notebook_shim ==0.2.3
  • numpy ==1.24.3
  • nvidia-cublas-cu11 ==11.10.3.66
  • nvidia-cuda-cupti-cu11 ==11.7.101
  • nvidia-cuda-nvrtc-cu11 ==11.7.99
  • nvidia-cuda-runtime-cu11 ==11.7.99
  • nvidia-cudnn-cu11 ==8.5.0.96
  • nvidia-cufft-cu11 ==10.9.0.58
  • nvidia-curand-cu11 ==10.2.10.91
  • nvidia-cusolver-cu11 ==11.4.0.1
  • nvidia-cusparse-cu11 ==11.7.4.91
  • nvidia-nccl-cu11 ==2.14.3
  • nvidia-nvtx-cu11 ==11.7.91
  • ortools ==9.4.1874
  • osqp ==0.6.3
  • overrides ==7.3.1
  • packaging ==23.1
  • pandas ==2.0.2
  • pandocfilters ==1.5.0
  • parso ==0.8.3
  • pathspec ==0.11.1
  • pexpect ==4.8.0
  • pickleshare ==0.7.5
  • platformdirs ==3.5.3
  • pluggy ==1.0.0
  • prometheus-client ==0.17.0
  • prompt-toolkit ==3.0.38
  • protobuf ==4.23.2
  • psutil ==5.9.5
  • ptyprocess ==0.7.0
  • pure-eval ==0.2.2
  • pyarrow ==12.0.1
  • pycparser ==2.21
  • pyparsing ==3.0.9
  • pyrsistent ==0.19.3
  • pytest ==7.3.2
  • python-dateutil ==2.8.2
  • python-json-logger ==2.0.7
  • pytz ==2023.3
  • pyzmq ==25.1.0
  • qdldl ==0.1.7
  • recommonmark ==0.7.1
  • requests ==2.31.0
  • rfc3339-validator ==0.1.4
  • rfc3986-validator ==0.1.1
  • s3fs ==0.4.2
  • s3transfer ==0.6.1
  • scikit-learn ==1.2.1
  • scipy ==1.10.1
  • scs ==3.2.3
  • seaborn ==0.12.2
  • six ==1.16.0
  • sniffio ==1.3.0
  • snowballstemmer ==2.2.0
  • soupsieve ==2.4.1
  • sphinx-rtd-theme ==1.2.2
  • sphinxcontrib-applehelp ==1.0.4
  • sphinxcontrib-devhelp ==1.0.2
  • sphinxcontrib-htmlhelp ==2.0.1
  • sphinxcontrib-jquery ==4.1
  • sphinxcontrib-jsmath ==1.0.1
  • sphinxcontrib-qthelp ==1.0.3
  • sphinxcontrib-serializinghtml ==1.1.5
  • stack-data ==0.6.2
  • sympy ==1.12
  • terminado ==0.17.1
  • threadpoolctl ==3.1.0
  • tinycss2 ==1.2.1
  • tomli ==2.0.1
  • torch ==2.0.1
  • tornado ==6.3.2
  • traitlets ==5.9.0
  • triton ==2.0.0
  • typing_extensions ==4.6.3
  • tzdata ==2023.3
  • uri-template ==1.2.0
  • urllib3 ==1.26.16
  • wcwidth ==0.2.6
  • webcolors ==1.13
  • webencodings ==0.5.1
  • websocket-client ==1.5.3
setup.py pypi
.github/workflows/pypi.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite