【发布时间】:2019-02-07 13:34:01
【问题描述】:
我正在使用 python 2.7。 SVC 的文档。
当我尝试以下操作时:
from sklearn.svm import SVC
base_learner = SVC(random_state=4,probability=True)
它会抛出以下错误:
TypeError: Argument 'kernel' has incorrect type (expected str, got unicode)
所以我想我会试试这个:
from builtins import str
from sklearn.svm import SVC
base_learner = SVC(kernel=str('rbf'), random_state=4,probability=True)
仍然无法识别内核。我做错了什么?
【问题讨论】:
-
我无法在只有 Python 2.7.15 和 scikit-learn 0.19.1 的 conda 环境中重现此问题。你是如何安装 scikit-learn 的;通过 Anaconda?
标签: python string python-2.7 scikit-learn python-unicode