data = rng.rand(n_sample) * len_data - len_data / 2
noise = rng.randn(n_sample) * .3
target = data ** 3 - 0.5 * data ** 2 + noise
can you explain what each line do and why ?
data = rng.rand(n_sample) * len_data - len_data / 2
noise = rng.randn(n_sample) * .3
target = data ** 3 - 0.5 * data ** 2 + noise
can you explain what each line do and why ?
Well, from the docs:
rand(n_samples) gives you an array of n_sample random numbers between 0 and 1, evenly distributed.
The first creates an array for the data and scales it to the interval [- len_data/2,len_data/2].
The second line uses randn, this gives noise with a normal distribution around 0. it is multiplied by 0.3 to scale the standard deviation from 1 to 0.3.
The third line defines the target as a third grade polynomial of the data variable and added noise.