首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Catboost默认超参数

Catboost默认超参数
EN

Stack Overflow用户
提问于 2019-04-11 01:19:11
回答 3查看 3.6K关注 0票数 3

如何返回CatBoost模型的所有超参数?

注意:我不认为这是Print CatBoost hyperparameters的重复,因为该问题/答案不能满足我的需求。

例如,使用sklearn,我可以这样做:

代码语言:javascript
复制
rf = ensemble.RandomForestClassifier(min_samples_split=2)
print rf

RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
            max_depth=None, max_features='auto', max_leaf_nodes=None,
            min_impurity_decrease=0.0, min_impurity_split=None,
            min_samples_leaf=1, min_samples_split=2,
            min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
            oob_score=False, random_state=None, verbose=0,
            warm_start=False)

这将返回所有的超参数,包括我定义的超参数和其他默认值。

使用Catboost,我可以使用.get_params(),但它似乎只返回用户指定的参数:

代码语言:javascript
复制
cat = CatBoostClassifier(loss_function='Logloss',
                         verbose = False,
                        eval_metric='AUC',
                        iterations=500,
                         thread_count = None,
                        random_state=SEED)
print cat.get_params()

{'iterations': 500, 'random_state': 42, 'verbose': False, 'eval_metric': 'AUC', 'loss_function': 'Logloss'}

例如,我想知道使用了什么learning_rate,但理想情况下会得到整个列表。

EN

回答 3

Stack Overflow用户

发布于 2019-10-23 14:53:05

您可以尝试更改您的

代码语言:javascript
复制
print cat.get_params()

代码语言:javascript
复制
print cat.get_all_params()

来源:get_all_params documentation

票数 5
EN

Stack Overflow用户

发布于 2019-04-13 16:47:51

您可以在此处找到所有训练参数及其默认值的详细说明:https://catboost.ai/docs/concepts/python-reference_parameters-list.html#python-reference_parameters-list

票数 3
EN

Stack Overflow用户

发布于 2020-10-28 06:03:34

我在寻找同样的答案时遇到了这个问题。

不幸的是,这似乎是不可能的。以下是documentation的摘录

如果未显式指定参数值,则将其设置为默认值。在某些情况下,这些默认值会根据数据集属性和用户定义参数的值动态更改。

因此,因为它们可以动态变化,所以它们在输出中不太可能与输入中的在技术上相同。我试图获取大多数参数,并至少跟踪这些默认值在不同版本之间是否会发生变化。如果它对你有帮助,这里就是:

代码语言:javascript
复制
from catboost import CatBoostClassifier, CatBoostRegressor
import random
import numpy as np

#Create fake dataset for testing:
random.seed(42)
X = np.array([random.random() for x in range(1000)])
y = X ** 2 + random.random()
y_class = [1 if x > 1 else 0 for x in y]

cbc = CatBoostClassifier() #Trend classifier
cbc.fit(X, y_class, verbose=False)
cbc.get_all_params()

#with the output:
{'nan_mode': 'Min', 'eval_metric': 'Logloss', 'iterations': 1000, 'sampling_frequency': 'PerTree', 'leaf_estimation_method': 'Newton', 'grow_policy': 'SymmetricTree', 'penalties_coefficient': 1, 'boosting_type': 'Plain', 'model_shrink_mode': 'Constant', 'feature_border_type': 'GreedyLogSum', 'bayesian_matrix_reg': 0.10000000149011612, 'l2_leaf_reg': 3, 'random_strength': 1, 'rsm': 1, 'boost_from_average': False, 'model_size_reg': 0.5, 'subsample': 0.800000011920929, 'use_best_model': False, 'class_names': [0, 1], 'random_seed': 0, 'depth': 6, 'border_count': 254, 'classes_count': 0, 'auto_class_weights': 'None', 'sparse_features_conflict_fraction': 0, 'leaf_estimation_backtracking': 'AnyImprovement', 'best_model_min_trees': 1, 'model_shrink_rate': 0, 'min_data_in_leaf': 1, 'loss_function': 'Logloss', 'learning_rate': 0.010301999747753143, 'score_function': 'Cosine', 'task_type': 'CPU', 'leaf_estimation_iterations': 10, 'bootstrap_type': 'MVS', 'max_leaves': 64}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55618140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档