ai-prediction-explainer
Skill2 starsChanged 12 days agoMITView on GitHub
AI Prediction Explainer. Generative AI chatbot that explains machine learning predictions in plain language - RTCC prompt (Role, Task, Context, Constraints), server-built context JSON with predictions, SHAP contributions and what-if results, OpenAI or Anthropic provider adapter with streaming, timeouts, retries, caching and rate limits, numeric grounding guard against invented numbers, prompt-injection handling, template fallback, notebook demo. Use for LLM explanations of model output, explainable AI chat, "why did the score change", or adding an AI assistant to a prediction app.
- Reads credentials
In this repository16 other files it gives its agents.
- data-mining-machine-learningSkill
- data-miningSkill
- data-preparationSkill
- data-profilingSkill
- data-storytellingSkill
- feature-engineeringSkill
- hyperparameter-tuningSkill
- ml-quality-guardSkill
- ml-web-applicationSkill
- model-deploymentSkill
- model-evaluationSkill
- model-explainabilitySkill
- model-trainingSkill
- notebook-auditSkill
- problem-framingSkill
- statistical-analysisSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Follow-ups reuse the same context plus the last four turns.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Prediction Explainer
The user moves predictors, asks why the prediction changed, and gets a short answer that uses only numbers the server computed.
Flow
- The front end calls
POST /v1/whatifas sliders move. - "Explain this change" (or auto-explain) sends only the profile values, the question and recent chat turns to
POST /v1/explain/narrative. - The server recomputes predictions, Shapley contributions and counterfactuals (
mlkit.explainer.build_rtcc_context), validates the context againstrtcc_context.schema.json, calls the provider, checks every number (grounding.py), regenerates once on failure, falls back to the template, and streams the result over SSE (meta,token,done). - Follow-ups reuse the same context plus the last four turns.
Prompt files (templates/prompts/)
rtcc_system.md: Role, Task, Context, Constraints.[MODEL_PURPOSE]and[AUDIENCE]are filled frommetadata.json(from ANALYSIS_MANIFEST.md) at startup.rtcc_context.schema.json: the only facts the model may use.rtcc_examples.md: two worked examples with angle-bracket placeholders only; real numbers never appear in static files.
Provider adapter
LLM_PROVIDER is openai, anthropic or none; keys from OPENAI_API_KEY or ANTHROPIC_API_KEY; model from LLM_MODEL. Every call has a timeout, a token cap and bounded retries with backoff; answers are cached by the hash of context and question; a per-session hourly limit caps cost. With none or on any provider failure the deterministic template explanation is returned. At runtime the service calls the provider API directly; Claude Code helps build and test the adapter.
Guards
- User text goes in the user message only, below the context and labeled as a question; the system prompt is a static file.
- Clients cannot send predictions or contributions (request models reject unknown fields).
- Grounding: every number must equal a context value, its percent form, or the difference of two context values, within the rounding written; small counting integers (1 to 5) are allowed.
- The answer describes associations, never causes, names extrapolated predictors, and gives no medical, legal or financial advice.
Tests (provider mocked)
Context building and schema validation, prompt injection stays out of the system prompt, grounded answer passes, invented number is regenerated then replaced, timeout falls back after bounded retries, caching, session limit, SSE format.
Notebook demo
templates/notebooks/llm_explainer_demo.ipynb: same prompt and guard driven by ipywidgets; reads the key from google.colab.userdata in Colab or environment variables elsewhere; runs offline with the template.
Details: references/rtcc-explainer.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

