擅长:python、mysql、java
<p>如果您想用相同的第一维连续地洗牌多个数组x,y,z,HYRY的答案的一个补充:<code>x.shape[0] == y.shape[0] == z.shape[0] == n_samples</code>。</p>
<p>你可以:</p>
<pre><code>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]
</code></pre>
<p>然后像海瑞的回答那样,对每个洗牌数组进行分割。</p>