TypeError: only integer scalar arrays can be converted to a scalar index

如
for i, (train, test) in enumerate(kf.split(data)):   # 将训练集的?条数据划分为5份
    tra = np.array(data)[train]
    tst = np.array(data)[test]

产生错误:TypeError: only integer scalar arrays can be converted to a scalar index

解决:将List转换为numpy数组

改成:

for i, (train, test) in enumerate(kf.split(data)):   # 将训练集的条数据划分为5份
    tra = np.array(data)[train]
    tst = np.array(data)[test]

你可能感兴趣的:(TypeError: only integer scalar arrays can be converted to a scalar index)