error 1:
# plt.scatter(X[0,:],X[1,:],c=np.squeeze(Y),s=40,cmap=plt.cm.Spectral)
plt.scatter(X[0, :], X[1, :], c=Y, s=40, cmap=plt.cm.Spectral)
ans:第二行应换为第一行
c of shape (1, 300) not acceptable as a color sequence for x with size 300, y with size 300
遇到类似类型不匹配的问题,也是这样得解法,只不过当你更改后,记得保存哦,特别在jupyter notebook下编译的时候记得点下kernel下面的restart 就是重启内核
error 2:
DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
y = column_or_1d(y, warn=True)
ans:
y=Y.ravel() 应该添加上这句话