ValueError:查询数据维度必须与培训数据维度匹配
我应该如何纠正错误
X_列2的形状为(4292,95),Y_列2的形状为(4292,)。 以下是我编写的代码:
X_train2 = X_train1.to_numpy()
y_train2 = y_train1.to_numpy()
fig, axes = plt.subplots(1, 3, figsize=(10,3))
for n_neighbors, ax in zip([1 ,3 ,9], axes):
knMod = KNeighborsClassifier(n_neighbors=n_neighbors)
knMod.fit(X_train1, y_train1)
mglearn.plots.plot_2d_separator(knMod, X_train2, fill=True, eps=0.5, ax=ax, alpha=.4)
mglearn.discrete_scatter(X_train2[:, 0], X_train2[:, 95], y_train2, ax=ax)
ax.set_title("{}KNN".format(n_neighbors))
ax.set_xlabel("feature 0")
ax.set_ylabel("feature 1")
axes[0].legend(loc=3)
这是错误代码,返回了以下消息:
Traceback (most recent call last):
File "<ipython-input-28-694c4077b877>", line 1, in <module>
plot_decision_regions(X_train2, y_train2, LR, "Logistic")
File "C:\Users\duddu\Anaconda3\lib\site-packages\mlxtend\plotting\decision_regions.py", line 163, in plot_decision_regions
'Unable to unpack feature_index. Make sure feature_index '
ValueError: Unable to unpack feature_index. Make sure feature_index only has two dimensions.
目前没有回答
相关问题 更多 >
编程相关推荐