driftless 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
driftless/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """driftless: Dependabot for LLM models."""
2
+
3
+ __version__ = "0.1.0"
driftless/calibrate.py ADDED
@@ -0,0 +1,33 @@
1
+ """Baseline-derived threshold suggestions (the educational half of P2.2).
2
+
3
+ A first-time user can't guess reasonable ``min_f1`` / ``max_schema_error_rate``
4
+ values. ``suggest_thresholds`` turns measured baseline metrics into a starting
5
+ ``thresholds:`` block (achieved metric minus a safety margin), which the user can
6
+ accept or edit. Pure and reused by the ``calibrate`` CLI command.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from .evaluation import Metrics
12
+
13
+ DEFAULT_MARGIN = 0.03
14
+
15
+
16
+ def suggest_thresholds(metrics: Metrics, *, margin: float = DEFAULT_MARGIN) -> dict:
17
+ """Suggested absolute thresholds grounded in measured baseline metrics.
18
+
19
+ Only emits a key when the underlying metric was actually measured, so we
20
+ never invent a bar for something we couldn't evaluate.
21
+ """
22
+ out: dict[str, float] = {}
23
+ if metrics.f1 is not None:
24
+ out["min_f1"] = round(max(0.0, metrics.f1 - margin), 3)
25
+ if metrics.score is not None:
26
+ out["min_score"] = round(max(0.0, metrics.score - margin), 3)
27
+ if metrics.precision is not None:
28
+ out["min_precision"] = round(max(0.0, metrics.precision - margin), 3)
29
+ if metrics.recall is not None:
30
+ out["min_recall"] = round(max(0.0, metrics.recall - margin), 3)
31
+ if metrics.schema_error_rate is not None:
32
+ out["max_schema_error_rate"] = round(min(1.0, metrics.schema_error_rate + margin), 3)
33
+ return out