Base classes for synthetic data generators.
Data generators create synthetic datasets for testing and benchmarking machine learning algorithms. Concrete generators subclass one of the task-specific bases (
ClassificationGenerator, RegressionGenerator, ClusteringGenerator) and implement generate().Classes
Container for generated data.
Attributes
X
np.ndarray of shape (n_samples, n_features)
Generated feature matrix.
y
np.ndarray of shape (n_samples,)
Generated targets (labels, values, or cluster assignments).
feature_names
list of str
Names of the generated features.
target_names
list of str
Names of the target classes or outputs.
Abstract base class for data generators.
Data generators create synthetic datasets for testing and benchmarking machine learning algorithms.
Constructor
__init__( self, n_samples: int = 100, n_features: int = 2, random_state: Optional[int] = None, )
Parameters
n_samples
int
= 100
Number of samples to generate.
n_features
int
= 2
Number of features.
random_state
int
Random seed for reproducibility.
Methods
__call__
(self, return_X_y: bool=False) -> Union[GeneratedData, Tuple[np.ndarray, np.ndarray]]
__call__
(self, return_X_y: bool=False) -> Union[GeneratedData, Tuple[np.ndarray, np.ndarray]]
Generate data by calling the generator directly.
Parameters
return_X_y
bool
= False
If True, return an
(X, y) tuple instead of GeneratedData.
Returns
data
GeneratedData or tuple of (np.ndarray, np.ndarray)
The generated dataset, either as a container or as
(X, y).
Base class for classification data generators.
Constructor
__init__( self, n_samples: int = 100, n_features: int = 2, n_classes: int = 2, random_state: Optional[int] = None, )
Parameters
n_samples
int
= 100
Number of samples to generate.
n_features
int
= 2
Number of features.
n_classes
int
= 2
Number of classes.
random_state
int
Random seed for reproducibility.
Base class for regression data generators.
Constructor
__init__( self, n_samples: int = 100, n_features: int = 2, noise: float = 0.0, random_state: Optional[int] = None, )
Parameters
n_samples
int
= 100
Number of samples to generate.
n_features
int
= 2
Number of features.
noise
float
= 0.0
Standard deviation of Gaussian noise added to the targets.
random_state
int
Random seed for reproducibility.
Base class for clustering data generators.
Constructor
__init__( self, n_samples: int = 100, n_features: int = 2, n_clusters: int = 3, random_state: Optional[int] = None, )
Parameters
n_samples
int
= 100
Number of samples to generate.
n_features
int
= 2
Number of features.
n_clusters
int
= 3
Number of clusters.
random_state
int
Random seed for reproducibility.