+4 votes
in Machine Learning by (77.2k 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 (354k points)
selected by
 
Best answer

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))


...