Friedman generators: the three classic regression benchmarks.
Implements Friedman's three test functions, which combine sine, square, and reciprocal terms so that no linear model fits them well. Extra features beyond those the function reads are pure noise, so the generators also measure how well a model ignores irrelevant inputs.
Classes
Friedman regression data generator.
Generates data using one of the Friedman benchmark functions. These are standard test functions for regression algorithms.
Functions:
- 1: y = 10 \sin(\pi x_1 x_2) + 20(x_3 - 0.5)^2 + 10 x_4 + 5 x_5
- 2: y = \sqrt{x_1^2 + (x_2 x_3 - 1/(x_2 x_4))^2}
- 3: y = \arctan((x_2 x_3 - 1/(x_2 x_4)) / x_1)
Constructor
__init__( self, n_samples: int = 100, n_features: int = 10, function: int = 1, noise: float = 0.0, random_state: Optional[int] = None, )
Parameters
n_samples
int
= 100
Number of samples to generate.
n_features
int
= 10
Number of features (minimum 5 for function 1, 4 for 2&3).
function
int
= 1
Friedman function (1, 2, or 3).
noise
float
= 0.0
Standard deviation of Gaussian noise.
random_state
int or None
= None
Random seed for reproducibility.
python
>>> from tuiml.datasets.generators.regression import Friedman
>>> gen = Friedman(n_samples=1000, function=1, noise=1.0, random_state=0)
>>> data = gen.generate()
>>> data.X.shape # only the first 5 features matter
(1000, 10)