4

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

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

例如,使用 sklearn 我可以:

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() 但它似乎只返回用户指定的参数:

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 使用了什么,但理想情况下得到整个列表。

4

3 回答 3

6

你可以尝试改变你的

print cat.get_params()

print cat.get_all_params()

来源:get_all_params 文档

于 2019-10-23T06:53:04.830 回答
3

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

于 2019-04-13T08:47:50.620 回答
0

我遇到了这个寻找相同的答案。

不幸的是,这似乎是不可能的。这是文档的摘录:

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

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

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}

于 2020-10-27T22:03:34.323 回答