Issue
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)
Solution
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,
...
)
Answered By - Ben Reiniger
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.