/datarobot-agent-skills:datarobot-model-explainabilityfrom datarobot-agent-skills
Guides DataRobot model explainability with SHAP values, feature impact, anomaly assessment, and diagnostics. Use when interpreting model predictions.
Ships in datarobot-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill covers SHAP insights, XEMP prediction explanations, anomaly explanations, and model diagnostics.
SDK version: Use
datarobot>=3.6.0for the full API set in this skill (ShapDistributionswas added in 3.6;ShapMatrix,ShapImpact, andShapPrevieware available indatarobot>=3.4.0). Usefrom datarobot.insights import ShapMatrix, ...withentity_id=model_id— not legacydatarobot.models.ShapMatrix(project_id/dataset_id).ShapMatrix,ShapImpact,ShapPreview, andShapDistributionsare the canonical SHAP API. The olderdr.PredictionExplanations(XEMP-based) remains available but is the secondary path.
| Goal | API to use | Prerequisites |
|---|---|---|
| SHAP values for all features, all rows | ShapMatrix.create(entity_id=model_id) | None - universal SHAP |
| Per-row top-feature explanations | ShapPreview.create(entity_id=model_id) | None |
| Aggregated feature importance via SHAP | ShapImpact.create(entity_id=model_id) | None |
| SHAP value distributions across features | ShapDistributions.create(entity_id=model_id) | None |
| SHAP for a filtered segment | dr.DataSlice.create(...) + ShapMatrix.create(..., data_slice_id=...) | Data slice definition |
| XEMP-based prediction explanations | dr.PredictionExplanations.create(...) | Feature Impact; PE initialization; dataset uploaded |
| Anomaly explanations (time series) | AnomalyAssessmentRecord.compute(project_id, model_id, ...) | Anomaly model |
| ROC / lift / confusion (insights) | RocCurve.create(...) / LiftChart.create(...) / ConfusionMatrix.create(...) | Validation data |
| ROC / lift / confusion (Model helpers) | model.get_roc_curve() / model.get_lift_chart() / model.get_confusion_chart() | Validation data |
Universal SHAP is the preferred path - no dataset pre-upload or Feature Impact step required.
Use this skill when you need to explain leaderboard model behavior, compute SHAP insights, use XEMP prediction explanations, analyze anomaly explanations, or retrieve model diagnostics.
ShapMatrix, ShapPreview, ShapImpact, and ShapDistributionsdr.DataSlicedr.PredictionExplanations when specifically requiredimport datarobot as dr
from datarobot.insights import ShapMatrix, ShapImpact, ShapPreview, ShapDistributions
dr.Client()
datarobot.insightsimport pandas as pd
from datarobot.insights import ShapMatrix, ShapImpact, ShapPreview, ShapDistributions
model_id = "YOUR_MODEL_ID"
matrix = ShapMatrix.create(entity_id=model_id)
df = pd.DataFrame(matrix.matrix, columns=matrix.columns)
impact = ShapImpact.create(entity_id=model_id)
preview = ShapPreview.create(entity_id=model_id)
distributions = ShapDistributions.create(entity_id=model_id)
Use ShapMatrix for full row-by-feature SHAP values, ShapPreview for compact top-driver rows,
ShapImpact for aggregated SHAP importance, and ShapDistributions for per-feature SHAP
distributions. Use source="externalTestSet" plus external_dataset_id for external datasets.
See references/shap_api_reference.md for parameters, exports, and limitations.
Use dr.PredictionExplanations when XEMP explanations are specifically required (e.g., certain
regulatory contexts, or when SHAP is unavailable for the model type).
Prerequisites (all required before calling .create()):
model.request_feature_impact() and waitdr.PredictionExplanationsInitialization.create(...)import datarobot as dr
model = dr.Model.get(project=project_id, model_id=model_id)
model.request_feature_impact().wait_for_completion()
dr.PredictionExplanationsInitialization.create(project_id=project_id, model_id=model_id)
dataset = dr.Dataset.upload("./data/scoring_data.csv")
pe_job = dr.PredictionExplanations.create(
project_id=project_id,
model_id=model_id,
dataset_id=dataset.id,
max_explanations=5, # top N features per row, up to 50
threshold_high=0.5, # only explain rows with prediction >= threshold
threshold_low=0.1, # only explain rows with prediction <= threshold
)
pe_obj = pe_job.get_result_when_complete()
Use pe_obj.get_rows(), pe_obj.get_all_as_dataframe(), or pe_obj.download_to_csv(...) to
retrieve results. For parameters, multiclass modes, and exposure-adjusted predictions, see
references/xemp_pe_reference.md.
Use dr.DataSlice when the user asks to explain model behavior for a segment, such as a
region, product line, target class, or high-risk cohort. Pass the resulting data_slice_id into
the datarobot.insights SHAP APIs.
import datarobot as dr
from datarobot.insights import ShapMatrix
data_slice = dr.DataSlice.create(
name="high_income_customers",
filters=[{"operand": "income", "operator": ">", "values": 100000}],
project=project_id,
)
shap_matrix = ShapMatrix.create(
entity_id=model_id,
source="validation",
data_slice_id=data_slice.id,
)
For time series anomaly detection models, use AnomalyAssessmentRecord.
from datarobot.models.anomaly_assessment import AnomalyAssessmentRecord
record = AnomalyAssessmentRecord.compute(
project_id=project_id,
model_id=model_id,
backtest=0, # backtest index (int) or "holdout"
source="validation", # "training" or "validation" only
series_id=None, # required for multiseries projects
)
records = AnomalyAssessmentRecord.list(project_id=project_id, model_id=model_id)
latest = record.get_latest_explanations()
regions = record.get_predictions_preview().find_anomalous_regions()
explanations = record.get_explanations_data_in_regions(regions=regions)
ranged = record.get_explanations(
start_date="2024-01-01T00:00:00.000000Z",
end_date="2024-06-01T00:00:00.000000Z",
)
Use the same entity_id=model_id pattern as SHAP insights. FeatureEffects / partial dependence
is still retrieved through Model helpers (not in datarobot.insights).
from datarobot.insights import RocCurve, LiftChart, ConfusionMatrix
roc = RocCurve.create(entity_id=model_id)
lift = LiftChart.create(entity_id=model_id)
confusion = ConfusionMatrix.create(entity_id=model_id)
model = dr.Model.get(project=project_id, model_id=model_id)
roc = model.get_roc_curve(source="validation")
lift = model.get_lift_chart(source="validation")
confusion = model.get_confusion_chart(source="validation")
# Feature Impact (non-SHAP) and Feature Effects (partial dependence for top features)
fi = model.get_feature_impact()
feature_effects = model.get_feature_effect(source="validation")
prediction - base_value in the link-function spacebase_value: the model's mean prediction (the "no information" baseline)Example: if base_value = 0.35 and a row's prediction is 0.72, the row's SHAP values sum to
0.37 when link_function = "identity". A feature with SHAP +0.20 contributed 20 units in
that same link-function space above baseline.
When link_function = "logit", SHAP values are in log-odds space. Add feature contributions to
base_value in log-odds space, then use inverse-logit (scipy.special.expit) on the resulting
total to convert it to a probability. Do not apply expit to individual SHAP values as if they
were probability deltas.
Task: explain predictions
|
- Need all features + all rows? -> ShapMatrix.create(entity_id=model_id)
- Need top-N features per row? -> ShapPreview.create(entity_id=model_id)
- Need aggregated importance? -> ShapImpact.compute(entity_id=model_id)
- Need feature SHAP distributions? -> ShapDistributions.create(entity_id=model_id)
- Need a segment/cohort only? -> dr.DataSlice + data_slice_id
- XEMP required (regulatory/type)? -> dr.PredictionExplanations.create(...)
- Time series / anomaly model? -> AnomalyAssessmentRecord.compute(project_id, model_id, ...)
| Error | Cause | Fix |
|---|---|---|
SHAP not available for this model | Unsupported model type, or anomaly-detection model with >1000 features | Check model support; use XEMP PE if SHAP is unavailable |
Feature Impact not computed | PredictionExplanations prerequisite missing | Run model.request_feature_impact() and wait |
Missing PredictionExplanationsInitialization | PE not initialized | Call PredictionExplanationsInitialization.create() |
source='holdout' fails | Holdout not unlocked | Unlock holdout in project settings first |
Empty previews | No rows in partition | Check partition contains data |
references/shap_api_reference.md - full parameter signatures for ShapMatrix, ShapImpact, ShapPreview, ShapDistributionsreferences/xemp_pe_reference.md - PredictionExplanations and PredictionExplanationsInitialization parameter referencescripts/compute_shap_matrix.py - compute and export ShapMatrix to CSV or DataFrameWhat SKILL.md sets; muted values are Claude Code's defaults
17 skills in this plugin
/datarobot-agent-assistUse when the user wants to design, build, code, simulate, or deploy an AI agent (not a predictive model) to DataRobot; mentions agent_spec.yaml, dr-assist, datarobot-agent-assist, dress rehearsal, swarm simulation, or the DataRobot agent template; wants to scaffold a LangGraph, CrewAI, LlamaIndex, NAT, or Base agent targeting DataRobot; wants to add an MCP server, backend API, or React frontend to a DataRobot agent application; or uses the DataRobot CLI (dr) to build or deploy an agentic custom application; or wants to harden, stress-test, or battle-test an agent. Covers the full workflow: agent design, agent_spec.yaml authoring, dress-rehearsal simulation via the DataRobot LLM Gateway, adversarial swarm simulation, template-based coding, and deployment./datarobot-agent-llm-selectionUse when the user wants to configure LLM integration for a DataRobot agent application. This skill helps to change LLM model, switch between the LLM integrations the project supports (LLM Gateway, a DataRobot-deployed LLM, an external provider, an LLM Blueprint, and any others its config declares), or set up provider credentials. The skill reads the project's .datarobot/cli/llm.yml for the real options, interviews the user, then runs sync_llm_env.py with the chosen values as CLI args to merge into .env./datarobot-app-framework-cicdGuidance for setting up CI/CD pipelines for DataRobot application templates using GitLab, GitHub Actions, and Pulumi for infrastructure as code. Use when setting up CI/CD pipelines, configuring deployments, or managing infrastructure for DataRobot application templates./datarobot-connectivity-datastore-sqlQuery, explore, and update databases through existing DataRobot data connections (datastores) with the connection's stored credentials: no connection strings, no app scaffolding. Use when the user wants to list DataRobot data connections, browse schemas, tables, or columns, preview a table, or run a SQL SELECT against any database connected in DataRobot; or run INSERT/UPDATE/DELETE/MERGE/CREATE (DML/DDL) through a Snowflake, Databricks, BigQuery, SAP Datasphere, or Trino connection. Examples: "query my Snowflake data connection", "show 10 rows from SALES.ORDERS in datastore <id>", "insert yesterday's totals into daily_summary in my Databricks connection". With only a JDBC URL and credentials, use datarobot-connectivity-jdbc-sql. Creating a connection happens in the DataRobot UI./datarobot-connectivity-jdbc-sqlRun SQL against a database through DataRobot with a JDBC URL (or host, port, and database) and credentials you supply; no DataRobot data connection needed. Also use it to point an existing app such as Talk to My Data at DataRobot's low-latency /jdbcDataPreview/ route (/jdbcExecution/ only for user-approved writes). Use when the user wants to test a connection to PostgreSQL, MySQL, SQL Server, Snowflake, Databricks, Trino, SAP HANA or Datasphere, Redshift, or BigQuery, list tables or columns, run read queries, or run DML/DDL, e.g. "run this SQL on jdbc:postgresql://… through DataRobot". If the database is already a DataRobot data connection, use datarobot-connectivity-datastore-sql./datarobot-data-preparationTools and guidance for data upload, dataset management, data validation, and preparing data for DataRobot projects. Use when uploading datasets, managing data, or validating data for DataRobot.npx claudepluginhub datarobot-oss/datarobot-agent-skills --plugin datarobot-agent-skillsOther plugins' skills for the same job