fuzzyclust: fuzzy clustering and data analysis in Python#

fuzzyclust

fuzzyclust is a scikit-learn compatible toolbox for fuzzy clustering and the data-analysis methods built on it. It succeeds the Fuzzy Clustering and Data Analysis Toolbox for MATLAB (Balaskó, Abonyi and Feil) and collects the clustering-based methods developed in the Abonyi group over two decades: model identification, time-series segmentation, visualization of fuzzy clusters and graph-based clustering, together with the possibilistic, noise, kernel and shape-prototype variants of fuzzy c-means and methods for relational, incomplete, very large and image data.

Core algorithms

K-means, k-medoids, fuzzy c-means, Gustafson–Kessel and Gath–Geva on one alternating-optimization template; generalized fuzzifiers, subtractive clustering, cluster merging.

fuzzyclust.cluster
Validity

Sixteen validity indices, scans over the number of clusters, fuzzy Rand indices and stability-based selection.

fuzzyclust.validity
Robust and shape prototypes

Possibilistic and noise clustering, kernel FCM, c-varieties, c-shells, volume prototypes and feature weighting.

fuzzyclust.extensions
Graph-based clustering

Minimal-spanning-tree hybrids and geodesic-distance fuzzy c-medoids.

fuzzyclust.graph
Visualization

PCA, Sammon and fuzzy Sammon mapping, projection quality, fuzzy SOM.

fuzzyclust.viz
Models and time series

Takagi–Sugeno identification, fuzzy classifiers, regression trees, segmentation, model order, chaotic prediction.

fuzzyclust.models
Relational and mixed data

Relational FCM, NERF c-means, fuzzy c-medoids, fuzzy k-modes and k-prototypes; DTW, autocorrelation and Gower dissimilarities.

fuzzyclust.relational
Incomplete, large and image data

FCM with missing values; weighted, sampling, single-pass and online FCM; spatial FCM variants for image segmentation.

fuzzyclust.incomplete
Beyond one unsupervised run

Partial supervision, pairwise constraints, co-clustering, collaborative clustering and cluster ensembles.

fuzzyclust.semisupervised

Quick start#

pip install fuzzyclust
from fuzzyclust.cluster import GK
from fuzzyclust.datasets import make_fuzzy_blobs
from fuzzyclust.plotting import plot_clusters, plot_membership_contours

X, _ = make_fuzzy_blobs(n_clusters=3, random_state=0)
gk = GK(n_clusters=3, m=2.0, random_state=0).fit(X)

gk.membership_        # fuzzy partition matrix, shape (n_samples, n_clusters)
gk.cluster_centers_   # prototypes
gk.covariances_       # fuzzy covariance matrices of the GK clusters
gk.predict_proba(X)   # memberships of (new) samples

ax = plot_clusters(X, gk.labels_, gk.cluster_centers_)
plot_membership_contours(gk, X, ax=ax)

Every estimator is a scikit-learn estimator: it accepts NumPy arrays or pandas DataFrames, works inside a Pipeline, and exposes its results as fitted attributes.

Where to go next#

  • Installation: requirements and optional extras.

  • Example gallery: the example gallery: one runnable script per algorithm, each generating its own data, explaining the method and the effect of its parameters. Every example can be downloaded as a Jupyter notebook.

  • The book: the book Fuzzy Clustering and Data Analysis in Python: theory with a unified notation, algorithm boxes and the same examples.

  • API reference: the API reference.

  • Migrating from the MATLAB toolbox: coming from the MATLAB toolbox.