0
$\begingroup$

I have got problem with sklearn function called validation_curve.

pipe_lr = Pipeline([('sc', StandardScaler()),
                ('pca', PCA(n_components=10)),
                ('lr', LogisticRegression(penalty='l2', random_state=0))])
param_range = [0.001, 0.01, 0.1, 1, 10, 100, 100]
train_scores, test_scores = validation_curve(estimator=pipe_lr,
                                        X=X_train,
                                        y=y_train,
                                        param_name='lr_C',
                                        param_range=param_range,
                                        cv=10)

This code causes error:

ValueError: Invalid parameter lr_C for estimator Pipeline(memory=None, steps=[('sc', StandardScaler(copy=True, with_mean=True, with_std=True)), ('lr', LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, l1_ratio=None, max_iter=100, multi_class='warn', n_jobs=None, penalty='l2', random_state=0, solver='warn', tol=0.0001, verbose=0, warm_start=False))], verbose=False). Check the list of available parameters with estimator.get_params().keys().

But when i use 'pipe_lr.get_params().keys(), i have something like this:

dict_keys(['memory', 'steps', 'verbose', 'sc', 'lr', 'sc__copy', 'sc__with_mean', 'sc__with_std', 'lr__C', 'lr__class_weight', 'lr__dual', 'lr__fit_intercept', 'lr__intercept_scaling', 'lr__l1_ratio', 'lr__max_iter', 'lr__multi_class', 'lr__n_jobs', 'lr__penalty', 'lr__random_state', 'lr__solver', 'lr__tol', 'lr__verbose', 'lr__warm_start'])

So name of parameter C is 'lr_C', but it isnt working. What is the problem?

$\endgroup$
  • $\begingroup$ double underscore $\endgroup$ – Ben Reiniger Nov 14 '19 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.