{"id":31761450,"url":"https://github.com/adaptinfer/contextualized","last_synced_at":"2025-12-13T20:48:47.647Z","repository":{"id":36993530,"uuid":"392447369","full_name":"AdaptInfer/Contextualized","owner":"AdaptInfer","description":"An SKLearn-style toolbox for estimating and analyzing models, distributions, and functions with context-specific parameters.","archived":false,"fork":false,"pushed_at":"2025-09-20T02:16:52.000Z","size":105457,"stargazers_count":75,"open_issues_count":38,"forks_count":14,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-09T16:31:53.625Z","etag":null,"topics":["bioinformatics","machine-learning","medical-informatics","statistics"],"latest_commit_sha":null,"homepage":"http://contextualized.ml/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdaptInfer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-08-03T20:29:06.000Z","updated_at":"2025-09-25T18:58:37.000Z","dependencies_parsed_at":"2023-12-27T01:38:25.780Z","dependency_job_id":"337b8344-bc3a-400e-914d-d61a536d8f67","html_url":"https://github.com/AdaptInfer/Contextualized","commit_stats":{"total_commits":295,"total_committers":6,"mean_commits":"49.166666666666664","dds":0.4203389830508475,"last_synced_commit":"a73c6042b358b59561f6732ac0e9d1636fec8cb9"},"previous_names":["adaptinfer/contextualized","cnellington/contextualized"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/AdaptInfer/Contextualized","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptInfer%2FContextualized","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptInfer%2FContextualized/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptInfer%2FContextualized/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptInfer%2FContextualized/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdaptInfer","download_url":"https://codeload.github.com/AdaptInfer/Contextualized/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaptInfer%2FContextualized/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002044,"owners_count":26083286,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bioinformatics","machine-learning","medical-informatics","statistics"],"created_at":"2025-10-09T21:52:26.720Z","updated_at":"2025-10-09T21:52:31.347Z","avatar_url":"https://github.com/AdaptInfer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Preview](docs/logo.png)\n#\n\n![License](https://img.shields.io/github/license/cnellington/contextualized.svg?style=flat-square)\n![python](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11-blue)\n[![PyPI version](https://badge.fury.io/py/contextualized-ml.svg)](https://badge.fury.io/py/contextualized-ml)\n![Maintenance](https://img.shields.io/maintenance/yes/2025?style=flat-square)\n[![Downloads](https://pepy.tech/badge/contextualized-ml)](https://pepy.tech/project/contextualized-ml)\n![pylint Score](pylint.svg)\n\u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n[![DOI](https://joss.theoj.org/papers/10.21105/joss.06469/status.svg)](https://doi.org/10.21105/joss.06469)\n\n\nAn SKLearn-style toolbox for estimating and analyzing models, distributions, and functions with context-specific parameters.\n\nContext-specific parameters:\n- Find hidden heterogeneity in data -- are all samples the same?\n- Identify context-specific predictors -- are there different reasons for outcomes?\n- Enable domain adaptation -- can learned models extrapolate to new contexts?\n\nMost models can be contextualized. For example, [linear regression](https://en.wikipedia.org/wiki/Linear_regression#Formulation) is\n```math\nY = X\\beta + \\epsilon\n```\n\nContextualized linear regression is\n```math\nY = X\\beta(C) + \\epsilon\n```\nwhere the coefficients $\\beta$ are now a function of context $C$, allowing the model to adapt to context-specific changes. \nContextualized implements this for many types of statistical models, including linear regression, logistic regression, Bayesian networks, correlation networks, and Markov networks.\n\nFor more details, see the [Contextualized Machine Learning whitepaper](https://arxiv.org/abs/2310.11340).\n\n## Quick Start\n\n### Installation\n```\npip install contextualized-ml\n```\n\nTake a look at the [easy demo](docs/models/easy_regression.ipynb) for a quickstart with sklearn-style wrappers.\n\n### Build a Contextualized Model\n```\nfrom contextualized.easy import ContextualizedRegressor\nmodel = ContextualizedRegressor()\nmodel.fit(C, X, Y, normalize=True)\n```\nThis builds a contextualized linear regression model by fitting a deep-learning model to generate context-specific coefficients $\\beta(C)$.\n\n### Predict Context-Specific Parameters\n```\nmodel.predict_params(C)\n```\n\nSee the [docs](https://contextualized.ml/docs) for more examples.\n\n### Important links\n\n- [Documentation](https://contextualized.ml/docs)\n- [Pypi package index](https://pypi.python.org/pypi/contextualized-ml)\n\n## Citing\nIf you use this software, please cite the software [publication](https://doi.org/10.21105/joss.06469):\n```\n@article{Ellington2024,\n  doi = {10.21105/joss.06469},\n  url = {https://doi.org/10.21105/joss.06469},\n  year = {2024},\n  publisher = {The Open Journal},\n  volume = {9},\n  number = {97},\n  pages = {6469},\n  author = {Caleb N. Ellington and Benjamin J. Lengerich and Wesley Lo and Aaron Alvarez and Andrea Rubbi and Manolis Kellis and Eric P. Xing},\n  title = {Contextualized: Heterogeneous Modeling Toolbox},\n  journal = {Journal of Open Source Software}\n}\n```\n\n## Contributing\n\nAdd your own contributions by sending a PR or request an improvement by creating an [issue](https://github.com/cnellington/Contextualized/issues). See [CONTRIBUTING.md](https://github.com/cnellington/Contextualized/blob/main/CONTRIBUTING.md) for more info.\n\n## Thanks to all our contributors\n\n\u003ca href=\"https://github.com/cnellington/contextualized/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=cnellington/contextualized\" /\u003e\n\u003c/a\u003e\n\nContextualized ML was originally implemented by [Caleb Ellington](https://calebellington.com/) (CMU) and [Ben Lengerich](http://web.mit.edu/~blengeri/www) (MIT).\n\nBeyond code contributions, many people have helped. Check out [ACKNOWLEDGEMENTS.md](https://github.com/cnellington/Contextualized/blob/main/ACKNOWLEDGEMENTS.md)!\n\n## Related Publications and Pre-prints\n- [Contextualized Machine Learning (ArXiv '23)](https://arxiv.org/abs/2310.11340)\n- [Contextualized: Heterogeneous Modeling Toolbox (JOSS '24)](https://doi.org/10.21105/joss.06469)\n- Contextualized Regression and Classification\n  - [Patient-Specific Models of Treatment Effects Explain Heterogeneity in Tuberculosis (ML4H '24)](https://arxiv.org/abs/2411.10645)\n  - [Automated Interpretable Discovery of Heterogeneous Treatment Effectiveness: A COVID-19 Case Study (JBI '22)](https://www.sciencedirect.com/science/article/pii/S1532046422001022)\n  - [Discriminative Subtyping of Lung Cancers from Histopathology Images via Contextual Deep Learning (MedRxiv '22)](https://www.medrxiv.org/content/10.1101/2020.06.25.20140053v2)\n  - [Personalized Survival Prediction with Contextual Explanation Networks (ML4H '17)](http://arxiv.org/abs/1801.09810)\n  - [Contextual Explanation Networks (JMLR '20)](https://jmlr.org/papers/v21/18-856.html)\n- Contextualized Networks\n  - [Learning to estimate sample-specific transcriptional networks for 7,000 tumors (PNAS '25)](https://www.pnas.org/doi/10.1073/pnas.2411930122)\n  - [NOTMAD: Estimating Bayesian Networks with Sample-Specific Structures and Parameters (ArXiv '23)](http://arxiv.org/abs/2111.01104)\n- Contextualized Timeseries\n  - [Contextualized Policy Recovery: Modeling and Interpreting Medical Decisions with Adaptive Imitation Learning (ICML '24)](https://arxiv.org/abs/2310.07918)\n- Background reading:\n  - [Varying-Coefficient Models (JRStatSoc)](https://academic.oup.com/jrsssb/article-abstract/55/4/757/7028270)\n\n\n## Videos\n- [Cold Spring Harbor Laboratory: Contextualized Graphical Models Reveal Sample-Specific Transcriptional Networks for 7000 Tumors](https://www.youtube.com/watch?v=MTcjFK-YwCw)\n- [Sample-Specific Models for Interpretable Analysis with Applications to Disease Subtyping](http://www.birs.ca/events/2022/5-day-workshops/22w5055/videos/watch/202205051559-Lengerich.html)\n\n## Contact Us\nPlease get in touch with any questions, feature requests, or applications by using the [GitHub discussions page](https://github.com/cnellington/Contextualized/discussions).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaptinfer%2Fcontextualized","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadaptinfer%2Fcontextualized","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaptinfer%2Fcontextualized/lists"}