> This page is for Structured Data Models Client.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/sdgm/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/sdgm/_mcp/server.

# Prediction Explainability

> Request structured attribution for a Kumo Relational prediction

Ask for `'explanation'` as an output field to return structured attribution alongside a prediction. Explainability supports a single prediction entity per request.

> **Warning**
>
> **Whether this works depends on your deployment.** The client declares `explanation` as a Kumo Relational output, but the narrower, more commonly shipped relational NIM build refuses it on every task — the endpoint answers `422 UNSUPPORTED_OUTPUT`. It has been verified working against a different (broader) relational deployment. Send a representative `outputs=['prediction', 'explanation']` request against your own endpoint before depending on this.

> **Note**
>
> sdm-client does not generate a natural-language summary of an explanation. Where a deployment does produce one, `result.explanation` carries the structured payload only — cohorts and subgraph attribution — with no summarization step in this client. If you need prose, read and present the structured payload yourself.

## Request an explanation

```python
from sdm_client import PredictiveQuery, SDMClient, KumoRelational

query = PredictiveQuery(
    "PREDICT SUM(orders.amount, 0, 30, days) FOR EACH customers.customer_id",
    schema,
)
request = query.materialize(indices=[42])

with SDMClient(url="http://localhost:8000") as client:
    result = client.predict(
        request,
        model=KumoRelational(),
        outputs=["prediction", "explanation"],
    )

predictions = result.to_pandas()
explanation = result.explanation
```

Use a small `num_context_samples` for explanation requests — an explanation is produced only within the smaller context budget (1,000 rows). Materializing with a larger context and then asking for `'explanation'` is refused before anything is sent, naming the limit.

## Work with the result

`result.explanation` is the structured explanation payload the endpoint returned for the scored entity, when it produced one. Its shape depends on the deployment; treat it as opaque structured data unless your NIM's release notes describe its schema.

`result.to_pandas()` is unaffected by asking for an explanation — it is the same prediction DataFrame described in [Prediction Results](/sdgm/kumo-relational/user-guide/work-with-prediction-results/prediction-results).

## Troubleshoot explainability

* **`422 UNSUPPORTED_OUTPUT` or the field is simply absent from a successful result:** This deployment likely doesn't serve explanations for this task. Check `result.absent(["explanation"])`, and confirm with your platform team which relational build is deployed.
* **`UnsupportedRequestError` naming a context-row limit:** Re-materialize with `num_context_samples=1000` or fewer.
* **`UnsupportedRequestError` naming the entity count:** An explanation covers exactly one entity; request others without `'explanation'`, one at a time if you need explanations for each.
* **The Kumo Relational NIM is temporarily unavailable:** Wait and retry. Explanation requests are GPU intensive, so send them one at a time.

See [Understand Explanations](/sdgm/kumo-relational/user-guide/explain-predictions/understand-explanations) for interpretation guidance.