from sklearn.model_selection import GridSearchCV
*parameters = {**?????**}*
search = GridSearchCV(_pipeline, n_jobs=1, cv= 5, param_grid=parameters)
#multi_target_linear = MultiOutputClassifier(search)
search.fit(X, y)
#search.get_params().keys()
search.best_params_

- 34,399
- 18
- 41
- 57

- 11
- 5
2 Answers
Hyperparameters in a case like this would vary from case to case, as they are what you want to solve for, arriving at hyperparameters that are both accurate and efficient.
From what it seems, you aim to create a parameter grid called parameters
, that includes several hyperparameters that you want to hone down on. GridSearchCV can then try all the combinations of hyperparameters and find the best performing combination. The CV is Cross Validation, which is a way of shuffling the training and test sets for fair evaluation, which you here have 5 different segments, hence cv=5
.
You also are using MultiOutputClassifier, which is designed to adapt other classifiers to be able to handle multiple targets, but you don't define what classifier that is.

- 175
- 9
-
I am sorry, this should be helpful: '''X, y = make_multilabel_classification(n_classes=36, random_state=0) _pipeline = Pipeline([ ('clf', MultiOutputClassifier(KNeighborsClassifier()).fit(X, y)) ]) for category in categories: y_pred = _pipeline.predict(X)''' – Egor Petrov Jul 20 '21 at 03:05
Parameter param_grid
of GridSearchCV is determined by its estimator
, but you didn't write how _pipeline
is constructed.
So I cannot answer this question, but this answer will help.

- 228
- 1
- 6
-
I am sorry guys, let me show you a structure: '''X, y = make_multilabel_classification(n_classes=36, random_state=0) _pipeline = Pipeline([ ('clf', MultiOutputClassifier(KNeighborsClassifier()).fit(X, y)) ]) for category in categories: y_pred = _pipeline.predict(X)''' – Egor Petrov Jul 20 '21 at 03:03
-
@EgorPetrov You are using 'Pipeline' in wrong way. See the link in my answer. – Canasta Jul 21 '21 at 04:49
-
I changed MultiOutputClassifier(KNeighborsClassifier()) to MultiOutputClassifier(SVR) and used paramets as for SVR and my pipeline works now. I do not know why it did not work for KneighborClassifier or I did not have parameters for this. – Egor Petrov Jul 23 '21 at 03:06