我们一般都用Scikit-learn的train_test_split来划分训练集和测试集, 但是有一个问题就是train_test_split并不返回训练集(或测试集)的索引, 这样的话有时候会比较麻烦.
其实我们可以曲线救国, 往函数里传一个有序的索引就好了, 函数也会把这个给划分掉.比如:
indices = np.arange(x.shape[0]) # help for check the index after split [x_train, x_test, indices_train, indices_test] = train_test_split(x, y, indices, test_size=0.2)
这样我们查看indices_train就可以轻松知道划分的x_train在之前数据集里的索引是什么了.



