Python实现将数据集分割成测试集(test)和训练集(training)

利用程序将数据集自动分为测试集(test datasets)和训练集(training datasets)

# Split data into training and validation datasets
indices = np.random.permutation(train.shape[0])
valid_cnt = int(train.shape[0] * 0.1)#可自行修改比例
test_idx,training_idx=indices[:valid_cnt],indices[valid_cnt:]
test, train = train[test_idx,:], train[training_idx,:]
onehot_test, onehot_train = onehot[test_idx,:], onehot[training_idx,:]

你可能感兴趣的:(Python)