Skip to main content
Glama
florenciakabas

xai-toolkit

explain_prediction

Understand why a machine learning model made a specific prediction by revealing which features influenced the classification, supported by SHAP values and optional visualizations.

Instructions

Explain why a single sample received its classification.

Returns a plain-English narrative explaining which features drove
the model's prediction for the given sample, backed by SHAP values.
Optionally includes a SHAP bar chart (tornado plot) visualization.

Checks the result store first for precomputed explanations.
Falls back to on-the-fly SHAP computation if not found.

Args:
    model_id: ID of a registered model (e.g., "gbc_lubricant_quality").
    sample_index: Row index in the test dataset to explain (0-based).
    include_plot: If True, include a SHAP bar chart as base64 PNG (default: True).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
model_idYes
sample_indexYes
include_plotNo
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden and discloses key behavioral traits: it explains the prediction process (using SHAP values), includes fallback behavior (checks result store first, then computes on-the-fly), and mentions optional outputs (base64 PNG chart). However, it lacks details on permissions, rate limits, or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. Each sentence adds value: the first states the goal, the second details the output, and the third explains the computation process. Minor verbosity in the args section could be trimmed, but overall it's efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is moderately complete for a 3-parameter tool. It covers purpose, parameters, and behavioral aspects but lacks details on return values (e.g., narrative structure), error cases, or performance implications. For a tool with computational fallback, more context on limitations would help.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining each parameter's role: 'model_id' identifies a registered model, 'sample_index' is a row index in the test dataset, and 'include_plot' controls visualization output. This clarifies semantics beyond the bare schema, though it could specify format constraints (e.g., model_id examples).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('explain why', 'returns a plain-English narrative') and resources ('a single sample', 'classification', 'features', 'SHAP values'), distinguishing it from siblings like 'explain_prediction_waterfall' by focusing on narrative explanations with optional visualizations rather than waterfall plots.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning it explains 'a single sample' and checks for 'precomputed explanations', but it does not explicitly state when to use this tool versus alternatives like 'explain_prediction_waterfall' or 'get_xai_methodology'. No exclusions or prerequisites are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/florenciakabas/xai-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server