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
Contextualized linear regression is
where the coefficients
For more details, see the Contextualized Machine Learning whitepaper.
pip install contextualized-ml
Take a look at the easy demo for a quickstart with sklearn-style wrappers.
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
model.predict_params(C)
See the docs for more examples.
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}
}
Add your own contributions by sending a PR or request an improvement by creating an issue. See CONTRIBUTING.md for more info.
Contextualized ML was originally implemented by Caleb Ellington (CMU) and Ben Lengerich (MIT).
Beyond code contributions, many people have helped. Check out ACKNOWLEDGEMENTS.md!
- Contextualized Machine Learning
- Contextualized: Heterogeneous Modeling Toolbox
- Networks
- Applications
- Contextualized Policy Recovery: Modeling and Interpreting Medical Decisions with Adaptive Imitation Learning
- Automated Interpretable Discovery of Heterogeneous Treatment Effectiveness: A COVID-19 Case Study
- Discriminative Subtyping of Lung Cancers from Histopathology Images via Contextual Deep Learning
- Personalized Survival Prediction with Contextual Explanation Networks
- Contextual Explanation Networks
- Background reading:
- Cold Spring Harbor Laboratory: Contextualized Graphical Models Reveal Sample-Specific Transcriptional Networks for 7000 Tumors
- Sample-Specific Models for Interpretable Analysis with Applications to Disease Subtyping
Please get in touch with any questions, feature requests, or applications by using the GitHub discussions page.