> For the complete documentation index, see [llms.txt](https://docs.algenta.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.algenta.ai/machine-learning/ml-calibration.md).

# Probability calibration

Isotonic (PAV) and z-score affine calibration with reliability diagnostics for turning raw model scores into trustworthy probabilities.

`calibration` maps raw model scores to trustworthy probabilities or magnitudes. A model can rank well and still be badly calibrated — betting sizes, thresholds, and expected-value math all need calibrated outputs.

## Functions

| Function                                                                | What it does                                                                                                                                                                                                         |
| ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `isotonic_fit(x, y)` / `isotonic_transform(...)`                        | Isotonic regression via Pool Adjacent Violators (weighted tie handling, sklearn-equivalent). Monotonic, non-parametric — the standard for calibrating regression outputs and probabilities without assuming a shape. |
| `platt_fit(scores, labels, max_iter)` / `platt_transform(a, b, scores)` | Platt scaling: logistic calibration with Platt's target smoothing — best when the miscalibration is sigmoidal and data is scarce.                                                                                    |
| `calibration_curve(probs, labels, n_bins)`                              | Reliability diagram data: per-bin predicted vs observed frequency and counts. Pair with the ECE/Brier metrics in `ml_metrics_extended`.                                                                              |

## Choosing isotonic vs Platt

Isotonic fits any monotone distortion but needs more data (it can overfit below \~1k samples). Platt is two parameters — robust when small. When in doubt, compare both on a held-out reliability curve.

## Verification

Verified against sklearn's isotonic regression, including weighted-tie pooling cases that break naive PAV implementations.

**Next:** promote what you trained with [statistical model comparison](/machine-learning/ml-model-comparison.md), or browse the [engine catalog](/engine-runtime/catalog.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.algenta.ai/machine-learning/ml-calibration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
