我是机器学习的初学者,我在 pyplot 的分散方法中遇到了颜色错误,“s=None”参数也出现了同样的错误
pyplot.scatter = (X_train, y_train, c = 'red')
pyplot.plot = (X_train, regressor.predict(X_train), c = 'blue')
我收到此错误
plt.scatter = (X_train, y_train, c = 'red')
^
SyntaxError: invalid syntax
如何消除此错误以及何时将“color = 'red'”替换为“c = 'red'”?
最佳答案
您必须删除=
:
pyplot.scatter(X_train, y_train, c = 'red')
pyplot.plot(X_train, regressor.predict(X_train), c = 'blue')
PS。
按照惯例,通常以这种方式导入 matplotlib
库:
import matplotlib.pyplot as plt
plt.scatter(X_train, y_train, c = 'red')
关于python - pyplot.scatter(c ='red')。无效的语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50961057/