Set icon
If icon
Download icon
Queries icon
Loop icon
Query icon
Script icon
Fail icon
UploadFiles icon
Pause icon
OutputValues icon
Request icon
Switch icon
Log icon
PurgeCurrentExecutionFiles icon
Schedule icon

Gate a classification model on subgroup error rates before it ships

Audit a classifier per subgroup in Kestra. DuckDB counts errors per group, Python tests the gaps, a reviewer signs off exceptions, the flow gates the deploy.

Categories
AIData

A model can look accurate overall and still make far more mistakes for one group. This flow is a release gate: a training pipeline calls it as a subflow with its scored data, and gets back approved, the decision, the report and the model_ref to deploy. It also runs standalone, by default on ProPublica's COMPAS risk scores.

How it works

  1. mark_pending sets the KV decision to PENDING, so a broken or killed run never leaves an old approval.
  2. The data comes from predictions_file (an upstream task's CSV, Parquet or JSON) or predictions_url. DuckDB keeps the attributes, outcome and prediction (SQL in variables).
  3. per_attribute (Loop) counts errors per group; race+sex audits intersections.
  4. audit (Python) compares every pair of groups on the chosen criterion (equalized odds, equal opportunity or predictive parity) with Fisher's exact test, Holm-corrected, reports impact ratios and the trend against past audits. fairlearn_cross_check recomputes every rate with Fairlearn.
  5. On WARN or FAIL, await_review pauses for a reviewer to approve an exception or reject, with a written reason.
  6. The decision goes to KV, to an MLflow model version tag and to an alert webhook; afterExecution purges the source data.

What you get

  • Flow outputs: approved, decision, model_ref, summary, results, report_markdown.
  • fairness/<model_name>/fairness_report.md and KV model_<model_name>_fairness with reviewer and justification.

Who it's for

  • ML engineers releasing classifiers, and risk teams signing them off (EU AI Act, NYC LL144).

Why orchestrate this with Kestra

  • Statistics, sign-off, registry tag and cleanup in one audited execution between training and deployment.

Prerequisites

  • A Docker-capable worker. Executors choose the data URL and inputs; editors control the SQL, so limit edit rights (Kestra OSS has no RBAC).
  • The source may hold personal data. Until the purge it is readable by anyone with access to the execution.

Secrets

  • None for the public default. Use {{ secret('NAME') }} for a private source or an MLflow token.

Quick start

  1. Click Execute: COMPAS is blocked on race (FPR 42.3% African-American vs 22.0% Caucasian) and pauses for review. Resume with a decision.
  2. In a pipeline, call it with predictions_file, model_ref and fail_on_block: false, then deploy on outputs.<task>.outputs.approved.

How to extend

  • Add attributes, swap the alert for an issue tracker, or point variables at your columns.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.