Skip to main content

A fast multi-core implementation of the PLSCAN clustering algorithm.

Project description

PyPi version Conda version DOI

Persistent Leaves Spatial Clustering for Applications with Noise

This library provides a new clustering algorithm based on HDBSCAN*. The primary advantages of PLSCAN over the hdbscan and fast_hdbscan libraries are:

  • PLSCAN automatically finds the optimal minimum cluster size.
  • PLSCAN can easily use all available cores to speed up computation.
  • PLSCAN has much faster implementations of tree condensing and cluster extraction.
  • PLSCAN does not rely on JIT compilation.

To use PLSCAN, you only need to set the min_samples parameter. This parameter controls how many neighbors are considered when measuring distances between points. Setting a higher value for min_samples makes the algorithm group points into larger, smoother clusters, and usually results in fewer, more stable clusters.

import numpy as np
import matplotlib.pyplot as plt

from fast_plscan import PLSCAN

data = np.load("docs/data/data.npy")

clusterer = PLSCAN(
  min_samples = 5, # same as in HDBSCAN
).fit(data)

plt.figure()
plt.scatter(
  *data.T, c=clusterer.labels_ % 10, s=5, alpha=0.5, 
  edgecolor="none", cmap="tab10", vmin=0, vmax=9
)
plt.axis("off")
plt.subplots_adjust(left=0, right=1, top=1, bottom=0)
plt.show()

scatterplot

The algorithm creates a hierarchy of leaf-clusters by changing the minimum cluster size. As this parameter varies, clusters appear or disappear. For each minimum cluster size, the algorithm measures how long these leaf-clusters persist. It then selects the minimum cluster size where the total persistence is highest, giving the most stable clustering. You can visualize this hierarchy using the leaf_tree_ attribute, which provides an alternative to HDBSCAN*'s condensed cluster tree.

clusterer.leaf_tree_.plot(leaf_separation=0.1)
plt.show()

leaf tree

You can also explore how the clustering changes for other important values of the minimum cluster size. The cluster_layers method automatically finds the most persistent clusterings and returns their cluster labels and membership strengths.

layers = clusterer.cluster_layers(max_peaks=4)
for i, (size, labels, probs) in enumerate(layers):
  plt.subplot(2, 2, i + 1)
  plt.scatter(
    *data.T,
    c=labels % 10,
    alpha=np.maximum(0.1, probs),
    s=1,
    linewidth=0,
    cmap="tab10",
  )
  plt.title(f"min_cluster_size={int(size)}")
  plt.axis("off")
plt.subplots_adjust(left=0, right=1, top=1, bottom=0)
plt.show()

layers

Installation instructions

Pre-build binaries are available on pypi and conda-forge, so the package can be installed with pip, conda, and similar package managers on most systems:

conda install conda-forge::fast-plscan

or

pip install fast_plscan

See our documentation for instructions on compiling the package locally.

Citing

When using this work, please cite our preprint:

