"Sklearn TypeError: init() got an unexpected keyword argument tol"

2024-05-16 04:23:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我安装了sklearn版本0.18.1。我收到这个错误消息。最近重新安装了水蟒。我试着运行这个:

   sgd = SGDClassifier(tol=1e3,max_iter=100,penalty='elasticnet',class_weight='balanced',shuffle=True)
   pipeline = make_pipeline(cv, tfidf, sgd)

TypeError: init() got an unexpected keyword argument 'tol'


Tags: 版本消息pipeline错误sklearnmaxclassweight
2条回答

正如sgdclassifier所说,这是意料之中的:

tol : float or None, optional The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol). Defaults to None. Defaults to 1e-3 from 0.21.

New in version 0.19.

所以如果使用0.18.1,那么它可能无法识别它。在

因为它是在版本0.19中引入的。这是他们在sklearn的documentation中提到的地方-

tol : float or None, optional The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol). Defaults to None. Defaults to 1e-3 from 0.21.

New in version 0.19.

编辑:
This是您的sklearn版本的文档。在

相关问题 更多 >