Skip to main content

Iterative clustering mechanism providing full coverage of the data.

Project description

Exhaustive HDBSCAN

HDBSCAN is a density based clustering technique that results in stable clusters. It is a modification of the basic DBSCAN algorithm and the hierarchical element comes from the splitting technique that proceeds in order of the density metric, i.e. the splits are performed as the density thresholds are reached sequentially. Consequently points within a threshold that do not qualify the cluster size criteria, are qualified as noise.

Since outputs of HDBSCAN clustering leaves out some points as noise, this can lead to loss of information. Exhaustive HDBSCAN addresses this shortfall by iteratively clustering the left over noise points at each level of iteration. The points left out as noise at each iteration are combined into their own density structure and clustered through their unique thresholding.

Typically, HDBSCAN is combined with a dimension reduction technique. Universal Manifold Approximation and Projection (UMAP) is more suited to the HDBSCAN as it preserves local neighborhood topology. This preserves the density structure while solidifying the separation boundaries.

With Exhaustive HDBSCAN, a new reduction is performed at each iteration. This leads to noise points forming their own unique density structure within which thresholding can separate clusters. Cluster size and minimum samples are adjusted iteratively to account for the reduced dataset size as iterations proceed.

Further when noise points from each iteration are reduced to form their unique density structure, these clusters can now be linked back to the clusters they originally fell out of. Exhaustive HDBSCAN caters for this by using a HDBSCAN-like density-based metric to assign parent-child links between clusters from previous iteration and current iteration. The resultant output is a tree of clusters.

Tests have found that as we move down this tree of clusters, the clusters become more sparse, but the meaning within them soldifies and becomes more precise.

Exhaustive HDBSCAN becomes an effective tool to extract structured meaning from large datasets in an unsupervised manner.

Full Docs

Installation

pip install exhaustive_hdbscan

Basic Usage

Here input_data is raw feature set.

from exhaustive_hdbscan import EHDBSCAN

ehdb = EHDBSCAN()
ehdb = ehdb.fit(input_data)

print(ehdb.cluster_feats.parent_names)

Minimal Reducer and Encoder Implementation

from sentence_transformers import SentenceTransformer
import umap
from exhaustive_hdbscan import Reducer, Encoder

class mEncoder(Encoder):
	def __init__(self):
		self.encoder = SentenceTransformer('all-mpnet-base-v2')

	def encode(self, X):
		embed = self.encoder.encode(X)
		embed = normalize(embed)
		return embed

class mReducer(Reducer):
	def __init__(self):
		super().__init__()
		self.ump = umap.UMAP(metric='cosine', random_state=200585)

	def fit(self, X):
		super().__init__()
		self.ump.fit(X)
		return self.ump.embedding_

	def transform(self, X):
		super().__init__()
		return self.ump.transform(X)

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

exhaustive_hdbscan-0.0.3.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

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

exhaustive_hdbscan-0.0.3-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file exhaustive_hdbscan-0.0.3.tar.gz.

File metadata

  • Download URL: exhaustive_hdbscan-0.0.3.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for exhaustive_hdbscan-0.0.3.tar.gz
Algorithm Hash digest
SHA256 31c6ae22a9c4d7f7fdb2c89104942d727957e71eb0a9d97430add445f50fbefe
MD5 390c4cc8182f915d7524ac94f5a6b305
BLAKE2b-256 3d90cf94e84048a565fb3d71919de1d0a858b13d173dfe2557cb88aaa2638a47

See more details on using hashes here.

File details

Details for the file exhaustive_hdbscan-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for exhaustive_hdbscan-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a8e9ca7c2c56766eb2be53958f4114144b2a0aea8f83f93cdb0a2c33ccb98b4c
MD5 c9d27c2c8341547202044b0a08f872dc
BLAKE2b-256 8e0b66ce47fdf6f4868b2e78b36dfe1798b69d5d639b205c384bedef456e0e8d

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