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 source checkout:
python -m pip install .
For development, testing, plotting, and documentation:
python -m pip install -e ".[dev]"
The package has not yet been released on PyPI. Do not use
pip install stsckm until a release is published there.
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. Version 1.0.0 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.0
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.0.tar.gz | 98.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stsckm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 188.6 kB
Release files / stsckm-1.0.0.tar.gz
| Download URL | stsckm-1.0.0.tar.gz |
|---|---|
| Size | 98.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bce7e4694186c70ab037bf843ba5897b793667a04f2eb23137f6807d1d932a69
|
|
BLAKE2b-256 checksum How to use checksums |
6731eb7dccf78846299602f19cf22c47ebcdd3495f26eb48fc22cc6baaf7b76d
|
| 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.0-py3-none-any.whl
| Download URL | stsckm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 89.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7760e391f6d6b8989c450a5b7162619efc18d5880dcdd50081c60c75733e3b57
|
|
BLAKE2b-256 checksum How to use checksums |
d0b6568acd3a76bfd53352d47609b2451851eb435df8e95f8a2957d6e37c4b3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|