qbiocode.data_generation.make_moons module#
Generate synthetic two-moons datasets for binary classification tasks.
This module creates multiple configurations of 2D two-moons datasets with varying sample sizes and noise levels, useful for testing machine learning algorithms on non-linearly separable data with interleaving classes.
Summary#
Functions:
Generate multiple two-moons datasets with varying parameters. |
Reference#
- generate_moons_datasets(n_samples=[100, 120, 140, 160, 180, 200, 220, 240, 260, 280], noise=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9], save_path=None, random_state=42)[source]#
Generate multiple two-moons datasets with varying parameters.
Creates a series of 2D datasets where samples form two interleaving half-circles (moons), providing a challenging non-linearly separable binary classification problem. Each configuration varies the number of samples and noise level.
- Parameters:
n_samples (list of int, default=range(100, 300, 20)) – List of sample sizes to generate for each configuration.
noise (list of float, default=[0.1, 0.2, ..., 0.9]) – List of noise standard deviations to apply to the data.
save_path (str, optional) – Directory path where datasets and configuration files will be saved.
random_state (int, default=42) – Random seed for reproducibility.
- Returns:
Saves CSV files for each dataset configuration and a JSON file with all configuration parameters.
- Return type:
None
Notes
Each dataset is saved as ‘moons_data-{i}.csv’ where i is the configuration number
Configuration parameters are saved in ‘dataset_config.json’
The last column ‘class’ contains binary labels (0 or 1)
Two-moons datasets are commonly used to evaluate algorithms on interleaving patterns
Examples
>>> from qbiocode.data_generation import generate_moons_datasets >>> generate_moons_datasets(n_samples=[100, 200], noise=[0.1, 0.3], save_path='data') Generating moons dataset...