Explain the difference between np.arange and np.linspace. Give examples
?

arange:

the difference between arange and linspace is that arange gets all values between start and stop with defined stepsize, while np.linspace gets a defined number of values. linspace infers the step size

{python} np.arange(start=0, stop=10, step=1)

it stops before the stop value.

example:
{python} np.arange(0, 10, 2) # [0 2 4 6 8]

linspace

As mentioned above, linspace infers the stepsize

{python} np.linspace(start=0, stop=10, num=20)

Note: set {python}endpoint=False if you don't want the endpoint.

Dataset generation

When working with neural networks, we want to test them using dummy data. This has the following goals:

  1. Make sure the model can handle the input data shape
    Note that this can be achieved by generating truly random data Random Number Generation.
  2. Make sure the model is able to detect basic data dependencies.
    This is where we require more complex data generation functions, where the data isn't random anymore.

https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_classification.html



</div></div>

<!--SR:!2025-08-19,137,250-->