Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 估算器管道的无效参数损失_Python_Scikit Learn - Fatal编程技术网

Python 估算器管道的无效参数损失

Python 估算器管道的无效参数损失,python,scikit-learn,Python,Scikit Learn,我正在尝试使用sklearn实现SGDClassizer,但遇到以下错误: ValueError: Invalid parameter loss for estimator Pipeline. Check the list of available parameters with `estimator.get_params().keys()`. 这是我的代码: pipeline = Pipeline([ ('clf', SGDClassifier()) ]) parameters = {

我正在尝试使用sklearn实现SGDClassizer,但遇到以下错误:

ValueError: Invalid parameter loss for estimator Pipeline. Check the list of available parameters with `estimator.get_params().keys()`.
这是我的代码:

pipeline = Pipeline([
 ('clf', SGDClassifier())
])

parameters = {
    'seed': [0],
    'loss': ('log', 'hinge'),
    'penalty': ['l1', 'l2', 'elasticnet'],
    'alpha': [0.001, 0.0001, 0.00001, 0.000001]
}

score_func = make_scorer(metrics.f1_score)

grid_search = GridSearchCV(pipeline, parameters, n_jobs=3,
verbose=1, scoring=score_func)

grid_search.fit(X, Y)
如何解决此问题?

来自:

管道中估计器的参数可以使用_u语法访问

所以试试这个:

parameters = {
    'clf__seed': [0],
    'clf__loss': ('log', 'hinge'),
    'clf__penalty': ['l1', 'l2', 'elasticnet'],
    'clf__alpha': [0.001, 0.0001, 0.00001, 0.000001]
}
这将显示用于引用管道内参数的精确键

pipeline.get_params().keys()