Sine generator: periodic targets with adjustable shape.
Evaluates a sine wave whose amplitude, frequency, phase, and offset are all free parameters, summing one wave per feature. Useful for exercising models on smooth periodic signals and, with noise added, for illustrating overfitting.
Classes
Sine wave data generator.
Generates data using a sine function:
y = A \sin(2\pi f x + \phi) + c
where A is amplitude, f is frequency, \phi is phase, and c is offset.
For multiple features, the output is the sum of sine waves.
Constructor
__init__( self, n_samples: int = 100, n_features: int = 1, amplitude: float = 1.0, frequency: float = 1.0, phase: float = 0.0, offset: float = 0.0, noise: float = 0.0, random_state: Optional[int] = None, )
Parameters
n_samples
int
= 100
Number of samples to generate.
n_features
int
= 1
Number of features.
amplitude
float
= 1.0
Amplitude of sine wave.
frequency
float
= 1.0
Frequency of sine wave.
phase
float
= 0.0
Phase shift (radians).
offset
float
= 0.0
Vertical offset.
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 Sine
>>> gen = Sine(n_samples=1000, frequency=2.0, noise=0.1, random_state=0)
>>> data = gen.generate()
>>> data.X.shape
(1000, 1)