I want to gridsearch RBFSampler in LightGBM. I don’t want to change any params of LightGBM, just the params of RBFSampler. I am having trouble figuring out where to run my features (X) through RBFSampler.
Code:
gamma = [.1,1,10]
n_components = [10,100,1000]
param_grid = {
"gamma": gamma,
"n_components": n_components,
}
search = GridSearchCV(
LGBMClassifier(n_jobs=-1,verbosity=0)
,param_grid=param_grid,n_jobs=-1,cv=tscv,verbose=0,
)
search.fit(X, y)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You need a pipeline to collect the RBFSampler together with the model.
from sklearn.pipeline import Pipeline
pipe = Pipeline([
('rbfs', RBFSampler()),
('lgbm', LGBMClassifier(n_jobs=-1, verbosity=0)),
])
param_grid = {
"rbfs__gamma": gamma,
"rbfs__n_components": n_components,
}
search = GridSearchCV(
pipe,
param_grid=param_grid,
...
)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0