stsckm
stsckm is a Python implementation of spatio-temporal spatially constrained
K-means (ST-SCKM) for point-event data. It combines weighted spatial and
temporal squared distances with a soft label-disagreement penalty on a spatial
K-nearest-neighbor graph.
The package implements the method associated with:
Idris, M. A., Aidi, M. N., and Djuraidah, A. (2026). Performance Evaluation of ST-DBSCAN and Spatio-Temporal Spatially Constrained K-Means (ST-SCKM) for Wildfire Risk Zoning and Resilience Analysis. Journal of Safety Science and Resilience. https://doi.org/10.1016/j.jnlssr.2026.100357
Scope
The estimator is intended for aligned spatial and temporal numeric matrices. The KNN penalty encourages neighboring observations to share labels but does not guarantee that every cluster is a single connected component. Context variables such as event intensity can be retained for post hoc profiling without entering the clustering objective.
Installation
Install the published package from PyPI:
python -m pip install stsckm
Optional plotting support can be installed with:
python -m pip install "stsckm[plot]"
For development, testing, and documentation from a source checkout:
python -m pip install -e ".[dev]"
Quick start
import numpy as np
from stsckm import (
STSCKM,
add_default_features,
evaluate_labels,
load_sample_wildfire,
standardize_features,
)
frame = add_default_features(load_sample_wildfire())
X_spatial, spatial_scaler = standardize_features(
frame, ["x_proj", "y_proj"]
)
X_temporal, temporal_scaler = standardize_features(
frame, ["time_days"]
)
model = STSCKM(
n_clusters=4,
spatial_weight=0.5,
temporal_weight=1.5,
lambda_spatial=1.0,
n_neighbors=5,
random_state=42,
)
labels = model.fit_predict(X_spatial, X_temporal)
metrics = evaluate_labels(
np.column_stack([X_spatial, X_temporal]),
labels,
)
print(model.n_iter_)
print(metrics)
Main API
STSCKM.fit(X_spatial, X_temporal)STSCKM.fit_predict(X_spatial, X_temporal)weighted_spatiotemporal_distance(...)knn_indices(...)evaluate_labels(...)neighbor_disagreement(...)assign_risk_labels(...)load_sample_wildfire()
The estimator follows scikit-learn parameter conventions and inherits from
BaseEstimator and ClusterMixin. The current release intentionally does not expose
out-of-sample predict(): defining neighbors for new points requires a
separate modeling choice.
Reproduction
Run all manuscript-scale numerical results and figures with one command:
python replication/run_all.py
The script writes its outputs to replication/output/ and checks the
sensitivity table against replication/expected/sensitivity.csv.
Tests and build
python -m pytest
python -m build
python -m twine check dist/*
License
MIT. This is a GPL-compatible free-software license.
Author
Muh Akbar Idris
IPB University
ORCID: https://orcid.org/0009-0000-2995-1975
Metadata
Release files for stsckm 1.0.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 | |
|---|---|---|---|
| stsckm-1.0.1.tar.gz | 99.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stsckm-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 189.1 kB
Release files / stsckm-1.0.1.tar.gz
| Download URL | stsckm-1.0.1.tar.gz |
|---|---|
| Size | 99.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32898e60e89e4a6da9c73fba5b5cfb5ae8de88bfc0fbb9bf1f94aae396d8989f
|
|
BLAKE2b-256 checksum How to use checksums |
81d51fe0324adc2eb2b625c258feb4a334a11a0b505e02b91c0d94f2ce13360f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / stsckm-1.0.1-py3-none-any.whl
| Download URL | stsckm-1.0.1-py3-none-any.whl |
|---|---|
| Size | 89.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d7e1e606c23e0727bce1fc8a3ed728d6c6f3d901f0cf843ee825ff5399bc186
|
|
BLAKE2b-256 checksum How to use checksums |
5f141e04d50716b1cd053dfae753b58bde163d103b2872155266380b260220bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|