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 isn_features. The data mimic a survey in which groups of respondents share typical answers with individual deviations.- Parameters:
- n_samples
int, default=300 - n_features
int, default=6 - n_categories
int, default=4 Categories per attribute (at least
n_clusters).- n_clusters
int, default=3 - noise
float, 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_state
int,RandomStateinstanceorNone - as_framebool, default=True
Return a
pandas.DataFramewith string categories ("A","B", …) and columnsq1, q2, ...; withFalsean object ndarray.
- n_samples
- Returns:
- data
sklearn.utils.Bunch data– the records;target– cluster of every record;modes– the planted modes in the same format asdata.
- 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'])