Sequence Explorer
Interactive Streamlit dashboard for visualizing how a sequence model's hidden state evolves over transaction sequences. Works with any PyTorch RNN (GRU, LSTM, RNN) with any number of layers.
Two Ways to Use
As a Package (pip install)
pip install seq-explorer
In Python/Notebooks:
from seq_explorer import SequenceTrace
trace = SequenceTrace.from_arrays(...)
Run dashboard:
streamlit run src/seq_explorer/app.py
As a Project (clone & run)
git clone https://github.com/chris-santiago/seq-explorer
cd seq-explorer
uv sync
uv run python src/seq_explorer/build_cache.py dataframe your_data.csv -o cache.parquet
uv run streamlit run src/seq_explorer/app.py
What it shows
- Model score timeline — running P(fraud) at every timestep, color-coded green → red
- Hidden state heatmap — per-neuron activations across the sequence (any number of layers)
- Hidden state norms — L2 norm over time for all layers, plus rate-of-change bars
- Top-k neuron drill-down — neurons most correlated with the fraud score, traced over time
- Layer similarity — cosine similarity between consecutive hidden state layers
- Raw features table — the actual transaction data, highlighted at the selected timestep
- Metadata overlays — visualize categorical/numeric metadata on timelines (e.g., risk tiers, channels)
- Timestep scrubber — linked across all panels for synchronized inspection
Quick Start
# Install dependencies
uv sync
# Build cache from CSV/Parquet (auto-detects schema)
uv run python src/seq_explorer/build_cache.py dataframe your_data.csv -o cache.parquet
# Launch dashboard
uv run streamlit run src/seq_explorer/app.py
The dashboard auto-detects hidden state columns - just use any prefix pattern like h0_*, h1_* or encoder_*, decoder_*.
Usage Options
Option 1: Construct + Plot Directly in Jupyter (Simplest!)
No need to save files or run Streamlit. Just use the plotting functions:
from seq_explorer import (
SequenceTrace,
fraud_score_timeline,
hidden_state_heatmap,
hidden_norm_plot,
top_neuron_traces,
layer_similarity_plot,
raw_feature_heatmap,
feature_fraud_correlation,
metadata_timeline_overlay,
)
trace = SequenceTrace.from_arrays(
sequence_id=0,
label=1,
raw_features=my_features, # (seq_len, n_features)
feature_names=['amount', ...],
hidden_states=[h0, h1], # list of (seq_len, hidden_dim)
running_fraud_scores=scores, # (seq_len,)
)
# All plotting functions return Plotly figures - show them inline!
fraud_score_timeline(trace.running_fraud_scores).show()
hidden_state_heatmap(trace.hidden_states[0]).show()
hidden_norm_plot(trace.hidden_norms).show()
top_neuron_traces(
trace.hidden_states[0],
trace.top_neuron_indices[0],
trace.top_neuron_correlations[0]
).show()
Option 2: Construct + Save + Dashboard
# Save to Parquet
df = SequenceTrace.to_dataframe({0: trace})
df.write_parquet('cache.parquet')
# Launch dashboard
streamlit run src/seq_explorer/app.py
Option 3: From DataFrame
python src/seq_explorer/build_cache.py dataframe data.csv -o cache.parquet
Option 4: From Model
python src/seq_explorer/build_cache.py model \
--checkpoint model.ckpt \
--data transactions.pt \
--auto-select \
-o cache.parquet
Model Support
Works with any PyTorch sequence model:
- GRU - any number of layers
- LSTM - any number of layers
- RNN - any number of layers
- Custom architectures with different attribute names (e.g.,
encoder,rnn_module)
Project structure
seq-explorer/
├── seq_explorer/ # Package + CLI
│ ├── __init__.py
│ ├── app.py # Streamlit dashboard
│ ├── plots.py # Plotly figure builders
│ ├── extractor.py # Model trace extraction
│ ├── trace.py # Data models
│ └── build_cache.py # Cache builder CLI
├── docs/ # Documentation
├── demo/ # Demo notebooks
└── README.md
Documentation
See the docs/ folder for full documentation:
Metadata
Release files for seq-explorer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| seq_explorer-0.1.1.tar.gz | 31.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| seq_explorer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 64.3 kB
Release files / seq_explorer-0.1.1.tar.gz
| Download URL | seq_explorer-0.1.1.tar.gz |
|---|---|
| Size | 31.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7470e2d32a63da294a1f0d2ea8aad893bd487dbee1f4ee5fa8c9ad9761d44894
|
|
BLAKE2b-256 checksum How to use checksums |
555f5f2751745e3252b7d32f41bad5764436442abccb11501fe668314dc14ece
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / seq_explorer-0.1.1-py3-none-any.whl
| Download URL | seq_explorer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 32.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c490aeaa9d8177703ff664d16f206eb82183baafe809f0452c931b17dbf528a7
|
|
BLAKE2b-256 checksum How to use checksums |
addf5297999f3ecb046a8d6d64f07a44bcc9d772bc24052411cd7f7b6e36ec26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for seq-explorer 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.