Skip to main content

An efficient implementation of the DBSCAN algorithm for 1D arrays.

Project description

DBSCAN1D

Coverage Supported Versions PyPI Licence

dbscan1d is a 1D implementation of the DBSCAN algorithm. It was created to efficiently preform clustering on large 1D arrays.

Sci-kit Learn's DBSCAN implementation does not have a special case for 1D, where calculating the full distance matrix is wasteful. It is much better to simply sort the input array and performing efficient bisects for finding closest points. Here are the results of running the simple profile script included with the package. In every case DBSCAN1D is much faster than scikit learn's implementation.

image

Installation

Simply use pip to install dbscan1d:

pip install dbscan1d

It only requires numpy.

Quickstart

dbscan1d is designed to be interchangable with sklearn's implementation in almost all cases. The exception is that the weights parameter is not yet supported.

from sklearn.datasets import make_blobs

from dbscan1d.core import DBSCAN1D

# make blobs to test clustering
X = make_blobs(1_000_000, centers=2, n_features=1)[0]

# init dbscan object
dbs = DBSCAN1D(eps=.5, min_samples=4)

# get labels for each point
labels = dbs.fit_predict(X)

# show core point indices
dbs.core_sample_indices_

# get values of core points
dbs.components_

Notes

  • dbscan1d can return different group numbers than sklearn for non-core points which are within eps distances of core points for two separate groups. For example: --C1--C1--P--C2--C2 Here C1 and C2 are core points for group 1 and group 2, respectively. If P is within eps of both C1 and C2, dbscan1d will assign it the same label as the core point that is closest. Sklearn doesn't always do this.

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

dbscan1d-0.2.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

dbscan1d-0.2.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file dbscan1d-0.2.2.tar.gz.

File metadata

  • Download URL: dbscan1d-0.2.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for dbscan1d-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9600384f7b09bd4f5d6ff034dffb00f9ec5e3f65e8a97ee95a2b9ec93ed96a12
MD5 cb33915244824f8ad862ae0a0a10ffae
BLAKE2b-256 bc05158f34c1701aef80fdf78da65231340dd7d8c1e38ce686d63cfb4ac98731

See more details on using hashes here.

File details

Details for the file dbscan1d-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: dbscan1d-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for dbscan1d-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2e6ed66e928d8ec6637ab1fefa4278fdf1f2b6581db26282cd6ce53729ce68ae
MD5 a15fcb2dd51cc4fa35e028fc8447b90f
BLAKE2b-256 bdea7cddad89d1d1833228b3b6206dfecbf28c1a99ebff9c4fdca9755b4853fa

See more details on using hashes here.

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