报错如图所示

ValueError: c of shape (1, 300) not acceptable as a color sequence for x with size 300, y with size 300

源码一般情况下,水平有限,不敢乱动,找到相应的报错路径,将代码

plt.scatter(X[0, :], X[1, :], c=y, cmap=plt.cm.Spectral)
改成:
plt.scatter(X[0, :], X[1, :], c= np.squeeze(y), cmap=plt.cm.Spectral)
即可


相关文章: