Conformist
Conformist v1.1.1 is an implementation of conformal prediction, specifically conformal risk control. It was written using Python 3.8.
BaseCoP contains utility functions common to all conformal predictors, such as splitting data into calibration and validation sets, and setting up runs. It is extended by FNRCoP that implements conformal risk control.
The ValidationRun class contains the data from a single run, which entails shuffling the data randomly, splitting it into calibration and validation datasets, calibrating the conformal predictor on the calibration data and creating prediction sets for the validation data.
The ValidationTrial class contains a list of runs and calculates statistics across these runs.
Installation
pip install conformist
Input file format
The input to Conformist is a CSV file with the following columns:
id, known_class, predicted_class, [proba_columns]
The proba_columns should contain class-specific probability scores and correspond to the names used in the known_class and predicted_class columns.
Example:
| id | known_class | predicted_class | ClassA | ClassB | ClassC |
|---|---|---|---|---|---|
| Sample1 | ClassB | ClassA | 0.70 | 0.25 | 0.05 |
| Sample2 | ClassA | ClassA | 0.98 | 0.02 | 0.0 |
| Sample3 | ClassC | ClassC | 0.01 | 0.01 | 0.98 |
Example implementation
from conformist import FNRCoP, PredictionDataset, ValidationTrial
CALIB_DATA_CSV = 'path/to/calib.csv'
TEST_DATA_CSV = 'path/to/test.csv'
OUTPUT_DIR = 'path/to/output'
ALPHA = 0.05 # Select a reasonable False Negative Rate
# Read in formatted predictions
calpd = PredictionDataset(predictions_csv=CALIB_DATA_CSV,
dataset_name='my_cal_data')
testpd = PredictionDataset(predictions_csv=TEST_DATA_CSV,
dataset_name='my_test_data')
# Get class counts and prediction heatmap
calpd.run_reports(OUTPUT_DIR)
# Validation trial and reports
mcp = FNRCoP(calpd, alpha=ALPHA)
trial = mcp.do_validation_trial(n_runs=10000)
trial.run_reports(OUTPUT_DIR)
# Recalibrate conformal predictor
mcp = FNRCoP(calpd, alpha=ALPHA)
mcp.calibrate()
# Predict
formatted_predictions = mcp.predict(testpd,
OUTPUT_DIR)
Metadata
Release files for conformist 1.1.1
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 |
|---|---|---|---|---|
| conformist-1.1.1.tar.gz | 21.5 kB | With provenance | Details for conformist-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conformist-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for conformist-1.1.1-py3-none-any.whl |
Total release size: 45.5 kB
Release files / conformist-1.1.1.tar.gz
| Download URL | conformist-1.1.1.tar.gz |
|---|---|
| Size | 21.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5beb160e75e2ee94ffcdf9b58e45270ade2d34318ead7707d63af9b8835ee305
|
|
BLAKE2b-256 checksum How to use checksums |
080d10af77e551537e0ad52f6dc91c8719d9e3631c8bde85f9049e24ff0be1cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 9, 2024.
Transparency logRelease files / conformist-1.1.1-py3-none-any.whl
| Download URL | conformist-1.1.1-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e81b2bebc8535e678527ec18823f4aa65608ce273c1406ca0ba149f94d09145d
|
|
BLAKE2b-256 checksum How to use checksums |
baf1792393964674a3ab00be563f241f025433c6b93821d2d231fe8d4a2a63f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 9, 2024.
Transparency logSecurity for conformist 1.1.1
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for conformist-1.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 9, 2024.
Transparency logA 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.