Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

License: MIT Ruff

DS2L-SOM

DS2L-SOM is a topological, density-based clustering algorithm. It combines a Self-Organizing Map (SOM) for prototype learning with Gaussian KDE density estimation and gradient ascent to detect clusters — without requiring the number of clusters to be specified in advance.

Based on the papers by Cabanes, Bennani and Fresneau (2008, 2012).

Usage

from ds2l_som.ds2lsom import DS2LSOM

model = DS2LSOM(n_prototypes=100, threshold=10)
model.fit(X)
labels = model.predict(X)   # sequential integers; -1 = unassigned

# or short:
labels = model.fit_predict(X)

DS2LSOM implements the scikit-learn API (ClusterMixin, BaseEstimator) and is compatible with sklearn pipelines and GridSearchCV.

Parameters

Parameter Default Description
n_prototypes auto (10·√n) Maximum number of SOM prototypes
threshold 1 Minimum shared samples for a prototype edge
sigma auto Bandwidth for Gaussian KDE density estimation
method "som" Quantizer backend: "som" (dbgsom) or "kmeans"
model_args None Kwargs passed to the quantizer: {"init": {...}, "train": {...}}
verbose False Print progress

Example with custom SOM parameters:

model = DS2LSOM(
    n_prototypes=100,
    threshold=10,
    model_args={"init": {"sigma_end": 1.0, "random_state": 42}},
)

Performance

Evaluated on load_digits (1797 samples, 64 features, 10 classes) using pairwise Rand and Jaccard index (as defined in the papers). DS2LSOM does not receive the true number of clusters.

Algorithm Clusters Noise Rand Jaccard
DS2LSOM 9 (auto) 37 0.912 0.461
KMeans (n=10 given) 10 0 0.906 0.415
Agglomerative (n=10 given) 10 0 0.930 0.542
HDBSCAN 6 (auto) 1244 — —

HDBSCAN metrics are excluded: 69% noise points make the scores not comparable.

Scalability

Time and memory complexity: O(n · k) where k ≈ 10·√n (default heuristic), giving O(n^1.5) overall. The distance matrix (shape k × n) is the main memory bottleneck — practical limit is around 50 000–100 000 samples.

Installing

# Development
git clone https://github.com/SandroMartens/ds2l-som.git
cd ds2l-som
uv sync

# As a dependency in another project
uv add ds2l-som

References

  • A Local Density-based Simultaneous Two-level Algorithm for Topographic Clustering, Guénaël Cabanes and Younès Bennani, 2008
  • Enriched topological learning for cluster detection and visualization, Guénaël Cabanes, Younès Bennani and Dominique Fresneau, 2012

Metadata

Release files for ds2l-som 0.3.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ds2l-som 0.3.0b1
File Size Uploaded
ds2l_som-0.3.0b1.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for ds2l-som 0.3.0b1
File Interpreter ABI Platform
ds2l_som-0.3.0b1-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / ds2l_som-0.3.0b1.tar.gz

Download URL ds2l_som-0.3.0b1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
89ca982b3e6bfe06d067cbd9fdadb3db7d4d75b7d9564363a64b3e4ba4f313a7
BLAKE2b-256 checksum
How to use checksums
b8a59a168e1daa031235c6eb47568bd9a0cb8d683b7f6699c10ccd5be2aa517f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.

Transparency log

Release files / ds2l_som-0.3.0b1-py3-none-any.whl

Download URL ds2l_som-0.3.0b1-py3-none-any.whl
Size 43.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
487370bc11124842947081fb72e8e33b555bb51f8dc35ec37dd8228b0f4671af
BLAKE2b-256 checksum
How to use checksums
a7f3793d242b1cbe2ee6d421e3ad88315771aa496f4a186f34bd349467e259e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0b1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page