+4 votes
in Machine Learning by (29.6k points)
I want to generate random binary labels (0/1) for the randomly generated data. Which Python function should I use?

1 Answer

+3 votes
by (51.1k points)

You can use Numpy's random() function to generate random numbers between 0 and 1 and then apply the round() function to those numbers to get binary labels.

Here is an example to generate 10 binary labels.

train_labels = np.round(np.random.random(10))


...