我正在尝试在 scikit-learn 中使用一种算法来根据多个输入来预测输出。我似乎收到错误“索引过多”返回,但无法弄清楚原因。
CSV 文件培训:
1.1 0.2 0.1 0 0.12 0.1
1.4 0.2 0.1 0.1 0.14 0.1
0.1 0.1 0.1 0 0.26 0.1
24.5 0.1 0 0.1 0.14 0.1
0.1 0.1 0.1 0 0.25 0.1
代码:
fileCSVTraining = genfromtxt('TrainingData.csv', delimiter=',', dtype=None)
#Define first 6 rows of data as the features
t = fileCSVTraining[:, 6:]
#Define which column to put prediction in
r = fileCSVTraining[:, 0-6:]
#Create and train classifier
x, y = r, t
clf = LinearSVC()
clf = clf.fit(x, y)
#New data to predict
X_new = [1.0, 2.1, 3.0, 2.4, 2.1]
b = clf.predict(X_new)
错误:
t = fileCSVTraining[:, 6:]
IndexError: too many indices