如何进行搜索RBFSampler

发布于 2025-01-25 03:18:47 字数 589 浏览 3 评论 0原文

I want to gridsearch RBFSampler在LightGBM中。我不想更改LightGBM的任何参数,只是RBFSAMPLER的参数。我很难通过RBFSampler弄清楚在哪里运行我的功能(X)。

代码:

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)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水中月 2025-02-01 03:18:47

您需要一条管道与模型一起收集rbfsampler

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,
    ...
)

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,
    ...
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文