I am using gridsearch in sklearn using the following code
How should I extract each numeric value i.e. 44.984326689694534 or 0.2811768697974237 from the object grid.best_params_?
param_grid= {'gamma': np.logspace(-9, 9, num=50, base=10),'C': np.logspace(-9, 9, num=50, base=10)}
base_estimator = SVC(kernel='rbf', random_state=42)
grid = HalvingGridSearchCV(base_estimator, param_grid, cv=10, factor=3, min_resources=20).fit(X_train_bal, Y_train_bal)
print(grid.best_params_)
The result is {'C': 44.984326689694534, 'gamma': 0.2811768697974237}
I tried grid.best_params_[0][0] but it gives error.
The result is in a
dictionaryformat (or dict). The first parameter is calledkeyand the secondvalue. If you want to get the value of 'C', for example, you need to:The output would be: