Skip to content

Base

Base class for clustering algorithms

ClusterMethod

Bases: StrEnum

An enum class to identify the cluster algorithm that produced a result.

BUTINA = 'butina'

LEADER = 'leader'

MMSEQS2 = 'mmseqs2'

ClusterParams()

Bases: ABC

Abstract base for a method's configuration.

method

ClusterResult(labels, representatives, params)

The standardized output every clusterer returns.

labels

dictionary with the keys being the items id (e.g. cids) and the values is their cluster id.

method

The algorithm generated this result.

n_clusters

Number of distinct clusters.

params

The params object holding the metadata the clustering algorithm ran with.

representatives

dictionary with the keys being the cluster id and the value is the id of the cluster representative id

__post_init__()

clusters()

Converts the labels into a dictionary of clusters with the cluster id as the key and the cluster members as the value.

Clusterer(params)

Bases: ABC

Abstract base class for all clustering algorithms.

PARAMETER DESCRIPTION
params

The ClusterParams object containing the configuration for the clustering algorithm.

TYPE: ClusterParams

method

The algorithm this clustering method implements.

params = params

cluster(items)

Abstract cluster method that must be implemented by subclasses.

PARAMETER DESCRIPTION
items

A dictionary where the keys are stable identifiers (e.g., cids) and the values are the items to be clustered.

TYPE: dict[str, object]