Skip to main content

python License: MIT Static Badge GitHub Repo stars

Venn-ABERS calibration

This library contains the Python implementation of Venn-ABERS calibration for binary and multiclass classification problems.

Installation

pip install venn-abers

The method can be applied on top of an underlying scikit-learn algorithm.

Example Usage

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB

from venn_abers import VennAbersCalibrator

X, y = make_classification(n_samples=1000, n_classes=3, n_informative=10)
X_train, X_test, y_train, y_test = train_test_split(X, y)

clf = GaussianNB()

# Define Venn-ABERS calibrator
va = VennAbersCalibrator(estimator=clf, inductive=True, cal_size=0.2, random_state=101)

# Fit on the training set
va.fit(X_train, y_train)

# Generate probabilities and class predictions on the test set
p_prime = va.predict_proba(X_test)
y_pred = va.predict(X_test)

Scikit-Learn Compatibility

The venn-abers library is fully compatible natively with the scikit-learn ecosystem! It seamlessly inherits from BaseEstimator allowing it to be dropped directly into workflows like Pipeline, GridSearchCV, and cross_val_score.

Furthermore, this compatibility is 100% backwards-compatible with all previous implementations of the library, so no existing code will break.

You can also pass **kwargs directly into the .fit() method to route parameters dynamically to the underlying estimator (e.g. passing eval_set to XGBoost):

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from xgboost import XGBClassifier
from venn_abers import VennAbersCalibrator

# Passing kwargs through fit explicitly
va = VennAbersCalibrator(estimator=XGBClassifier(), inductive=True, cal_size=0.2)
va.fit(X_train, y_train, eval_set=[(X_val, y_val)], early_stopping_rounds=10)

# Scikit-learn Pipeline Integration
pipeline = Pipeline([
    ('scaler', StandardScaler()),
    ('va', VennAbersCalibrator(estimator=GaussianNB(), inductive=True, cal_size=0.2))
])
pipeline.fit(X_train, y_train)
p_prime_pipeline = pipeline.predict_proba(X_test)

Examples

Further examples can be found in the github repository https://github.com/ip200/venn-abers in the examples folder:

Academic Usage

The venn-abers library has been used or referenced in several academic works related to probability calibration, uncertainty estimation, and conformal prediction.

Papers Referencing This Repository


Research Using Venn‑Abers Calibration

These papers apply Venn‑Abers, IVAP, or CVAP calibration methods.

For a more comprehensive list please see Google Scholar



Foundational Research


Citation

If you use this library in academic work, please cite:

@software{petej_venn_abers,
  author = {Petej, Ivan},
  title = {venn-abers: Venn-Abers calibration for probabilistic classifiers},
  year = {2024},
  url = {https://github.com/ip200/venn-abers}
}

You may also cite the foundational paper:

@inproceedings{vovk2014venn,
  title={Venn-Abers predictors},
  author={Vovk, Vladimir and Petej, Ivan},
  booktitle={Proceedings of the Thirtieth Conference on Uncertainty in Artificial Intelligence},
  pages={829--838},
  year={2014}
}

Contributing

Contributions and pull requests are welcome.
If you are aware of additional research using this library, please open a PR to add it to the Academic Usage section.


License

MIT License

Release files for venn-abers 1.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for venn-abers 1.5.4
File Size Uploaded
venn_abers-1.5.4.tar.gz 20.8 kB Details

Release files / venn_abers-1.5.4.tar.gz

Download URL venn_abers-1.5.4.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a6bf5383e618ce42d0ecb2335bba0d6b104ecbe979041f10019b57572364bc69
BLAKE2b-256 checksum
How to use checksums
cb303988e57974170121201bf1e21815c9ee30e605d0661369a9fad7aa732165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

1.5.4 This release

1 release file

1.5.3

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.7

1 release file

1.4.6

1 release file

1.4.5

1 release file

1.4.4

1 release file

1.4.3

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page