Use np.random.permutation!
np.random.permutation
import numpy as np X = np.array(data) y = np.array(target) perm = np.random.permutation(len(X)) X = X[perm] y = y[perm]