Architecture overview¶
This app combines sequence modeling with local explainability in one Streamlit workflow.
High-level flow¶
- Load data:
-
demo generator or uploaded CSV/Parquet
-
Build windows:
- sorted by entity and timestep
-
sliding windows produce
(x, y) -
Activate model:
- either train built-in GRU
-
or load pretrained checkpoint
-
Inspect window:
- compute prediction and hidden activations
-
visualize hidden matrix over timesteps
-
Explain selected window:
- run TimeSHAP pruning
- run event-level attribution
- run feature-level attribution
Core components¶
GRUClassifier- sequence encoder (
nn.GRU) plus classification head SequencePack- session payload for scaled windows, labels, and metadata
load_sequence_model_from_checkpoint- flexible loader for Lightning and raw state dict checkpoints
run_local_timeshap- adapter from app tensors to TimeSHAP local API
State model¶
The app stores active artifacts in st.session_state["trained"]:
- active source (
trainorcheckpoint) - model object
- optional training history
SequencePack- train/validation indices
- loader notes
This keeps model and preprocessing context aligned for downstream plotting and explanation.