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.
Changes about previous work
calibrate: instead ofBalanced Accuracy Score, it can be calibrated eitherMatthews Correlation CoefficientorBookmaker Informedness Score, for better reliability.evaluate: scoresbmandmccfor 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.
Installation
Install TinyCP using pip:
pip install tinycp
Note: If you want to enable plotting capabilities, you need to install the extras using Poetry:
poetry install --E plot
Usage
Importing Classifiers
Import the conformal classifiers from the tinycp.classifier module:
from tinycp.classifier import BinaryClassConditionalConformalClassifier
from tinycp.classifier import BinaryMarginalConformalClassifier
Importing Regressors
Import the conformal regressors from the tinycp.regressor module:
from tinycp.regressor import ConformalizedRegressor
from tinycp.regressor import ConformalizedQuantileRegressor
Example
Example usage of BinaryClassConditionalConformalClassifier:
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:
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.
Metadata
Release files for tinycp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tinycp-0.1.2.tar.gz | 16.6 kB | Without provenance | Details for tinycp-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tinycp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for tinycp-0.1.2-py3-none-any.whl |
Total release size: 37.4 kB
Release files / tinycp-0.1.2.tar.gz
| Download URL | tinycp-0.1.2.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08b1fb2be3e82c71de9744874d3cd3473f54de61dc357b04d3133f91231e1832
|
|
BLAKE2b-256 checksum How to use checksums |
a3b9a336d26307f937c1e5946e8bb47817ec20e7cadb7998b19bbb7c76d2a5d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.18
|
Release files / tinycp-0.1.2-py3-none-any.whl
| Download URL | tinycp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e14be394df2b5d78c98afea7c41018f052f38830274d18ef15fc5423ff388a9
|
|
BLAKE2b-256 checksum How to use checksums |
4de59d646531331d010da6ab8270b698bbbf340ac8c202b25100554fff0da597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.18
|
Security for tinycp 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.