下面是我的代码
filename = 'train4.csv'
names = ['attribut names are here']
dataframe = read_csv(filename, names=names)
array = dataframe.values
X = array[:,0:47]
Y = array[:,47]
num_folds = 10
kfold = KFold(n_splits=10, random_state=7)
model = KNeighborsClassifier()
results = cross_val_score(model, X, Y, cv=kfold)
print(results.mean())
我得到了错误
>IndexError Traceback (most recent call last)
<ipython-input-19-8d9596c3368b> in <module>()
4 array = dataframe.values
5 X = array[:,0:47]
----> 6 Y = array[:,47]
7 num_folds = 10
8 kfold = KFold(n_splits=10, random_state=7)
> IndexError: index 47 is out of bounds for axis 1 with size 47
在我的CSV中,第47个属性是目标标签-因此是48(我错了吗?)。
我正在Jupyter笔记本上运行pandas/sklearn。
谢谢