# GridSearchCV fitting multiple classifers

**URL:** https://discuss.ray.io/t/gridsearchcv-fitting-multiple-classifers/6379
**Category:** Ray Tune
**Created:** [June 3, 2022, 1:58pm UTC](https://discuss.ray.io/t/gridsearchcv-fitting-multiple-classifers/6379 "2022-06-03T13:58:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![markanthony97](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/markanthony97/32/2665_2.png) [@markanthony97](https://discuss.ray.io/u/markanthony97)
#### Post date: [June 3, 2022, 1:58pm UTC](https://discuss.ray.io/t/gridsearchcv-fitting-multiple-classifers/6379/1 "2022-06-03T13:58:07Z")

</div>

- High: It blocks me to complete my task.

Hello, I have another issue with my fitting. So far when it comes to fitting an individual model with its parameters `TuneGridSearchCV` works fine; however, when trying to fit multiple classifiers, I start getting first the following warnings:

```auto
2022-06-03 15:33:41,937	INFO logger.py:715 -- Removed the following hyperparameter values when logging to tensorboard: {'classifier': AdaBoostClassifier()}
2022-06-03 15:33:41,956	INFO trial_runner.py:803 -- starting _Trainable_bdcee633
2022-06-03 15:33:42,363	INFO logger.py:715 -- Removed the following hyperparameter values when logging to tensorboard: {'classifier': AdaBoostClassifier()}
2022-06-03 15:33:42,374	INFO trial_runner.py:803 -- starting _Trainable_c8acc8dc
2022-06-03 15:33:43,040	INFO logger.py:715 -- Removed the following hyperparameter values when logging to tensorboard: {'classifier': AdaBoostClassifier()}
2022-06-03 15:33:43,047	INFO trial_runner.py:803 -- starting _Trainable_c8ed0636
2022-06-03 15:33:44,969	INFO logger.py:715 -- Removed the following hyperparameter values when logging to tensorboard: {'classifier': AdaBoostClassifier()}
2022-06-03 15:33:45,113	INFO trial_runner.py:803 -- starting _Trainable_c94d0078
(pid=) [2022-06-03 15:33:48,911 E 9580 16080] (raylet.exe) agent_manager.cc:107: The raylet exited immediately because the Ray agent failed. The raylet fate shares with the agent. This can happen because the Ray agent was unexpectedly killed or failed. See `dashboard_agent.log` for the root cause.
2022-06-03 15:33:51,516	INFO trial_runner.py:803 -- starting _Trainable_ca8a3b7f
2022-06-03 15:33:52,792	ERROR trial_runner.py:872 -- Trial _Trainable_bdcee633: Error processing event.

```

afterwards I get the following error traceback:

```auto
Traceback (most recent call last):
  File "C:\Users\Hp\Documents\GitHub\ML_project_2\tunetest.py", line 108, in <module>
    tune_search.fit(X_train,y_train)
  File "C:\Users\Hp\Documents\GitHub\ML_project_2\newEnv\lib\site-packages\tune_sklearn\tune_basesearch.py", line 622, in fit
    return self._fit(X, y, groups, tune_params, **fit_params)
  File "C:\Users\Hp\Documents\GitHub\ML_project_2\newEnv\lib\site-packages\tune_sklearn\tune_basesearch.py", line 533, in _fit
    self.analysis_ = self._tune_run(X, y, config, resources_per_trial,
  File "C:\Users\Hp\Documents\GitHub\ML_project_2\newEnv\lib\site-packages\tune_sklearn\tune_gridsearch.py", line 302, in _tune_run
    analysis = tune.run(trainable, **run_args)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\tune\tune.py", line 672, in run
    runner.step()
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\tune\trial_runner.py", line 767, in step
    self._wait_and_handle_event(next_trial)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\tune\trial_runner.py", line 745, in _wait_and_handle_event
    raise e
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\tune\trial_runner.py", line 730, in _wait_and_handle_event
    self._on_executor_error(trial, result)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\tune\trial_runner.py", line 874, in _on_executor_error
    raise result[0]
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\tune\ray_trial_executor.py", line 901, in get_next_executor_event
    future_result = ray.get(ready_future)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\_private\client_mode_hook.py", line 105, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\worker.py", line 1803, in get
    values, debugger_breakpoint = worker.get_objects(object_refs, timeout=timeout)
  File "C:\Users\Hp\AppData\Local\Programs\Python\Python39\lib\site-packages\ray\worker.py", line 362, in get_objects
    data_metadata_pairs = self.core_worker.get_objects(
  File "python\ray\_raylet.pyx", line 1198, in ray._raylet.CoreWorker.get_objects
  File "python\ray\_raylet.pyx", line 173, in ray._raylet.check_status
ray.exceptions.RaySystemError: System error: Unknown error

```

probably due to the fact that the actual classifier is removed from the pipeline.

I set the classifiers and their respective parameters parameters as follows, just like I would do with scikit-learn’s `GridSearchCV`:

```auto
clf1 = AdaBoostClassifier()
params1 = {"classifier__n_estimators": [50, 100, 150, 200],
           "classifier__learning_rate": [0.1, 0.5, 1, 5, 10],
           "classifier__random_state": [20, 42, 301, 2000],
           "classifier" : [clf1]}

# https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html
clf2= SVC()
params2 = {"classifier__C":[1.0, 2.0, 3.0, 5.0, 7.0, 10.0],
            'classifier__kernel' : ['rbf','sigmoid'],
            'classifier__tol' : [1e-4, 1e-3, 1e-2],
            "classifier":[clf2]}

....

params = [params1, params2]
classifier = Pipeline([('classifier',clf1)])

tune_search = TuneGridSearchCV(classifier, params)

```

is it because it can’t handle python objects, or is it something else? If it’s the former, is there any way to combine multiple classifiers in the grid sarch that I don’t know about?

---

<div class="post-metadata">

### Author: ![Huaiwei\_Sun](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/huaiwei_sun/32/1316_2.png) [@Huaiwei\_Sun](https://discuss.ray.io/u/Huaiwei_Sun)
#### Post date: [August 26, 2022, 5:18am UTC](https://discuss.ray.io/t/gridsearchcv-fitting-multiple-classifers/6379/2 "2022-08-26T05:18:51Z")

</div>

cc: @kai @xwjiang2010

---

<div class="post-metadata">

### Author: ![xwjiang2010](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/xwjiang2010/32/1476_2.png) [@xwjiang2010](https://discuss.ray.io/u/xwjiang2010)
#### Post date: [August 30, 2022, 9:05pm UTC](https://discuss.ray.io/t/gridsearchcv-fitting-multiple-classifers/6379/3 "2022-08-30T21:05:35Z")

</div>

@markanthony97  
Does this work for you?

[https://learn-scikit.oneoffcoder.com/hyperparam-tuning.html#tune-sklearn](https://learn-scikit.oneoffcoder.com/hyperparam-tuning.html#tune-sklearn)
