Trained models and endpoints

Some questions are better answered by a model trained on your own history than by a rule or a language model: which flights are likely to leave late, how many hours a check will take, what each shop will sell over the next two weeks. A trained model is defined next to the ontology, trained with SQL over lake tables, registered in MLflow with its metrics and lineage, and promoted only when it passes a gate. It then scores rows or objects on request, or whole tables in a pipeline, and is called as a typed function from functions, AI functions and agents, with the caller's access and a log of every prediction. Live accuracy against real outcomes decides when it is trained again

MLflowTracking, datasets and the model registry
GatedChampion only when held-out metrics pass
Your accessObject keys looked up with the caller's access labels and policies
WatchedEvery prediction logged, with drift and live accuracy against outcomes

In the platform today

Built
  • Training, registration, gated aliases, lineage, the prediction endpoint, batch scoring, the pipeline score step, the prediction log and drift run in the platform service with tests
  • A model's kind is classifier (binary, the default), regression or forecast
  • A deployed alias is a typed function: GET /api/v2/models/{name}/signature, POST /api/v2/models/{name}:call, ctx.predict(model, rows, alias=…) in Python functions, the predict step of AI functions and a predict_<model> tool for agents given models: […]
  • outcomes: gives live accuracy per version and slice at GET /{name}/accuracy, retrain: lets the model monitor retrain on a schedule, on drift or on falling accuracy, and reviews: adds named sign-offs that promotion waits for
  • The Trained models screen in AI works against the service
In the demo
  • The demo models are illustrative, trained on synthetic data
On request
  • Multiclass models and traffic splitting between versions
Requirements
  • A group in the model's access.manage to train, promote and score; a group in access.predict to call the endpoint
  • Every access label the model inherits: those of the object types its training tables back, and of its own object type
  • The ops grant in the SQL workspace, or managing the model, to read its prediction log and drift
  • Membership of a review check's approvers groups, or administrator, to sign that check

A model definition

Models are defined in ontology.yaml under models:. The training set is one SQL statement over lake tables. The features are a second SQL statement over a relation called input, so the same features come out of the training set, rows sent to the endpoint, objects looked up for the caller, and batch scoring

models:
  late-departure:
    name: Late departure risk
    # flights can be scored by key; the type's access label applies
    objectType: flight
    access: { manage: [maintenance-control, planning], predict: ['*'] }
    training:
      inputs: [gold.flights]
      sql: select *, delayMinutes >= 15 as late from gold.flights where status = 'Arrived'
      label: late
      testFraction: 0.3
      seed: 7
    features:
      key: flightId
      sql: |
        select flightId, origin, aircraftType,
               hour(scheduledDeparture) as departureHour, loadFactor
        from input
      categorical: [origin, aircraftType]
      numeric: [departureHour, loadFactor]
    # or random_forest, gradient_boosting
    estimator: { kind: logistic_regression, params: { C: 0.5 } }
    threshold: 0.35
    gate: { roc_auc: { min: 0.55 }, beatChampion: roc_auc }
    gatedAliases: [champion]
    afterTraining: challenger
    serving: { alias: champion }
    scoring:
      inputs: [gold.flights]
      sql: select * from gold.flights where status in ('Scheduled', 'Delayed')
      output: gold.flight_delay_risk

Classifiers, regression and forecasts

kind on a model picks what it predicts. All three share the training SQL, the gate, aliases, lineage, the prediction log and batch scoring

KindPredictsEstimatorsVersion metrics
classifier (default)A score and a label per row, against thresholdlogistic_regression, random_forest, gradient_boostingAccuracy, precision, recall, F1, log loss, Brier score, ROC AUC
regressionA value per row, from a numeric labelridge (default), random_forest, gradient_boostingMAE, RMSE, R², MAPE and bias, against a mean baseline
forecastP10, P50 and P90 per series and period, over the horizonSeasonal naive, exponential smoothing and gradient boosting with quantile loss, backtested; the best one is fittedThe winner's backtest scores: WAPE, MASE, sMAPE, MAE, RMSE, bias, pinball loss and P10 to P90 coverage

Forecast models

A forecast model reads one row per series and period. forecast: names the time column, the target, the series columns, inputs known ahead (holidays, promotions, prices), inputs known only up to now, static attributes per series, the horizon, the frequency (H, D, W or M, inferred when left out) and how gaps are filled (zero, previous or interpolate). From a Maritime ice cream maker's daily sales by shop

