CatBoost超参数优化返回意外结果

2024-04-28 18:22:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我的系统使用的是:CatBoost版本0.16.4,NumPy版本1.16.2,Pandas版本0.24.2,Hyperopt版本0.2

我试图解决一个二进制分类问题,即确定每一行属于“0”类还是“1”类。我在一个具有许多分类特性的大型数据集上使用超参数调整CatBoost教程(https://github.com/catboost/tutorials/blob/master/classification/classification_with_parameter_tuning_tutorial.ipynb)中提供的CatBoostClassifier。因此,我不得不将GPU内存的使用限制为0.9。在

在CV=5倍的100次hyperopt_迭代后,推荐的最佳参数大大超出了输入特征的规定范围。值得注意的是,当学习速率的输入范围在0.000001和0.1之间时,建议将learning_rate设置为10。

这是“查找最佳超参数”的典型行为,还是hyperopt或CatBoost存在故障?然而,在超参数搜索过程中打印的评估的AUC分数大致符合预期。在

非常感谢,我是一个初学者使用这两个工具。在

max_mean_auc = np.max(scores['test-AUC-mean'])

const_params = dict({
'boosting_type': 'Plain',
'max_ctr_complexity': 1,
'gpu_ram_part': 0.9,
'gpu_cat_features_storage': 'CpuPinnedMemory',
'task_type': 'GPU' if have_gpu else 'CPU',
'loss_function': 'Logloss',
'eval_metric': 'AUC', 
'custom_metric': ['AUC'],
'class_weights': [1, 12],
'od_type': 'Iter',
'early_stopping_rounds': 20,
'random_seed': 1})

parameter_space = {
'iterations': hyperopt.hp.choice('iterations', range(20,1020,20)), 
'depth': hyperopt.hp.choice('depth', range(1, 11,1)),
'learning_rate': hyperopt.hp.choice('learning_rate', [0.000001, 0.000003, 0.00001, 0.00003, 0.0001, 0.0003, 0.001, 0.003, 0.01, 0.03, 0.1]),
'l2_leaf_reg': hyperopt.hp.uniform('l2_leaf_reg', 1, 50),
'roc_file': 'roc-file'}

超参数搜索完成后输出消息:

“最佳参数为{'depth':6,'iterations':48,'l2\'leaf_reg':20.242404408697663,'learning_'u reg':20.242404408697663,'learning_type':10,'boosting_type':0.9,'gpu_cat_features_storage':'CpuPinnedMemory','task_type':'gpu','loss_function':'Logloss','eval_metric':'AUC','custom'u metric':['AUC'],'class\u weights':[1,12],“od_type”:“Iter”,“早期停止回合”:20,“随机种子”:1}“

“学习率大于1。您可能需要降低学习率。”

编辑:请注意,在整个搜索过程中,我收到一条“警告:可用的gpu内存不足75%”,并且我的loss_函数正在使用“LogLoss”。这些设置是否会影响输出?在


Tags: 版本参数gpuratetyperegmetricmax