smartcal – Auto-Calibration for Machine Learning
smartcal is a modular and extensible Python package that provides automated, metric-driven calibration of classification models. It leverages meta-learning to recommend and tune the best calibrator from a rich suite of calibration algorithms. smartcal supports evaluation with popular calibration metrics.
Features
1. SmartCal Engine
- Meta-learning-powered recommendation of calibration methods based on dataset characteristics.
- Automated hyperparameter tuning via Bayesian Optimization.
- Provides a unified interface for fitting and applying the best calibrator using:
from smartcal import SmartCal # Initialize SmartCal with your preferred metric smartcal = SmartCal(metric='ECE') # Supports metrics: ECE, MCE, ConfECE, brier_score, log_loss # Step 1: Get top 3 recommended calibration methods recommended = smartcal.recommend_calibrators(y_true, predictions_prob, n=3) # Step 2: Fit and retrieve the best calibrator best_calibrator = smartcal.best_fitted_calibrator(y_true, predictions_prob, n_iter=20) # Step 3: Use the calibrator calibrated_probs = best_calibrator.predict(predictions_prob)
- Note: The maximum number of supported calibrators is 12, not 13. This is because we do not include the Probability Tree Calibrator in the default meta-calibration pipeline, as it operates differently by incorporating data features in addition to model outputs. However, you can still use it independently via the calibration_algorithms module.
2. Calibration Algorithms
- Supports diverse calibration methods, including:
- Parametric: Temperature Scaling, Platt, Vector, Matrix, Beta, Dirichlet, Adaptive TS
- Non-parametric: Isotonic, Histogram, Empirical Binning
- Hybrid: Meta Calibration, Mix-and-Match Calibration
- Each calibrator implements standard
.fit()and.predict() and metadataAPIs.
3. Calibration Metrics
- Built-in evaluation metrics to assess calibration quality:
- ECE – Expected Calibration Error
- MCE – Maximum Calibration Error
- ConfECE – Confidence-Binned ECE
- Brier Score – Proper scoring rule measuring accuracy of probabilistic predictions
- Calibration Curves – for visual inspection of reliability
Package Structure
├── calibration_algorithms/ # All calibration method implementations
├── metrics/ # Calibration evaluation metrics
├── config/ # Configuration enums and constants
├── meta_model/ # Meta-learning recommendation engine
├── meta_features_extraction/ # Meta-feature computation utilities
├── bayesian_optimization/ # Bayesian optimization computation utilities
├── utils/ # Helper functions and validation
├── smartcal/ # Core SmartCal meta-calibration engine
└── __init__.py
Supported Calibration Algorithms
- Empirical Binning
- Isotonic Regression
- Temperature Scaling
- Beta Calibration
- Dirichlet Calibration
- Platt Scaling
- Vector Scaling
- Matrix Scaling
- Adaptive Temperature Scaling
- Histogram Calibration
- Mix-and-Match Calibration
- Meta Calibration
- Probability tree Calibration
Each calibrator supports .fit() and .predict() with (n_samples, n_classes) formatted input.
Calibration Metrics
smartcal provides implementations for:
- ECE (Expected Calibration Error)
- MCE (Maximum Calibration Error)
- Confidence-ECE (for threshold-based confidence bins)
- Brier Score (proper scoring rule measuring accuracy of probabilistic predictions)
- Calibration Curve Plotting (for visualization)
Documentation & Usage
For full documentation and usage guidance, please refer to this colab notebook: smartcal.ipynb
Collaborators
This project is a collaborative effort developed with support from Giza Systems. We would like to acknowledge the following contributors:
Core Team
- Mohamed Maher - GitHub | PyPI | Email
- Mariam Elseedawy - GitHub | PyPI | Email
- Osama Fayez - GitHub | PyPI | Email
- Youssef Medhat - GitHub | PyPI | Email
- Yara Marei - GitHub | PyPI | Email
- Abdullah Ibrahim - GitHub | PyPI | Email
- Radwa ElShawi - Email
Citation
If you use SmartCal in your research or publication, please cite it as:
BibTeX:
@inproceedings{
abdelrahman2025smartcal,
title={SmartCal: A Novel Automated Approach to Classifier Probability Calibration},
author={Mohamed Maher Abdelrahman and Mariam Magdy Elseedawy and Osama Fayez Oun and Youssef Medhat and Yara Mostafa Marei and Abdullah Ibrahim and Radwa Mohamed El Shawi},
booktitle={AutoML 2025 Methods Track},
year={2025},
url={https://openreview.net/forum?id=XPtubBurd2}
}
License
MIT License. See LICENSE file for details.
Metadata
Release files for smartcal 0.1.16
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 |
|---|---|---|---|---|
| smartcal-0.1.16.tar.gz | 1.7 MB | Without provenance | Details for smartcal-0.1.16.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smartcal-0.1.16-py3-none-any.whl | Python 3 | none | any | Details for smartcal-0.1.16-py3-none-any.whl |
Total release size: 3.4 MB
Release files / smartcal-0.1.16.tar.gz
| Download URL | smartcal-0.1.16.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a92d336de38daa66a171ebf9b175d8c9842eb52bf067ab65f72472d45ad221d5
|
|
BLAKE2b-256 checksum How to use checksums |
ebb8a368aa9db49be6d0bf7bf4ca7cbaa7232879e7acef788999fb0d57d2d31b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / smartcal-0.1.16-py3-none-any.whl
| Download URL | smartcal-0.1.16-py3-none-any.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d8e4e2b3e78e30525b7a129c07a688fff79033f85a9b9c8aefc42f5ad03f4a9
|
|
BLAKE2b-256 checksum How to use checksums |
db9495a5371042cdf3f783be2646994548c22cf0995269f84ce2f953ed0c5833
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for smartcal 0.1.16
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.