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.

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.2.tar.gz (20.1 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.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: exhaustive_hdbscan-0.0.2.tar.gz
  • Upload date:
  • Size: 20.1 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.2.tar.gz
Algorithm Hash digest
SHA256 e559b516e1cfc25f59dde4a7390efe6d4c282787f00f7d6e961c981736135e09
MD5 4308fbe28b2043d357cba1d1e401a638
BLAKE2b-256 65447296df211eb1caae47ce3b91bb04d2705047fb84aedfc02d1eba2acd6879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for exhaustive_hdbscan-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e62bd6987663582dcf713bdaf709f97fdf8f82e4a8974b979bc9d904616de4fc
MD5 d0f47f870ebbecbfbe258005e17af93c
BLAKE2b-256 e807f0bbd3361a3df9fafcfd2bc45e8fbbc6a71623c0dfdb107ad10dfa8fa30c

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