Invalid parameter loss for estimator Pipeline

Viewed 5277

I'm trying to implement a SGDClassifier with sklearn, but I'm getting this error:

ValueError: Invalid parameter loss for estimator Pipeline. Check the list of available parameters with `estimator.get_params().keys()`.

This is my code:

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)

How can I fix this?

2 Answers

This displays exact keys to be used to reference parameters within the pipeline

pipeline.get_params().keys()
Related