Python 估算器管道的无效参数损失
我正在尝试使用sklearn实现SGDClassizer,但遇到以下错误: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 = {
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()