models:
  shop-sales:
    kind: forecast
    name: Daily sales by shop
    access: { manage: [operations, shop-managers], predict: ['*'] }
    training:
      inputs: [gold.shop_days]
      sql: select shopId, date, sales, isHoliday from gold.shop_days
    forecast:
      time: date
      target: sales
      series: shopId
      frequency: D
      horizon: 14
      gapFill: zero                         # no row means nothing sold
      knownFuture: [isHoliday]               # also pastOnly: [...] and static: [...]
      backtest: { folds: 3, metric: wape }
      future:
        inputs: [gold.shop_calendar]
        sql: select shopId, date, isHoliday from gold.shop_calendar
    gate: { wape: { max: 0.4 }, beatChampion: wape }
    scoring: { output: gold.shop_sales_forecast }

Each candidate is backtested on a rolling origin, up to folds origins one horizon apart, and the one with the lowest mean of the chosen metric across folds is fitted on the whole history. Everything is deterministic for a given seed. A forecast always starts from the latest history, and the horizon cannot pass the trained one. A forecast run, :score or a pipeline step of kind score, writes one row per series and period keyed by forecastId, with step, p10, p50 and p90

Train and register

POST /api/v2/models/late-departure:train

Training splits the set with the given test fraction and seed, fits the estimator, and logs to MLflow: the parameters, held-out metrics, a signature, the training set as an MLflow dataset input and a reference profile of every feature. It then registers a new version in the MLflow model registry. For a classifier, held-out metrics are accuracy, precision, recall, F1, log loss, Brier score and, when both classes are present, ROC AUC; regression and forecast metrics are in the table above. Each version records the Delta Lake version of every training table, and the edges from training tables to the model and from the model to its scoring output are written to ops.lineage_edges, so the catalogue shows them

Tracking and the registry live in SQLite under the lake, at <lake>/_mlflow, or on an MLflow server named in the service settings

Aliases and the gate

Aliases are the stages. A new version takes the afterTraining alias, challenger by default. Moving a gated alias, champion by default, requires the version's held-out metrics to pass the gate, and with beatChampion to beat the version that holds the alias now on that metric. A refused promotion names the failing conditions

POST /api/v2/models/late-departure:promote
{ "version": 4, "alias": "champion",
  "note": "Passes the gate and beats version 3 on ROC AUC" }

Every alias move, removal or refusal is a row in ops.ml_alias_events and an event in the audit log. The endpoint serves the alias named in serving unless a request names an alias or a version

Predictions

POST /api/v2/models/late-departure:predict
{ "objects": ["MKA214-20261024", "MKA223-20261024"] }
{
  "model": "late-departure", "version": 4, "alias": "champion", "threshold": 0.35,
  "data": [
    { "key": "MKA214-20261024", "score": 0.412, "label": true },
    { "key": "MKA223-20261024", "score": 0.188, "label": false }
  ],
  "missing": [], "ms": 21.4
}

A request sends either rows, with the feature inputs, or objects, keys of the model's object type, up to 1,000 per request. Keys are looked up through the object store as the caller, with their access labels, row policy and hidden properties. A key the caller cannot see is reported as missing, and a feature that needs a property hidden from the caller refuses the request. A model is visible and callable only to people who hold the access labels it inherits

Batch scoring

POST /api/v2/models/{name}:score runs the definition's scoring SQL and writes the scores to its output table with the model and version. The same works as a pipeline step, so scores are rebuilt with the data and checked by the step's expectations

- output: gold.flight_delay_risk
  kind: score
  model: late-departure
  alias: champion                 # or version: 3
  inputs: [gold.flights]
  sql: select * from gold.flights where status in ('Scheduled', 'Delayed')

Models as typed functions

A deployed alias is a function with a signature. GET /api/v2/models/{name}/signature returns its input columns, with types and which are required, and its output: a score and label, a value, or a forecast per period. The inputs are declared under inputs:, or recorded at training as the training-set columns the feature SQL reads. Every caller goes through the same check: a missing or mistyped required column refuses the call with INPUT_COLUMNS, unknown columns are dropped and listed under ignored, and every prediction is logged with who asked

FromCall
The APIPOST /api/v2/models/{name}:call with rows or objects, and optionally alias, version or, for a forecast, horizon
Python functionsctx.predict('late-departure', rows, alias='champion'), as the caller; see functions
AI functionsA predict step with model, optional alias or version, and one of row, rows or objects; see AI functions
Agentsmodels: [late-departure] on an agent or team member gives it a predict_late-departure tool with the input columns in its schema; see tools and guardrails

