Blobs generator: isotropic Gaussian clusters.

Samples points from spherical Gaussians placed at random or caller-supplied centers. Cluster count, spread, and dimensionality are all adjustable, which makes it the usual first sanity check for a clustering algorithm.

Classes

Blobs

class datasets.generators.clustering.blobs.Blobs(ClusteringGenerator)

Gaussian Blobs data generator.

Generates data from isotropic Gaussian distributions (blobs). This is a common test case for clustering algorithms.
Constructor
__init__(
    self,
    n_samples: int = 100,
    n_features: int = 2,
    n_clusters: int = 3,
    cluster_std: Union[float, List[float]] = 1.0,
    centers: Optional[np.ndarray] = None,
    center_box: tuple = (),
    shuffle: bool = True,
    random_state: Optional[int] = None,
)

Parameters

n_samples
int = 100
Number of samples to generate (total or per cluster).
n_features
int = 2
Number of features (dimensions).
n_clusters
int = 3
Number of clusters (blobs).
cluster_std
float or list of float = 1.0
Standard deviation of clusters.
centers
np.ndarray or None = None
Array of cluster centers (optional).
center_box
tuple, 10.0) = (-10.0
Bounding box for randomly generated centers.
shuffle
bool = True
Whether to shuffle the samples.
random_state
int or None = None
Random seed for reproducibility.
python
>>> from tuiml.datasets.generators.clustering import Blobs
>>> gen = Blobs(n_samples=1000, n_clusters=4, random_state=0)
>>> data = gen.generate()
>>> data.X.shape
(1000, 2)
>>> X, y = gen(return_X_y=True)   # same data as plain arrays

Methods

generate (self) -> GeneratedData

Generate Gaussian blobs.

Returns
GeneratedData
Generated dataset with feature array X of shape (n_samples, n_features) and cluster labels y.
get_parameter_schema (cls) -> Dict[str, Any]

Return JSON Schema for constructor parameters.