Skip to content

First local explanation run

This tutorial walks through the first successful end-to-end run using demo data.

Outcome

At the end you will:

  • train a GRU model in-app,
  • inspect one validation window and its hidden activations,
  • run TimeSHAP and read pruning, event, and feature attributions.

Prerequisites

  • Python environment set up for this repo
  • Dependencies installed (uv sync or equivalent)

Step 1: Start the app

uv run python -m streamlit run timeshap_app.py

Step 2: Keep demo data selected

In the sidebar:

  • Dataset: choose Demo synthetic data
  • Keep default columns:
  • Entity column: entity_id
  • Time column: time_idx
  • Target column: target

Step 3: Train the baseline model

In Model:

  • Model source: Train in app
  • Keep defaults:
  • Sequence length = 18
  • GRU hidden size = 32
  • Epochs = 8
  • Batch size = 64
  • Learning rate = 0.005
  • Click Train / Retrain

Wait for training to finish, then verify:

  • Model Diagnostics shows training and validation curves
  • Sequence Inspector shows predicted probability and hidden-state heatmap

Step 4: Select a validation sample

  • Set Validation sample to any index
  • Confirm Predicted probability, Predicted class, and True class are displayed
  • Review the raw window table under the heatmap

Step 5: Run TimeSHAP

In TimeSHAP Local Explanations:

  • Keep defaults:
  • Pruning tolerance (tol) = 0.03
  • Kernel SHAP samples = 200
  • Click Run TimeSHAP

Expected outputs:

  • Pruning Output table/object
  • Event-Level (Timestep) Attributions chart and table
  • Feature-Level Attributions chart and table

Next steps

  • Try How-to guides -> Use custom CSV or Parquet data
  • Try How-to guides -> Load a Lightning checkpoint