lundi 20 avril 2015

Generate random sparse matrix filled with only values 0 or 1

I'm trying to generate a random csr_matrix using SciPy but I need it to only be filled with values 0 or 1.

So far I'm trying to use:

rand(1000, 10, density=0.2, format='csr', random_state=np.random.randint(0, 2))

and I get the correct structure and density I want, but the values filling it are floats between 0 and 1.

Is there a way to generate this structure with just floats of 0 or 1?




Aucun commentaire:

Enregistrer un commentaire