以下代码
plt.scatter(X[0, :], X[1, :], c=y, cmap=plt.cm.Spectral)
报错:
ValueError: RGBA sequence should have length 3 or 4
During handling of the above exception, another exception occurred:
......
ValueError: 'c' argument has 1 elements, which is not acceptable for use with 'x' with size 300, 'y' with size 300.
修改为:
import operator
from functools import reduce
plt.scatter(X[0, :], X[1, :], c=reduce(operator.add, y), cmap=plt.cm.Spectral)
即可解决