Temporal Models Skill

SkillAI & models

Use this skill whenever the input contains ordered repeated measurements, longitudinal visits, ROI time series, dynamic connectivity features, or variable-length sequences. It supports LSTM, GRU, temporal convolutional networks, and temporal Transformers for classification and regression. Triggers include 'longitudinal model', 'sequence model', 'time series', 'repeated visits', 'LSTM', 'GRU', 'TCN', 'temporal Transformer', 'dynamic connectivity', and 'variable-length sequence'.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Temporal Models Skill skill

What this skill tells your AI

The instructions your AI receives, as published by cuhk-aim-group/neurodiscovery in skills/temporal-models/SKILL.md and read by ahel’s review.

Overview

temporal-models trains sequence encoders on ordered neuroimaging or clinical measurements. It supports variable sequence lengths and estimates normalization statistics from training subjects only.

Supported models

ModelEncoderTypical use
lstmlong short-term memorylongitudinal visits
grugated recurrent unitcompact recurrent baseline
tcntemporal convolutional networklocal temporal patterns
transformermasked temporal self-attentionlonger dependencies

Both classification and regression are supported.


Installation

pip install numpy torch scikit-learn pandas

Verify:

python -c "import torch; print('CUDA:', torch.cuda.is_available())"

Workflows

1. Prepare an NPZ sequence bundle

X:          float array [subjects, time, features]
y:          array [subjects]
lengths:    integer array [subjects] (optional)
subject_id: string array [subjects] (optional)

Padded frames must occur after each valid sequence. If lengths is absent, every sequence is treated as fully valid.

import numpy as np

np.savez(
    "sequences.npz",
    X=X.astype("float32"),
    y=y,
    lengths=lengths,
    subject_id=subject_ids,
)

2. Classification with GRU

python skills/temporal-models/scripts/train_reference.py \
  --input sequences.npz \
  --model gru \
  --task classification \
  --hidden-dim 64 \
  --layers 2 \
  --epochs 100 \
  --batch-size 32 \
  --folds 5 \
  --device cuda \
  --output-dir run_models_output/gru

3. Regression with temporal Transformer

python skills/temporal-models/scripts/train_reference.py \
  --input sequences.npz \
  --model transformer \
  --task regression \
  --hidden-dim 128 \
  --layers 3 \
  --dropout 0.2 \
  --lr 0.001 \
  --weight-decay 0.0001 \
  --output-dir run_models_output/temporal_transformer

Use subject-level folds; never split frames or visits from one subject across training and test sets.


Input / Output Summary

ItemFormat
Input.npz with X, y, optional lengths, subject_id
Predictionspredictions.csv
Fold membershipfold_assignments.csv
Metricsmetrics.json
Fold checkpointscheckpoint.pt
Provenanceconfig.json, run_manifest.json

Each fold checkpoint stores the model state plus fold-local feature mean and standard deviation.


Testing

pytest models/tests/test_extended_models.py -q
python skills/temporal-models/scripts/train_reference.py --help

Directory Reference

models/temporal_models/
├── net.py              LSTM, GRU, TCN, and Transformer encoders
└── train.py            cross-validated sequence trainer

skills/temporal-models/
├── SKILL.md
└── scripts/train_reference.py

Reference

  • Sequence masking is driven by the optional lengths array.
  • Scaling is fitted from valid training frames and padding is restored to zero.

Created At: 2026-07-26 HKT Last Updated At: 2026-07-29 HKT Author: chengwang96

Signals

GitHub stars
85
Forks
4
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
temporal-models-cuhk-aim-group
Source
github.com/cuhk-aim-group/neurodiscovery