0

I'm trying to tune my model using the Grid search model in @kaggle notebook. In order to benefit from the GPU, I used this package hummingbird-ml. Thanks in advance

However, I get the following issue:

AttributeError: 'GridSearchCV' object has no attribute 'best_estimator_'

Here is my code:


from hummingbird.ml import convert
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVR
from sklearn.metrics import make_scorer, mean_squared_error
from pprint import pprint
# Hyper-tunning for SVM regressor

import numpy as np

base_svr = SVR()


scorer = make_scorer(mean_squared_error, greater_is_better=False)



param_grid_svr = {'C': [0.01, 0.1,1, 10, 100], 
              'gamma': [1,0.1, 0.01, 0.001, 0.0001],
              'kernel': ['linear', 'poly', 'rbf', 'sigmoid', 'precomputed'],
              'epsilon': [0.01, 0.1, 0.2 , 0.3, 1]}
pprint(param_grid_svr) 

# Create a GridSearchCV object and fit it to the training data

svr_gs = GridSearchCV(base_svr,param_grid_svr, n_jobs = -1 , scoring=scorer, cv=3   ,refit=True,verbose=2)

# Converting scikit-learn model to PyTorch on CPU

svr_gs_pytorch = convert(svr_gs, 'torch')

# Switching PyTorch from CPU to GPU
%%capture 
svr_gs_pytorch.to('cuda')

# Train the model in GPU

svr_gs_pytorch.fit(X_train,y_train)


# print best parameter after tuning
svr_gs_pytorch.best_params_

MarMarhoun
  • 45
  • 4
  • My rough understanding of hummingbird is that you convert a model *after* learning in order to speed up inference. This code listing appears to convert an entire `GridSearchCV` object *before* learning. – Alexander L. Hayes Dec 29 '22 at 16:24
  • Yes, exactly. I used this package to speed up the search process. Since using only the CPUs is taking a long time to find the best combination. Please feel free to share any thoughts or suggestions! – MarMarhoun Dec 29 '22 at 16:29
  • That sounds like undefined behavior. I'm surprised it didn't crash. – Alexander L. Hayes Dec 29 '22 at 16:30
  • Why is that? Can you please explain your opinion, thanks in advance. – MarMarhoun Dec 30 '22 at 01:20

0 Answers0