HYR*_*YRY 18
你可以使用numpy.random.shuffle
import numpy as np
N = 4601
data = np.arange(N*58).reshape(-1, 58)
np.random.shuffle(data)
a = data[:int(N*0.6)]
b = data[int(N*0.6):int(N*0.8)]
c = data[int(N*0.8):]
Run Code Online (Sandbox Code Playgroud)
如果你想要使用相同的第一维来一致地改组几个数组x,y,z,那么这是对HYRY答案的补充:x.shape[0] == y.shape[0] == z.shape[0] == n_samples
.
你可以做:
rng = np.random.RandomState(42) # reproducible results with a fixed seed
indices = np.arange(n_samples)
rng.shuffle(indices)
x_shuffled = x[indices]
y_shuffled = y[indices]
z_shuffled = z[indices]
Run Code Online (Sandbox Code Playgroud)
然后按照HYRY的回答继续进行每个混洗数组的拆分.