Python SyntaxError:无效语法[plt.scatter]
我准备了一个多项式回归模型,一切似乎都很好,只是matplotlib有问题!我不知道到底是怎么回事!代码如下:Python SyntaxError:无效语法[plt.scatter],python,matplotlib,Python,Matplotlib,我准备了一个多项式回归模型,一切似乎都很好,只是matplotlib有问题!我不知道到底是怎么回事!代码如下: plt.scatter(X,y,color='Red') plt.plot(X , lin_reg.predict(X),color='Blue') plt.title('Truth') plt.xlabel('Position') plt.ylabel('Salary') plt.show() 下面是错误:--- 文件“”,第3行 plt.散射(X,y,color='Red') ^
plt.scatter(X,y,color='Red')
plt.plot(X , lin_reg.predict(X),color='Blue')
plt.title('Truth')
plt.xlabel('Position')
plt.ylabel('Salary')
plt.show()
下面是错误:---
文件“”,第3行
plt.散射(X,y,color='Red')
^
SyntaxError:无效语法
根据文档,重塑
至少接收2个参数(您只提供了一个):
除了同意不应该粘贴代码图像(复制粘贴代码是同一个过程),您在标题中描述的错误并不是您显示的错误<代码>np。重塑需要两个参数,要重塑的数组和新的形状,您只提供了一个,它已解释为原始数组。该错误消息与
plt
或无效语法无关。请在前一行计算括号。
File "<ipython-input-15-697418dc1afd>", line 3
plt.scatter( X,y,color='Red')
^
SyntaxError: invalid syntax
numpy.reshape(a, newshape, order='C')
where:
- a : array_like
Array to be reshaped.
- newshape : int or tuple of ints
The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.