Skip to main content

A statistical machine learning toolbox for estimating models, distributions, and functions with sample-specific parameters.

Project description

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.

Important links

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!

Related Publications and Pre-prints

Videos

Contact Us

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contextualized_ml-0.2.9.tar.gz (19.7 MB view details)

Uploaded Source

Built Distribution

contextualized_ml-0.2.9-py3-none-any.whl (72.4 kB view details)

Uploaded Python 3

File details

Details for the file contextualized_ml-0.2.9.tar.gz.

File metadata

  • Download URL: contextualized_ml-0.2.9.tar.gz
  • Upload date:
  • Size: 19.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for contextualized_ml-0.2.9.tar.gz
Algorithm Hash digest
SHA256 5540ce46b680d4ee8910c93621eaa1d1b5faa4d72e59451260c6579fb5c37338
MD5 7fb2b134ebd8d9dbc6d2fdb5ba6a002a
BLAKE2b-256 45fbb43495f3d9965c119b5b1862f97127d78614e27b6731a2da30e9f95e93df

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextualized_ml-0.2.9.tar.gz:

Publisher: publish.yml on cnellington/Contextualized

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file contextualized_ml-0.2.9-py3-none-any.whl.

File metadata

File hashes

Hashes for contextualized_ml-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6909c287c623cbeccf489ed6547819bd52df17b59ac4439f6b095b15b3861c12
MD5 e928a4d1153c9854725fdc0b68568360
BLAKE2b-256 22d4238ad5893ca3b2590497f3600022663ae5c2836c1fbe62b18ed9e5d1721d

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextualized_ml-0.2.9-py3-none-any.whl:

Publisher: publish.yml on cnellington/Contextualized

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page