-1

I have the IRIS Dataset loaded fro text file -

data = np.genfromtxt('../Data/bezdekIris.csv',delimiter=',',usecols=[0,1,2,3,4],dtype=None)

this has the data in the format

ndarray [(5.1, 3.5, 1.4, 0.2, 'Iris-setosa') 
 (4.9, 3. , 1.4, 0.2, 'Iris-setosa')
 (4.7, 3.2, 1.3, 0.2, 'Iris-setosa') 
 (4.6, 3.1, 1.5, 0.2, 'Iris-setosa')
 (5. , 3.6, 1.4, 0.2, 'Iris-setosa')]

How do I randomize the order

Prateek Narendra
  • 1,837
  • 5
  • 38
  • 67
  • You can use `np.random.shuffle(data)`, be carful this function doesn't return anything, shuffling is made on data. – rockikz Sep 27 '18 at 08:30

1 Answers1

0
import numpy as np

np.random.seed(12345) # For repeatable results
np.random.shuffle(data)

Shuffling is done in place.

lightalchemist
  • 10,031
  • 4
  • 47
  • 55