{"id":34044803,"url":"https://github.com/egonmedhatten/online-cp","last_synced_at":"2026-04-08T15:32:41.753Z","repository":{"id":262823474,"uuid":"814135043","full_name":"egonmedhatten/online-cp","owner":"egonmedhatten","description":"Repository for online conformal prediction methods","archived":false,"fork":false,"pushed_at":"2025-12-05T09:27:14.000Z","size":25768,"stargazers_count":4,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-12-08T18:25:04.312Z","etag":null,"topics":["conformal-prediction","online-compression-modelling","testing-randomness","uncertainty-quantification"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/online-cp/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/egonmedhatten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","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":"2024-06-12T12:07:31.000Z","updated_at":"2025-12-05T09:27:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c9390ff-bb8e-45bc-a268-27a6426b30a6","html_url":"https://github.com/egonmedhatten/online-cp","commit_stats":null,"previous_names":["egonmedhatten/onlineconformalprediction"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/egonmedhatten/online-cp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egonmedhatten%2Fonline-cp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egonmedhatten%2Fonline-cp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egonmedhatten%2Fonline-cp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egonmedhatten%2Fonline-cp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egonmedhatten","download_url":"https://codeload.github.com/egonmedhatten/online-cp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egonmedhatten%2Fonline-cp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["conformal-prediction","online-compression-modelling","testing-randomness","uncertainty-quantification"],"created_at":"2025-12-13T23:02:28.353Z","updated_at":"2026-04-08T15:32:41.744Z","avatar_url":"https://github.com/egonmedhatten.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# online-cp -- Online Conformal Prediction\n\n[![online-cp's Build Status][build-status]][build-log]\n[![online-cp on PyPI][pypi-version]][online-cp-on-pypi]\n\nThis project is an implementation of Online Conformal Prediction.\n\nFor now, take a look at [`example.ipynb`][] to see how to use the library.\n\n\n## Quick start\n\nThe `online-cp` package is [available on PyPI][online-cp-on-pypi], to install just:\n\n```bash\npip install online-cp\n```\n\nLet's create a dataset with noisy evaluations of the function _f(x₁, x₂) = x₁ + x₂_.\n\n```py\nimport numpy as np\nN = 30\nX = np.random.uniform(0, 1, (N, 2))\ny = X.sum(axis=1) + np.random.normal(0, 0.1, N)\ncp.learn_initial_training_set(X, y)\n```\n\nImport the library and create a regressor:\n\n```py\nfrom online_cp import ConformalRidgeRegressor\ncp = ConformalRidgeRegressor(epsilon=0.1)\n```\n\nTo predict, simply do\n```py\ncp.predict(X[0])\n(-inf, inf)\n```\nThe output is non-informative since we have not learned anything yet. The parameter `epsilon` is the significance level.\n\nAlternative 1: Learn the dataset sequentially online, and make predictions as we go. In order to output nontrivial prediction at significance level `epsilon=0.1`, we need to have learned at least 20 examples.\n\n```py\nfor x, y in zip(X[-1], Y[-1]):\n    print(f'Prediction set: {cp.predict(x)}')\n    cp.learn_one(x, y)\n```\n\nIn the online setting, we first observe the object _x_, which is used to make a prediction, only then to observe the label _y_. The output will be `(inf, inf)` for the first 19 predictions, after which we will typically see meaningful prediction sets. The snippet above learned all but the last example. To predict it, do (your output may not be exactly the same, as the dataset depends on the random seed).\n\n```py\ncp.predict(X[-1])\n(0.029643344144500712, 0.34909922671253196)\n```\n\nThe prediction set is the closed interval whose boundaries are indicated by the output.\n\nAlternative 2: Learn an initial training set offline, and predict e.g. only the last example\n\n```py\ncp = ConformalRidgeRegressor()\ncp.learn_initial_training_set(X[:-1], Y[:-1])\ncp.predict(X[-1])\n(0.8748194061248175, 1.3357383729107446)\n```\n\nFurhter examples can be found in the notebooks, e.g. [`example.ipynb`][]. Current functionality includes\n* Conformal regression\n* Conformal classification\n* Testing exchangeability through conformal test martignales\n\n\n## Links\n\n* [online-cp on GitHub][online-cp-on-github]\n* [online-cp on PyPI][online-cp-on-pypi]\n\n\n## References\n\nThe main reference for Conformal Prediction is the book\n\nVladimir Vovk, Alexander Gammerman, and Glenn Shafer. Algorithmic Learning in a Random World (2nd ed). Springer Nature, 2022.\n\n\n[`example.ipynb`]: https://github.com/egonmedhatten/online-cp/blob/main/notebooks/example.ipynb\n[online-cp-on-pypi]: https://pypi.org/project/online-cp/\n[online-cp-on-github]: https://github.com/egonmedhatten/online-cp\n[pypi-version]: https://img.shields.io/pypi/v/online-cp\n[build-log]:    https://github.com/egonmedhatten/online-cp/actions/workflows/test.yml\n[build-status]: https://github.com/egonmedhatten/online-cp/actions/workflows/test.yml/badge.svg\n\n## 📄 Citing `online-cp`\n\nIf you use `online-cp` in your work, please cite the following paper. It helps support the ongoing development of this package.\n\n### BibTeX\n\nFor users of LaTeX and bibliography managers, please use this BibTeX entry:\n\n```bibtex\n@InProceedings{pmlr-v266-hallberg-szabadvary25a,\n  title = \t {online-cp: a Python Package for Online Conformal Prediction, Conformal Predictive Systems and Conformal Test Martingales},\n  author =       {Hallberg Szabadv\\'{a}ry, Johan and L\\\"{o}fstr\\\"{o}m, Tuwe and Matela, Rudy},\n  booktitle = \t {Proceedings of the Fourteenth Symposium on Conformal and Probabilistic Prediction with Applications},\n  pages = \t {595--614},\n  year = \t {2025},\n  editor = \t {Nguyen, Khuong An and Luo, Zhiyuan and Papadopoulos, Harris and L\\\"ofstr\\\"om, Tuwe and Carlsson, Lars and Bostr\\\"om, Henrik},\n  volume = \t {266},\n  series = \t {Proceedings of Machine Learning Research},\n  month = \t {10--12 Sep},\n  publisher =    {PMLR},\n  pdf = \t {[https://raw.githubusercontent.com/mlresearch/v266/main/assets/hallberg-szabadvary25a/hallberg-szabadvary25a.pdf](https://raw.githubusercontent.com/mlresearch/v266/main/assets/hallberg-szabadvary25a/hallberg-szabadvary25a.pdf)},\n  url = \t {[https://proceedings.mlr.press/v266/hallberg-szabadvary25a.html](https://proceedings.mlr.press/v266/hallberg-szabadvary25a.html)}\n}\n```\n\n### Formatted Citation (APA Style)\n\nHallberg Szabadváry, J., Löfström, T., \u0026 Matela, R. (2025). online-cp: a Python Package for Online Conformal Prediction, Conformal Predictive Systems and Conformal Test Martingales. In K. A. Nguyen, Z. Luo, H. Papadopoulos, T. Löfström, L. Carlsson, \u0026 H. Boström (Eds.), *Proceedings of the Fourteenth Symposium on Conformal and Probabilistic Prediction with Applications* (Vol. 266, pp. 595–614). PMLR. https://proceedings.mlr.press/v266/hallberg-szabadvary25a.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegonmedhatten%2Fonline-cp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegonmedhatten%2Fonline-cp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegonmedhatten%2Fonline-cp/lists"}