Prediction Results for Kumo Relational
For a Kumo Relational prediction, client.predict() returns a PredictionResult, never a bare DataFrame. to_pandas() gives you the DataFrame. The following example prints the columns and the first rows of the DataFrame.
Result Fields
The fields that are present depend on the prediction task and the requested outputs.
Do not assume that every task returns every field or one row per input entity. Binary and multiclass classification return one row per entity, and forecasting returns one row per forecast timeframe. A RANK TOP K query returns one row per entity with prediction/rankings holding the candidates as a list. Three entities ranked TOP 3 come back as three rows, not nine. Inspect the DataFrame columns or client.capabilities(model) before processing optional outputs.
A Ranking Can Hold Fewer Than K Candidates
A ranking asks one yes-or-no question per candidate: will this entity link to it in the window? If no entity in a candidate’s sampled context linked to it, that question has only one answer in context, and the endpoint refuses it. The client leaves that candidate out rather than failing the whole ranking: it gets no score and appears in no row’s prediction or rankings. The following example reads the candidates that the client left out.
Every entity in the ranking shares a candidate’s context, so a candidate left out for one entity is left out for all, and result.unscored_candidates lists them in the order you passed them. The client emits one warning that names the candidates it left out. If every candidate is left out, there is nothing to rank and predict() raises UnsupportedRequestError before sending anything.
A larger num_context_samples can reach entities that did link to a candidate. On sparse data (a catalog where most products sell rarely), it often cannot.
Recommended Pattern: Rank Over a Table of Pairs
When you can provide a table with one row per (entity, candidate) pair, ask one classification over the pairs instead of a RANK TOP K ranking. Each pair is scored from the features of its entity and its candidate, and the context pools every pair, so a candidate nobody linked to recently is still scored. The pairs are scored with one classification request, batched if needed, rather than one call per candidate. The following example builds the pairs schema and scores one customer’s candidates with a single classification request.
The events table needs a pair_id column linking each event to its pair. The pairs table should hold the pairs you want scored, plus enough others (some that converted, some that did not) for the context to learn from.
What a Regression Reports
The relational model predicts a distribution for a regression, and prediction is its median by default, matching what the engine returns. Pass materialize(..., prediction_statistic="mean") for the mean instead. The NIM averages the model’s predicted quantiles to compute the mean, which trims the tails.
Choose "mean" when you sum predictions across entities, such as total demand across products. Means add up and medians do not, so on a right-skewed target the sum of the medians understates the total. Neither statistic is pinned to a floor of 0 on a zero-inflated target, because predicted quantiles are not clipped to the target’s range.
A regression on the tabular model always reports the mean and does not take prediction_statistic.
Joining
Every row carries row_index. It also carries id when the model has an entity key.
Join on id when it is present, otherwise on row_index. Never on row order. The endpoint is not required to return rows in the order they were sent, and a request split across several calls does not preserve it either.
Checking Whether a Requested Field Arrived
The following example requests two output fields and then checks which requested fields are absent from the result.
A particular deployment can still refuse a field that the client declares for a model. Refer to Prediction Types. sdm-client warns when a field you asked for by name is absent from the answer.
Explanations
On a compatible client and deployment, EXPLAIN or the explanation output requests per-entity gradients and labeled-context cohorts in result.explanations.
result.to_pandas() is unaffected. Refer to Prediction Explainability.