简体   繁体   English

Optuna catboost 修剪

[英]Optuna catboost pruning

is there a way to have pruning with CatBoost and Optuna (in LightGBM it's easy but in Catboost I can't find any hint).有没有办法用 CatBoost 和 Optuna 进行修剪(在 LightGBM 中很容易,但在 Catboost 中我找不到任何提示)。 My code is like this我的代码是这样的

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()

No, because catboost doesn't provide any callback like the other boosting libraries.不,因为 catboost 不像其他增强库那样提供任何回调。 However, catboost plans to introduce a callback function in the near future.但是,catboost 计划在不久的将来引入回调 function。 After the release of the feature, optuna may implement integration for catboost like LightGBM .功能发布后,optuna 可能会像LightGBM一样实现 catboost 的集成。 See also the feature request on github https://github.com/optuna/optuna/issues/2464 .另请参阅 github https://github.com/optuna/optuna/issues/2464上的功能请求。

Yes, CatBoost does now support pruning with Optuna.是的,CatBoost 现在支持使用 Optuna 进行修剪。 Adding to @nzw0301's comment, please see Optuna's example of pruning a CatBoost model here:添加到@nzw0301 的评论,请在此处查看 Optuna 修剪 CatBoost model 的示例:

Optuna Documentation - Pruning a CatBoost Model Optuna 文档 - 修剪 CatBoost Model

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM