I have the following code which is giving error *"TypeError: 'numpy.float64' object cannot be interpreted as an integer*". The error is thrown by the statement "**np.random.choice(pos_of_1, how_many_to_change)**"

how_many_to_change = np.sum(Y)/2 #half of class 1 needs to be changed

pos_of_1 = np.where(Y==1)[0] #np.where gives tuple. 1st elemetn is an np array

print (len(pos_of_1))

random_indices = np.random.choice(pos_of_1, how_many_to_change) #randomly select half of them