Skip to main content

Preview

License python PyPI version Maintenance Downloads pylint Score Code style: black DOI

An SKLearn-style toolbox for estimating and analyzing models, distributions, and functions with context-specific parameters.

Context-specific parameters:

  • Find hidden heterogeneity in data -- are all samples the same?
  • Identify context-specific predictors -- are there different reasons for outcomes?
  • Enable domain adaptation -- can learned models extrapolate to new contexts?

Most models can be contextualized. For example, linear regression is

Y = X\beta + \epsilon

Contextualized linear regression is

Y = X\beta(C) + \epsilon

where the coefficients $\beta$ are now a function of context $C$, allowing the model to adapt to context-specific changes. Contextualized implements this for many types of statistical models, including linear regression, logistic regression, Bayesian networks, correlation networks, and Markov networks.

For more details, see the Contextualized Machine Learning whitepaper.

Quick Start

Installation

pip install contextualized-ml

Take a look at the easy demo for a quickstart with sklearn-style wrappers.

Build a Contextualized Model

from contextualized.easy import ContextualizedRegressor
model = ContextualizedRegressor()
model.fit(C, X, Y)

This builds a contextualized linear regression model by fitting a deep-learning model to generate context-specific coefficients $\beta(C)$.

Predict Context-Specific Parameters

model.predict_params(C)

See the docs for more examples.

Citing

If you use this software, please cite the software publication:

@article{Ellington2024,
  doi = {10.21105/joss.06469},
  url = {https://doi.org/10.21105/joss.06469},
  year = {2024},
  publisher = {The Open Journal},
  volume = {9},
  number = {97},
  pages = {6469},
  author = {Caleb N. Ellington and Benjamin J. Lengerich and Wesley Lo and Aaron Alvarez and Andrea Rubbi and Manolis Kellis and Eric P. Xing},
  title = {Contextualized: Heterogeneous Modeling Toolbox},
  journal = {Journal of Open Source Software}
}

Contributing

Add your own contributions by sending a PR or request an improvement by creating an issue. See CONTRIBUTING.md for more info.

Thanks to all our contributors

Contextualized ML was originally implemented by Caleb Ellington (CMU) and Ben Lengerich (MIT).

Beyond code contributions, many people have helped. Check out ACKNOWLEDGEMENTS.md!

Videos

Contact Us

Please get in touch with any questions, feature requests, or applications by using the GitHub discussions page.

Metadata

Release files for contextualized-ml 0.2.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contextualized-ml 0.2.9
File Size Uploaded
contextualized_ml-0.2.9.tar.gz 19.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for contextualized-ml 0.2.9
File Interpreter ABI Platform
contextualized_ml-0.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 MB

Release files / contextualized_ml-0.2.9.tar.gz

Download URL contextualized_ml-0.2.9.tar.gz
Size 19.7 MB
Tags Source
SHA-256 checksum
How to use checksums
5540ce46b680d4ee8910c93621eaa1d1b5faa4d72e59451260c6579fb5c37338
BLAKE2b-256 checksum
How to use checksums
45fbb43495f3d9965c119b5b1862f97127d78614e27b6731a2da30e9f95e93df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2025.

Transparency log

Release files / contextualized_ml-0.2.9-py3-none-any.whl

Download URL contextualized_ml-0.2.9-py3-none-any.whl
Size 72.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6909c287c623cbeccf489ed6547819bd52df17b59ac4439f6b095b15b3861c12
BLAKE2b-256 checksum
How to use checksums
22d4238ad5893ca3b2590497f3600022663ae5c2836c1fbe62b18ed9e5d1721d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 2, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.9 This release

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page