《机器学习实战》笔记:第8章,ValueError: x and y must be the same size

>>> yMat = xMat*ws
>>> import matplotlib.pyplot as plt
>>> fig =plt.figure()
>>> ax =fig.add_subplot(111)
>>> ax.scatter(xMat[:,1].flatten().A[0],yMat.T[:,0].flatten().A[0])
Traceback (most recent call last):
  File "", line 1, in
    ax.scatter(xMat[:,1].flatten().A[0],yMat.T[:,0].flatten().A[0])
  File "D:\Python\Python36-32\lib\site-packages\matplotlib\__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "D:\Python\Python36-32\lib\site-packages\matplotlib\axes\_axes.py", line 3955, in scatter
    raise ValueError("x and y must be the same size")

ValueError: x and y must be the same size

经测试,scatter的两个参数大小不一样:

>>> len(xMat[:,1].flatten().A[0]);len(yMat.T[:,0].flatten().A[0])

200

1

重新操作之前的步骤后正常:

>>> len(xMat[:,1])
200
>>> len(yMat.T[:,0])
200

你可能感兴趣的:(Python)