Python 索引器:索引11超出大小为11的轴1的界限
请告诉我为什么会收到此错误消息,请: 索引器回溯(最后一次最近调用) 在 1#导入一些数据进行处理 第2列=列x所有值 ---->3 X=nd[:,[11,5]]#我们只考虑前两个特性。 4 Y=列车Y所有值 五, 索引器:索引11超出大小为11的轴1的界限Python 索引器:索引11超出大小为11的轴1的界限,python,Python,请告诉我为什么会收到此错误消息,请: 索引器回溯(最后一次最近调用) 在 1#导入一些数据进行处理 第2列=列x所有值 ---->3 X=nd[:,[11,5]]#我们只考虑前两个特性。 4 Y=列车Y所有值 五, 索引器:索引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 = tra
# 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“index 11”不是第12个元素吗?对于任何大小为11的集合,这都是不允许的。