fuzzyclust.relational.make_categorical_blobs#

fuzzyclust.relational.make_categorical_blobs(n_samples=300, n_features=6, n_categories=4, n_clusters=3, noise=0.25, random_state=None, as_frame=True)[source]#

Categorical records scattered around planted modes.

Every cluster has a mode (one category per attribute); a record of the cluster copies the mode and then, independently per attribute with probability noise, replaces the category by a uniformly random one. Distinct clusters get distinct modes that differ in every attribute, so the matching dissimilarity between modes is n_features. The data mimic a survey in which groups of respondents share typical answers with individual deviations.

Parameters:
n_samplesint, default=300
n_featuresint, default=6
n_categoriesint, default=4

Categories per attribute (at least n_clusters).

n_clustersint, default=3
noisefloat, default=0.25

Probability that an entry is replaced by a uniformly random category. The random category can coincide with the mode, so an entry differs from the mode of its cluster with probability noise * (n_categories - 1) / n_categories.

random_stateint, RandomState instance or None
as_framebool, default=True

Return a pandas.DataFrame with string categories ("A", "B", …) and columns q1, q2, ...; with False an object ndarray.

Returns:
datasklearn.utils.Bunch

data – the records; target – cluster of every record; modes – the planted modes in the same format as data.

Examples

>>> from fuzzyclust.relational import make_categorical_blobs
>>> d = make_categorical_blobs(n_samples=50, n_features=4, random_state=0)
>>> d.data.shape, d.modes.shape, sorted(d.data.iloc[:, 0].unique())[:2]
((50, 4), (3, 4), ['A', 'B'])

Examples using fuzzyclust.relational.make_categorical_blobs#

Fuzzy k-modes on categorical survey data

Fuzzy k-modes on categorical survey data