@misc{bot2025plscan,
  title         = {Persistent Multiscale Density-based Clustering},
  author        = {Dani{\"{e}}l Bot and Leland McInnes and Jan Aerts},
  year          = {2025},
  eprint        = {2512.16558},
  archiveprefix = {arXiv},
  primaryclass  = {cs.LG},
  url           = {https://arxiv.org/abs/2512.16558}
}

Licensing

The fast-plscan package has a 3-Clause BSD license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast_plscan-0.2.0.tar.gz (478.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fast_plscan-0.2.0-cp312-abi3-win_amd64.whl (456.5 kB view details)

Uploaded CPython 3.12+Windows x86-64

fast_plscan-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (329.9 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_plscan-0.2.0-cp312-abi3-macosx_15_0_arm64.whl (418.3 kB view details)

Uploaded CPython 3.12+macOS 15.0+ ARM64

fast_plscan-0.2.0-cp311-cp311-win_amd64.whl (458.0 kB view details)

Uploaded CPython 3.11Windows x86-64

fast_plscan-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (334.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_plscan-0.2.0-cp311-cp311-macosx_15_0_arm64.whl (418.8 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

fast_plscan-0.2.0-cp310-cp310-win_amd64.whl (458.2 kB view details)

Uploaded CPython 3.10Windows x86-64

fast_plscan-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (334.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fast_plscan-0.2.0-cp310-cp310-macosx_15_0_arm64.whl (418.9 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file fast_plscan-0.2.0.tar.gz.

File metadata

  • Download URL: fast_plscan-0.2.0.tar.gz
  • Upload date:
  • Size: 478.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fast_plscan-0.2.0.tar.gz
Algorithm Hash digest
SHA256 034fbf0b79fe64703dd9e5a0812aecf374172fceb1c85c5df390a2923fbe44e8
MD5 d865d7c9e7602cd97e240ac2b3830b05
BLAKE2b-256 9f93a9daf1c535e30ba5fb0cf637b629083ebabbec6a6120ca6ffa036d06a7a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0.tar.gz:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: fast_plscan-0.2.0-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 456.5 kB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fast_plscan-0.2.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 afa1aebff83cb94c0e2d58c3ae1507fca45063e74764720b5890e5f23ea24e0b
MD5 e72be165487b2c721583c5f71bb4a8fb
BLAKE2b-256 738276f404cf5830ba5e072218470320d5b4c189f6d8d534208555ea5b276971

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp312-abi3-win_amd64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_plscan-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 968de97f6e28e67f389e6262016ee47b1b054800a7f937785aa563331e717437
MD5 e3f7545b4605da265c41f67096c10910
BLAKE2b-256 b2ed2c292b75b3d8bfbc1c6269020da5f82cc060c7007377f7477220a17dac04

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_plscan-0.2.0-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8fbbf0695023aa61fdd948a579c6f77e8dda9a0c7b3161c4ccacfbd38e33cfba
MD5 2de102d4521ddfb7c5af01da8a29cf0e
BLAKE2b-256 ca3c77051894e64368e67711fbe4b33bc1436ed691c7936daf15a4955ced6540

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp312-abi3-macosx_15_0_arm64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: fast_plscan-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 458.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fast_plscan-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1077f9d3d40fb0f6c489c7b74aca2d2e367562591b2456271ee7cdb0cf7e4ac2
MD5 638a9a4d05e8ff85116e116330d35f13
BLAKE2b-256 0f0578545a5bc80981cbd57a81fd1b89b8ad6db3bb68005dc9a93fda3f9cdc9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_plscan-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 625bf45adb260667b826188ad3c3a67fc6ca92dd0e36a600931386def39b22f9
MD5 ba0d0db45fe1ae2df8a69df99ff642a7
BLAKE2b-256 78e74d291d4d1546b9d2232081843d160d8bcda4c7f687c5f0a6635f6e5b2379

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_plscan-0.2.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3e040c12815b98960b90465a2e98b6bfe6554813704c396af1ae17ffefc79b53
MD5 383bb2232b0159b714e74bc7d381c983
BLAKE2b-256 28df3915a94fd85adde2dac3b007b1e38ac259956c12e791013b1dcd12f12302

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: fast_plscan-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 458.2 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fast_plscan-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4c706432731596b402ce0601dca332db20ec14f01071864e618c01fa235cbc98
MD5 45e267ada1add7bda2a6bce5602104f3
BLAKE2b-256 5ca7c35922bc6cd3ce798d7ba0d45bd66a1f39ad1a02acb92b2dc54f2cc504ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp310-cp310-win_amd64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fast_plscan-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6a63b525c2f6e88a88ce521f10cd0c06ddd51a4c066d14d1a65a0be00921b336
MD5 0e58efb40d1b9c2e456566c8645d0024
BLAKE2b-256 614e5a5adbedb1bb79e9d48fa2e398939ff9ad70e20a00eb08a447e7cbc0d8f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_plscan-0.2.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for fast_plscan-0.2.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 3fe0c2d20417985a1751ef8e23615d6a260930da6da84f189e64e9f7e316c465
MD5 b2091a693185626b24879a85014e2219
BLAKE2b-256 29a6f8f72944529841f4215be54d497b1bafe22a4ca1e2487c7add8f0a5080ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_plscan-0.2.0-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: release.yml on JelmerBot/fast_plscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page