Skip to main content

A modular and extensible Python microframework for evaluating and calibrating probabilistic classifiers with standardized metrics, visualization tools, and reusable validation strategies.

Project description

Below is the complete README.md rewritten in professional English, strictly without emojis or informalities, and aligned with engineering and academic standards.


# Calimetrics

**Calimetrics** is a modular microframework for calibration, evaluation, and diagnostic analysis of probabilistic classifiers. It is designed to support auditable, reproducible, and production-grade model validation workflows.

## Overview

In modern machine learning systems, probabilistic classifiers are frequently used in critical decision-making contexts. However, poorly calibrated probability estimates can lead to significant risk and suboptimal outcomes. **Calimetrics** provides a principled interface to address this issue, offering:

- Post-hoc calibration using frozen base estimators and `CalibratedClassifierCV`
- Support for various cross-validation strategies (`KFold`, `StratifiedKFold`, `GroupKFold`)
- Custom metrics such as Brier Score, Log Loss, Expected Calibration Error (ECE), Maximum Calibration Error (MCE), Sensitivity, Specificity, F1-Score, and Matthews Correlation Coefficient (MCC)
- Metric exporting for auditing and reporting
- Comparative calibration curve plotting
- Optional logging for traceability of evaluation configuration

All components are compatible with `scikit-learn` estimators and can be easily integrated into existing pipelines.

## Project Structure

calimetrics/ │ ├── calibration/ # Calibration logic and plotting │ ├── calibrator.py │ └── ploter.py │ ├── evaluation/ # Evaluation execution and custom scorers │ ├── evaluator.py │ └── scorer.py │ ├── utils/ # Metric implementations and utilities │ └── metrics.py │ ├── tests/ # Unit and integration tests │ ├── notebooks/ # Interactive examples and demonstrations │ ├── pyproject.toml # Build and dependency configuration └── README.md # Project documentation


## Features

- Calibration using frozen estimators to prevent retraining during the calibration process
- Seamless integration with `cross_validate()` and other `scikit-learn` workflows
- Configurable and extensible scoring interface supporting multiple metrics
- Export of results to structured JSON files for reproducibility
- Visualization of multiple calibration curves for comparative analysis
- Logging infrastructure to support experiment tracking and auditability

## Installation

To install the package in development mode:

```bash
git clone https://github.com/your-org/calimetrics.git
cd calimetrics
pip install -e .

Usage Example

Calibration

from calimetrics.calibration.calibrator import Calibrator
from sklearn.linear_model import LogisticRegression

model = LogisticRegression().fit(X_train, y_train)
calibrator = Calibrator(model=model, method="isotonic", cv=5)
calibrator.fit(X_train, y_train)
probs = calibrator.predict_proba(X_test)

Evaluation

from calimetrics.evaluation.evaluator import run_model_validation
from calimetrics.evaluation.scorer import Scorer
from sklearn.model_selection import StratifiedKFold

scorer = Scorer(n_bins=10)
cv_strategy = StratifiedKFold(n_splits=5)
results = run_model_validation(model, X, y, scorer, cv=cv_strategy)

Exporting Results

from calimetrics.evaluation.evaluator import export_results_to_json

export_results_to_json(results, "metrics_output.json")

Plotting Calibration Curves

from calimetrics.calibration.ploter import CalibrationPlotter

plotter = CalibrationPlotter(n_bins=10)
plotter.compare({"Model A": model_a, "Model B": model_b}, X_val, y_val)

Testing (to-do)

To execute the full test suite:

pytest tests/

License

This project is released under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome. Please adhere to clean code principles, write modular and well-tested code, and document all public interfaces. Open issues and submit pull requests via GitHub.


Se desejar, posso também criar o `LICENSE`, `CONTRIBUTING.md`, ou o esqueleto de um `setup.cfg` ou `setup.py` adicionalmente. Deseja isso?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

calimetrics-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calimetrics-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file calimetrics-0.1.0.tar.gz.

File metadata

  • Download URL: calimetrics-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for calimetrics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7b3a310c2eb159c921366a489fcfc9cc98d844877bea221694ddb6d73c4d58f
MD5 21cba05d223db08c9dbd9ef2da98ce52
BLAKE2b-256 2e0d933e85cef9d25295d68c3f3ec34018ed59b2cd6f110193e5c31fef9ac70a

See more details on using hashes here.

File details

Details for the file calimetrics-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: calimetrics-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for calimetrics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a342172049f7b8c97b21ae4d21b8e7b821ffc1a1246fa6c418bbd1456f1c5d2
MD5 56fb739f240750f0adb0ef3bb3bc39a3
BLAKE2b-256 2b0aa8fb8071d9d7bb91c7a0a0607f4cd4884bbe9a00cd8e84c8a5499ed4330d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page