tinycp


Nametinycp JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA small toolbox for conformal prediction
upload_time2025-08-30 16:59:35
maintainerNone
docs_urlNone
authorLucas Leão
requires_python<4.0,>=3.10
licenseMIT
keywords machine-learning conformal-prediction
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TinyCP
TinyCP is an experimental Python library for conformal predictions, providing tools to generate valid prediction sets with a specified significance level (alpha). This project aims to facilitate the implementation of personal and future projects on the topic.

For more information on a previous project related to Out-of-Bag (OOB) solutions, visit [this link](https://github.com/HeyLucasLeao/cp-study).

## Changes about previous work
- `calibrate`: instead of `Balanced Accuracy Score`, it can be calibrated either `Matthews Correlation Coefficient` or `Bookmaker Informedness Score`, for better reliability.
- `evaluate`: scores `bm` and `mcc` for more reliability.

Currently, TinyCP supports Out-of-Bag (OOB) solutions for `RandomForestClassifier` in binary classification problems, as well as `RandomForestRegressor` and `RandomForestQuantileRegressor` for regression tasks. For additional options and advanced features, you may want to explore [Crepes](https://github.com/henrikbostrom/crepes).

## Installation

Install TinyCP using pip:

```bash
pip install tinycp
```

> **Note:** If you want to enable plotting capabilities, you need to install the extras using Poetry:

```bash
poetry install --E plot
```

## Usage

### Importing Classifiers

Import the conformal classifiers from the `tinycp.classifier` module:

```python
from tinycp.classifier import BinaryClassConditionalConformalClassifier
from tinycp.classifier import BinaryMarginalConformalClassifier
```
### Importing Regressors

Import the conformal regressors from the `tinycp.regressor` module:

```python
from tinycp.regressor import ConformalizedRegressor
from tinycp.regressor import ConformalizedQuantileRegressor
```
### Example

Example usage of `BinaryClassConditionalConformalClassifier`:

```python
from sklearn.ensemble import RandomForestClassifier
from tinycp.classifier import BinaryClassConditionalConformalClassifier

# Create and fit a RandomForestClassifier
learner = RandomForestClassifier(n_estimators=100, oob_score=True)
X_train, y_train = ...  # your training data
learner.fit(X_train, y_train)

# Create and fit the conformal classifier
conformal_classifier = BinaryClassConditionalConformalClassifier(learner)
conformal_classifier.fit(y=y_train, oob=True)

# Make predictions
X_test = ...  # your test data
predictions = conformal_classifier.predict(X_test)
```

### Evaluating the Classifier

Evaluate the performance of the conformal classifier using the `evaluate` method:

```python
results = conformal_classifier.evaluate(X_test, y_test)
print(results)
```

## Classes

### BinaryMarginalConformalClassifier

`BinaryMarginalConformalClassifier` A marginal coverage conformal classifier methodology utilizing a classifier as the underlying learner. This classifier supports the option to use Out-of-Bag (OOB) samples for calibration.


### BinaryClassConditionalConformalClassifier

`BinaryClassConditionalConformalClassifier` A class conditional conformal classifier methodology utilizing a classifier as the underlying learner. This classifier supports the option to use Out-of-Bag (OOB) samples for calibration.

### ConformalizedRegressor

`ConformalizedRegressor` A conformal regressor methodology utilizing a regressor as the underlying learner. This regressor supports the option to use Out-of-Bag (OOB) samples for calibration, providing valid prediction intervals for regression tasks.

### ConformalizedQuantileRegressor

`ConformalizedQuantileRegressor` A conformal quantile regressor methodology utilizing a quantile regressor as the underlying learner. This regressor supports the option to use Out-of-Bag (OOB) samples for calibration, offering more robust prediction intervals by leveraging quantile estimates.

## License

This project is licensed under the MIT License.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tinycp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "machine-learning, conformal-prediction",
    "author": "Lucas Le\u00e3o",
    "author_email": "heylucasleao@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6e/2e/ac382c4b353554ef24f6801e75d021a20fc539ea773a86e15293e913fb41/tinycp-0.1.1.tar.gz",
    "platform": null,
    "description": "# TinyCP\nTinyCP is an experimental Python library for conformal predictions, providing tools to generate valid prediction sets with a specified significance level (alpha). This project aims to facilitate the implementation of personal and future projects on the topic.\n\nFor more information on a previous project related to Out-of-Bag (OOB) solutions, visit [this link](https://github.com/HeyLucasLeao/cp-study).\n\n## Changes about previous work\n- `calibrate`: instead of `Balanced Accuracy Score`, it can be calibrated either `Matthews Correlation Coefficient` or `Bookmaker Informedness Score`, for better reliability.\n- `evaluate`: scores `bm` and `mcc` for more reliability.\n\nCurrently, TinyCP supports Out-of-Bag (OOB) solutions for `RandomForestClassifier` in binary classification problems, as well as `RandomForestRegressor` and `RandomForestQuantileRegressor` for regression tasks. For additional options and advanced features, you may want to explore [Crepes](https://github.com/henrikbostrom/crepes).\n\n## Installation\n\nInstall TinyCP using pip:\n\n```bash\npip install tinycp\n```\n\n> **Note:** If you want to enable plotting capabilities, you need to install the extras using Poetry:\n\n```bash\npoetry install --E plot\n```\n\n## Usage\n\n### Importing Classifiers\n\nImport the conformal classifiers from the `tinycp.classifier` module:\n\n```python\nfrom tinycp.classifier import BinaryClassConditionalConformalClassifier\nfrom tinycp.classifier import BinaryMarginalConformalClassifier\n```\n### Importing Regressors\n\nImport the conformal regressors from the `tinycp.regressor` module:\n\n```python\nfrom tinycp.regressor import ConformalizedRegressor\nfrom tinycp.regressor import ConformalizedQuantileRegressor\n```\n### Example\n\nExample usage of `BinaryClassConditionalConformalClassifier`:\n\n```python\nfrom sklearn.ensemble import RandomForestClassifier\nfrom tinycp.classifier import BinaryClassConditionalConformalClassifier\n\n# Create and fit a RandomForestClassifier\nlearner = RandomForestClassifier(n_estimators=100, oob_score=True)\nX_train, y_train = ...  # your training data\nlearner.fit(X_train, y_train)\n\n# Create and fit the conformal classifier\nconformal_classifier = BinaryClassConditionalConformalClassifier(learner)\nconformal_classifier.fit(y=y_train, oob=True)\n\n# Make predictions\nX_test = ...  # your test data\npredictions = conformal_classifier.predict(X_test)\n```\n\n### Evaluating the Classifier\n\nEvaluate the performance of the conformal classifier using the `evaluate` method:\n\n```python\nresults = conformal_classifier.evaluate(X_test, y_test)\nprint(results)\n```\n\n## Classes\n\n### BinaryMarginalConformalClassifier\n\n`BinaryMarginalConformalClassifier` A marginal coverage conformal classifier methodology utilizing a classifier as the underlying learner. This classifier supports the option to use Out-of-Bag (OOB) samples for calibration.\n\n\n### BinaryClassConditionalConformalClassifier\n\n`BinaryClassConditionalConformalClassifier` A class conditional conformal classifier methodology utilizing a classifier as the underlying learner. This classifier supports the option to use Out-of-Bag (OOB) samples for calibration.\n\n### ConformalizedRegressor\n\n`ConformalizedRegressor` A conformal regressor methodology utilizing a regressor as the underlying learner. This regressor supports the option to use Out-of-Bag (OOB) samples for calibration, providing valid prediction intervals for regression tasks.\n\n### ConformalizedQuantileRegressor\n\n`ConformalizedQuantileRegressor` A conformal quantile regressor methodology utilizing a quantile regressor as the underlying learner. This regressor supports the option to use Out-of-Bag (OOB) samples for calibration, offering more robust prediction intervals by leveraging quantile estimates.\n\n## License\n\nThis project is licensed under the MIT License.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A small toolbox for conformal prediction",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [
        "machine-learning",
        " conformal-prediction"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "66cf123ec69dc1db9f885ca82f1878d87d558e43c0a3b0b3f9b6b75f104b562c",
                "md5": "02b112db97e31b8a76264a8ef8b09a3b",
                "sha256": "3c7dadc37c269479563ccf8c3b0120ac99242e4a3faf35e38c7ac301bfa43c52"
            },
            "downloads": -1,
            "filename": "tinycp-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "02b112db97e31b8a76264a8ef8b09a3b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 20603,
            "upload_time": "2025-08-30T16:59:34",
            "upload_time_iso_8601": "2025-08-30T16:59:34.556111Z",
            "url": "https://files.pythonhosted.org/packages/66/cf/123ec69dc1db9f885ca82f1878d87d558e43c0a3b0b3f9b6b75f104b562c/tinycp-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6e2eac382c4b353554ef24f6801e75d021a20fc539ea773a86e15293e913fb41",
                "md5": "a0ccf88069bf6bdc9b9b5d88946d7165",
                "sha256": "27229736eb0b5c94d68cbf5fb4da218fe04af9b26edcb85facc3c142ae2ef736"
            },
            "downloads": -1,
            "filename": "tinycp-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a0ccf88069bf6bdc9b9b5d88946d7165",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 14349,
            "upload_time": "2025-08-30T16:59:35",
            "upload_time_iso_8601": "2025-08-30T16:59:35.648092Z",
            "url": "https://files.pythonhosted.org/packages/6e/2e/ac382c4b353554ef24f6801e75d021a20fc539ea773a86e15293e913fb41/tinycp-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-30 16:59:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tinycp"
}
        
Elapsed time: 1.55198s