Python 为什么此参数在sklearn'中无效;s管道?
下面的代码出现以下错误,但无法找出我的参数无效的原因Python 为什么此参数在sklearn'中无效;s管道?,python,machine-learning,scikit-learn,Python,Machine Learning,Scikit Learn,下面的代码出现以下错误,但无法找出我的参数无效的原因SelectFromModel是管道中的有效输入,因为它具有拟合和变换功能 ValueError: Invalid parameter sfm_threshold for estimator Pipeline. Check the list of available parameters with `estimator.get_params().keys()` 当我运行pipe\u lr.get_params().keys()时,我得到了以
SelectFromModel
是管道中的有效输入,因为它具有拟合和变换功能
ValueError: Invalid parameter sfm_threshold for estimator Pipeline.
Check the list of available parameters with
`estimator.get_params().keys()`
当我运行pipe\u lr.get_params().keys()
时,我得到了以下输出,它实际上包括sfm\u threshold
,我完全按照原样复制和粘贴了它
['std__with_mean',
'sfm__estimator__precompute',
'lr__n_jobs',
'sfm__prefit',
'poly',
'sfm__threshold',
'sfm__estimator__cv',
'sfm__estimator__max_iter',
'sfm__estimator__positive',
'sfm__estimator__n_alphas',
'std__with_std',
'sfm__estimator__random_state',
'std__copy',
'lr__normalize',
'sfm__estimator__copy_X',
'lr',
'sfm__estimator__n_jobs',
'poly__interaction_only',
'sfm__estimator__fit_intercept',
'sfm__estimator__tol',
'sfm__estimator',
'sfm__estimator__verbose',
'sfm',
'sfm__estimator__normalize',
'std',
'sfm__estimator__selection',
'poly__degree',
'lr__copy_X',
'sfm__estimator__alphas',
'lr__fit_intercept',
'steps',
'poly__include_bias',
'sfm__estimator__eps']
这是一个简单的印刷错误,您通过了
sfm\u阈值
,您应该sfm\u阈值
(注意双下划线)。至少一开始的错误就表明了这一点 你能告诉我们你的问题吗?把括号放在函数上,通过赋值传递的实例类型是函数的返回类型,而不是函数类型。我的猜测是管道正在寻找一个函数作为参数,在这里传递一个非函数。我在执行代码时没有错误。您使用的是Python2还是Python3?这里也没有错误!很好用!我使用了python 3和sklearn 0.17.1。
['std__with_mean',
'sfm__estimator__precompute',
'lr__n_jobs',
'sfm__prefit',
'poly',
'sfm__threshold',
'sfm__estimator__cv',
'sfm__estimator__max_iter',
'sfm__estimator__positive',
'sfm__estimator__n_alphas',
'std__with_std',
'sfm__estimator__random_state',
'std__copy',
'lr__normalize',
'sfm__estimator__copy_X',
'lr',
'sfm__estimator__n_jobs',
'poly__interaction_only',
'sfm__estimator__fit_intercept',
'sfm__estimator__tol',
'sfm__estimator',
'sfm__estimator__verbose',
'sfm',
'sfm__estimator__normalize',
'std',
'sfm__estimator__selection',
'poly__degree',
'lr__copy_X',
'sfm__estimator__alphas',
'lr__fit_intercept',
'steps',
'poly__include_bias',
'sfm__estimator__eps']