请告诉我为什么我会收到此错误消息:
IndexError Traceback(最近一次通话)在1#导入一些要播放的数据第二名= train_x_all.values----> 3 X = nd [:,[11,5]]#我们仅采用前两个特征。4 Y = train_y_all.values5
IndexError:索引11超出了尺寸为11的轴1的范围
# import some data to play with
nd = train_x_all.values
X = nd[:,[11,5]] # we only take the first two features.
Y = train_y_all.values
logreg = LogisticRegressionCV(cv=10)
# Create an instance of Logistic Regression Classifier and fit the data.
logreg.fit(X, Y)
x_min, x_max = X[:,0].min() - 1, X[:,0].max() + 1
y_min, y_max = X[:,1].min() - 1, X[:,1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max,0.1),
np.arange(y_min,y_max, 0.1))
Z = logreg.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)
plt.plot()
plt.contourf(xx, yy, Z, alpha=0.4, cmap = plt.cm.RdYlBu)
plt.scatter(X[:, 0], X[:, 1], c=Y, cmap = plt.cm.brg)
plt.title("Logistic Regression")
plt.xlabel("FamilyN")
plt.ylabel("Fare")
plt.legend(Y)
plt.show()
Python基于0,因此如果列表的大小为11,则其最大索引为10