返回所选测试集的索引Python

问题描述

我正在尝试获取测试数据选择的数据的索引。首先,我将train-test-split用于数据

A = [[1,2],[3,4],[6,4]]
y = [1,1]

from sklearn.model_selection import train_test_split
A_train,A_test,y_train,y_test = train_test_split(A,y,test_size=0.3,random_state=1)

A_test
>> [[3,2]]

但是,如何获取A中A_test的索引?例如,在这种情况下,它应该返回3、4。非常感谢!

解决方法

只需在Content-Type: text/csv;charset=utf-8;header=presentrange(len(A))上方使用A

y