A forecast model takes series ids in its rows, or none for every series, and an optional horizon up to the trained one

Monitoring

Every prediction is a row in ops.model_predictions with a hash of the inputs, the inputs and output, the model version and the latency. GET /api/v2/models/{name}/drift compares recent prediction inputs, 7 days by default, with the training profile of the version in use, feature by feature, using the population stability index. Numeric features are compared in the training deciles, categorical features by category, with categories never seen in training listed

StatusWhen
StableIndex below 0.1
Shifted0.1 to 0.25
Drifted0.25 or more
Not enough dataFewer recent predictions than minRows, 30 by default

Live accuracy

outcomes: names where the real outcome lands. GET /api/v2/models/{name}/accuracy joins the prediction log to those rows, the latest prediction per version and key inside the window, and scores each version and each value of the slices columns. Predictions whose outcome has not landed are counted as waiting. A classifier reports accuracy, precision, recall, ROC AUC, Brier score and rates; a regression model MAE, RMSE, MAPE, bias and R²; a forecast WAPE, MAE, RMSE, bias, sMAPE, pinball loss and P10 to P90 coverage, matched by series and period

    outcomes: { table: gold.flights, key: flightId, column: late,
                slices: [origin], window: 30d }

Retraining

retrain: hands the model to the model monitor, a timer that runs every 300 seconds by default, a service setting. Each pass stores a live accuracy snapshot in ops.ml_accuracy, at most once per snapshotEvery (a day by default), then checks the triggers

    retrain:
      every: 7d                                  # since the last retraining
      whenDrift: Drifted                         # or Shifted
      whenAccuracy: { metric: roc_auc, min: 0.6 }   # or max: for an error metric
      minOutcomes: 50                           # before accuracy counts
      cooldown: 1d                               # after the monitor's own last retraining
      promote: champion
      runAs: ops.lead                            # a person who manages the model

When a trigger fires, the model is trained again as runAs, or as a service identity with the model's manage groups. With promote, the new version is then offered to that alias, and the gate and review checks decide; a refusal is recorded, not an error. Every pass that finds a trigger is a row in ops.ml_monitor_events and an audit event. POST /api/v2/models/{name}:monitor runs one model's pass now ({"dryRun": true} only reports the triggers)

Review checks

reviews: adds named sign-offs per version, each held by approver groups. A decision is pass, fail with a note, or pending, and the latest decision per check wins. Moving a version to an alias in requiredFor needs every check of that version passed, otherwise the promotion is refused with REVIEWS_INCOMPLETE and the refusal recorded. Decisions are rows in ops.ml_reviews and audit events

    reviews:
      checks:
        - { id: data, name: Training data reviewed, approvers: [data-platform] }
        - { id: operations, name: Operations sign-off, approvers: [maintenance-control] }
      requiredFor: [champion]
POST /api/v2/models/late-departure:review
{ "version": 5, "check": "operations", "status": "pass",
  "note": "Matches the spring schedule" }

API

EndpointDoes
GET /api/v2/models, /{name}Models the caller can see, and one with its aliases and gate
GET …/{name}/versions, /versions/{v}Registered versions with metrics, parameters and training table versions
GET …/{name}/aliases, /lineageAlias history, and lineage
GET …/{name}/predictions, /driftThe prediction log, and drift per feature
GET …/{name}/signatureInput columns and output of a deployed alias or version
GET …/{name}/accuracy, /monitorLive accuracy per version and slice, and the monitor's state and recent events
GET …/{name}/versions/{v}/reviewsReview checks of a version with their decisions
POST …/{name}:reviewSign a review check: pass, fail or pending
POST …/{name}:monitorRun the monitor for one model
POST …/{name}:train, :promote, :removeAlias, :scoreLifecycle, for managers
POST …/{name}:predict, :callScores rows or object keys; :call checks rows against the signature first

Limitations

  • Classifiers are binary; multiclass models are delivered on request
  • Forecasts take numeric known and past inputs, up to 5,000 series, with no hierarchical reconciliation; the two simple candidates use no inputs
  • One alias serves all traffic; there is no traffic split or shadow scoring between versions
  • Review checks are signed by their approver groups; separation of duties from the person who trained the version is delivered on request
  • At most 1,000 rows or keys per prediction request; larger sets use batch scoring
  • The Trained models screen, with versions, gates, predictions, drift, accuracy, reviews and the language model catalogue, is in AI, in the Markham Aviation workspace of the demo app connected to the service

Related