Skip to content

Load a Lightning checkpoint

Use this guide when you want inference and TimeSHAP from a pretrained model.

What you need

  • checkpoint file (.ckpt, .pt, or .pth)
  • dataset with the same feature semantics used during model training
  • optionally, a scaler file (.npz) with mean and std

Steps

  1. Start the app:
uv run python -m streamlit run timeshap_app.py
  1. In sidebar Model:
  2. set Model source to Load Lightning checkpoint

  3. Upload checkpoint and optional metadata:

  4. Lightning checkpoint: upload file
  5. Lightning class path (optional):
  6. format package.module.ClassName
  7. use when loading through Class.load_from_checkpoint(...)
  8. Model attribute:
  9. default model
  10. set to where the torch.nn.Module lives on the loaded Lightning object

  11. Optional scaler:

  12. upload .npz containing mean and std arrays
  13. lengths must equal number of selected features

  14. Click Load checkpoint

Validation checklist

After load:

  • Model Diagnostics should show Active model source: checkpoint
  • notes under diagnostics should describe how loading happened
  • no exception should appear in the UI

Then run TimeSHAP as usual from TimeSHAP Local Explanations.

If it fails

Check:

  • feature count matches checkpoint input
  • preprocessing (column order, scaling) matches training-time setup
  • model output is compatible with app contract:
  • (logits, seq_hidden, hidden_state) or (logits, seq_hidden)