plt.scatter中参数 c 需要的是一维数组,所以需要转化一下
plt.scatter(X[:, 0], X[:, 1], c=labels.flatten(), s=100, cmap='viridis')
否则会出现这样的错误:
ValueError: 'c' argument has 200 elements, which is not acceptable for use with 'x' with size 200, 'y' with size 200.
plt.scatter中参数 c 需要的是一维数组,所以需要转化一下
plt.scatter(X[:, 0], X[:, 1], c=labels.flatten(), s=100, cmap='viridis')
否则会出现这样的错误:
ValueError: 'c' argument has 200 elements, which is not acceptable for use with 'x' with size 200, 'y' with size 200.