Python API¶
The Python-first API is for running one model programmatically. It wraps the same presets and runner used by the CLI while presenting model classes with a small sklearn-style surface.
Use the CLI for benchmark campaign orchestration, paper reproduction, and artifact-backed metric profiles.
Imports¶
Use concrete classes when they exist:
Use STPPEstimator when you want to choose by model name or registered preset:
model = STPPEstimator("AutoSTPP", device="cpu")
same_model = STPPEstimator("auto_stpp", device="cpu")
Supported Model Aliases¶
The Python API exposes friendly classes for registered presets, including:
PoissonGMM,PoissonCNF,PoissonTVCNFHawkesGMM,HawkesCNF,HawkesTVCNFSelfCorrectingGMM,SelfCorrectingCNF,SelfCorrectingTVCNFRMTPPGMM,THPGMMNeuralSTPP,NeuralJumpSC,NeuralAttnSCNeuralJumpCNF,NeuralAttnCNFDeepSTPP,AutoSTPP,SMASH,DiffusionSTPP,NSMPP
The canonical NJSDE preset is available through STPPEstimator("njsde").
Programmatic discovery is available:
Data¶
Load canonical JSONL split files with load_jsonl:
train = load_jsonl("data/my_dataset/train.jsonl")
val = load_jsonl("data/my_dataset/val.jsonl")
test = load_jsonl("data/my_dataset/test.jsonl")
Each split is a list of sequence dictionaries with times and locations.
See Data Format for the full data contract.
Fit¶
fit trains from in-memory train, validation, and optional test sequences. A
validation split is required.
model = AutoSTPP(device="cpu", seed=42)
model.fit(
train,
val,
test,
epochs=10,
lr=1e-3,
batch_size=64,
dataset_id="my_dataset",
)
fit returns the estimator itself. The fitted runner is available as
model.runner, and the underlying model is available as model.model.
Evaluate¶
evaluate currently supports implemented likelihood metrics:
The default core profile returns:
test_nllmean_seq_nll
You can request supported metrics explicitly:
Unsupported estimator metrics raise NotImplementedError. Use
python -m seahorse evaluate metrics ... for the full artifact-backed
evaluation profiles.
Predict Next Events¶
The implemented predictive method is predict_next, not predict:
The returned dictionary includes arrays such as:
next_timesnext_locationstrue_next_timestrue_next_locationssequence_indextarget_event_indexsampling_succeededsampling_backend
predict_next raises NotImplementedError when the fitted model does not
support the required native or exact-intensity sampling path.
Tune¶
The Python API exposes a thin HPO wrapper:
This uses the existing Ray Tune path. Install HPO dependencies before using it:
Save And Load¶
Save a fitted estimator through the underlying runner:
Load through the base estimator or a matching concrete class:
Visualization Helpers¶
Fitted estimators expose plotting helpers:
surface = model.plot_intensity(test[0], output_path="runs/plots/intensity")
kde = model.plot_kde_surface(test[0], n_samples=128, output_path="runs/plots/kde")
plot_intensity requires a fitted or loaded runner with a run directory.
plot_kde_surface requires plotly.
For benchmark-aligned visual artifacts, use the CLI workflows in Evaluation And Visualization.