1
$\begingroup$

On the following lines of code I am getting

clf = neural_network.MLPClassifier(hidden_layer_sizes=(5, 12))
parameters =[ {'solver': ['lbfgs'],'max_iter': [500,1000,1500], 'alpha': [1e-1,1e-2,1e-3,1e-4,1e-5,1e-6,1e-7],  'random_state':[0,1,2,3,4,5,6,7,8,9]}]
model = GridSearchCV(clf,param_grid=parameters,n_jobs=-1)

On the last line I am getting the following error

ValueError: Parameter values for parameter (solver) need to be a sequence(but not a string) or np.ndarray.

now I know from reading

Parameters in GridSearchCV in scikit-learn

That this means everything must be in an array but all my params are in an array so what am I doing wrong. thanks

$\endgroup$
1
$\begingroup$

I don't get that (or any) error (after correcting your paramators to parameters).

That said, if you only want to use one solver, you might as well pass it directly to the estimator and leave it out of the grid search.

$\endgroup$
0
$\begingroup$

No, Not all of your parameters are array, as pointed in the error message, the parameter "solver" is a list with a single string value.

You have declared {'solver' : ['lbfgs'] }, this is a list with a single string 'lbfgs'.

Parameter 'solver' should have list of values separated by comma, but you given only one value 'lbfgs'.

For Example

You could change the parameter like {'solver' : ['l','b','f','g','s'] }, this is a list of string values.

Or

You could change the parameter like {'solver' : ['lbf','gs', 'abc'] }, this is also a list of string values.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.