python - Optuna catboost 修剪
问题描述
有没有办法用 CatBoost 和 Optuna 进行修剪(在 LightGBM 中很容易,但在 Catboost 中我找不到任何提示)。我的代码是这样的
def objective(trial):
param = {
'iterations':trial.suggest_int('iterations', 100,1500, step=100),
'learning_rate':trial.suggest_uniform("learning_rate", 0.001, 0.3),
'random_strength':trial.suggest_int("random_strength", 1,10),
'max_bin':trial.suggest_categorical('max_bin', [2,3,4,5,6,8,10,20,30]),
'grow_policy':trial.suggest_categorical('grow_policy', ['SymmetricTree', 'Depthwise', 'Lossguide']),
"colsample_bylevel": trial.suggest_uniform("colsample_bylevel", 0.1, 1),
'od_type' : "Iter",
'od_wait' : 30,
"depth": trial.suggest_int("max_depth", 1,12),
"l2_leaf_reg": trial.suggest_loguniform("l2_leaf_reg", 1e-8, 100),
'custom_metric' : ['AUC'],
"loss_function": "Logloss",
}
if param['grow_policy'] == "SymmetricTree":
param["boosting_type"]= trial.suggest_categorical("boosting_type", ["Ordered", "Plain"])
else:
param["boosting_type"] = "Plain"
# Added subsample manually
param["subsample"] = trial.suggest_float("subsample", 0.1, 1)
### CV ###
# How to add a callback for pruning?
scores = cv(train_dataset,
param,
fold_count=5,
early_stopping_rounds=30,
plot=False, verbose=False)
return scores['test-AUC-mean'].mean()
解决方案
不,因为 catboost 不像其他增强库那样提供任何回调。但是,catboost 计划在不久的将来引入回调函数。功能发布后,optuna 可能会实现 catboost 的集成,例如LightGBM
. 另请参阅 github https://github.com/optuna/optuna/issues/2464上的功能请求。
推荐阅读
- javascript - 如何在 JavaScript 中使用 ScrollTo()
- html - 使标签与下面的语义 UI 宽度相同
- spring-boot - 将身份验证/授权移动到单独的微服务,然后结合网关(zuul + eureka 服务器)
- java - Vert.x 中的 sharedData AsyncMap 的寿命有多长?
- c# - log4net - 使用 .config 文件部分 (WebService/IIS) 配置存储库 [MyProject] 时出错
- android - 如何在 Flutter 中使用 Circle Items 制作 ListView 或 PageView 并调整当前 Circle 的大小?
- prolog - 在prolog中制作自然数规则的正确方法是什么?
- java - 即使使用设置,Eclipse 内容辅助自动完成也无法正常工作
- python - 字符串包含换行符 (\n),如何使用正则表达式将 \n 替换为 \n?
- c++ - 对全局变量的非常量引用的无效初始化