biomedical_data_generator.generate_dataset
- biomedical_data_generator.generate_dataset(cfg, return_dataframe=True)[source]
Generate synthetic biomedical dataset with specified feature structure.
Creates a classification dataset with configurable informative features, noise, correlated feature clusters (e.g., biological pathways), and optional batch effects.
- Parameters:
cfg (DatasetConfig) – Configuration object defining the dataset structure. See
DatasetConfigfor details.return_dataframe (bool) – If
True, return features as apandas.DataFramewith named columns. IfFalse, return as a NumPy array.
- Returns:
A 3-tuple containing:
x (
pandas.DataFrameornumpy.ndarray): Feature matrix of shape(n_samples, n_features). Each row represents one sample (e.g., patient), each column represents one feature (e.g., biomarker, gene expression value). When returned as DataFrame, column names depend oncfg.prefixed_feature_naming: whenTrue(default), names use type-based prefixes (cfg.prefix_informativefor informative features,cfg.prefix_corrfor correlated clusters,cfg.prefix_noisefor noise), yielding names likei1, corr1_anchor, n1. WhenFalse, names use sequential numberingfeature_1, feature_2, ....y (
numpy.ndarray): Class labels of shape(n_samples,)with integer values0, 1, ..., n_classes-1.meta (
DatasetMeta): Metadata object containing feature masks (informative, correlated, noise, batch-specific), correlation block specifications, batch assignments, and complete generation configuration.
- Return type:
Examples
>>> from biomedical_data_generator.config import ( ... DatasetConfig, ClassConfig, StandaloneInformativeGroup ... ) >>> data_cfg_1 = DatasetConfig( ... standalone_informative_groups=[ ... StandaloneInformativeGroup(n_features=5, class_sep=1.0) ... ], ... n_standalone_noise=10, ... class_configs=[ClassConfig(n_samples=100, label="healthy"), ... ClassConfig(n_samples=100, label="diseased")], ... random_state=42 ... ) >>> x1, y1, meta_data1 = generate_dataset(data_cfg_1)