【发布时间】:2020-05-22 15:33:02
【问题描述】:
import matplotlib.pyplot as plt
import matplotlib as cmap
from sklearn import datasets
from sklearn import svm
digits = datasets.load_digits()
clf = svm.SVC(gamma=0.001, C=100)
print(len(digits.data))
x, y = digits.data[:-1], digits.target[:-1]
clf.fit(x,y)
print('Prediction:', clf.predict(digits.data[[-1]]))
plt.imshow(digits.images[-1], cmap-plt.cm.gray_r, interpolation-"nearest")
plt.show()
在 python 3.8.3 中运行此代码时,我收到以下错误消息:
Traceback (most recent call last):
File "C:\Users\Aben\Downloads\pythonstuff\machinelearning.py", line 18, in <module>
plt.imshow(digits.images[-1], cmap-plt.cm.gray_r, interpolation-"nearest")
TypeError: unsupported operand type(s) for -: 'module' and 'LinearSegmentedColormap'
有人知道为什么吗? 我正在使用this 教程顺便说一句
【问题讨论】:
标签: python matplotlib machine-learning svm