如何返回CatBoost模型的所有超参数?
注意:我不认为这是Print CatBoost hyperparameters的重复,因为该问题/答案不能满足我的需求。
例如,使用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,但理想情况下会得到整个列表。
发布于 2019-10-23 14:53:05
发布于 2019-04-13 16:47:51
发布于 2020-10-28 06:03:34
我在寻找同样的答案时遇到了这个问题。
不幸的是,这似乎是不可能的。以下是documentation的摘录
如果未显式指定参数值,则将其设置为默认值。在某些情况下,这些默认值会根据数据集属性和用户定义参数的值动态更改。
因此,因为它们可以动态变化,所以它们在输出中不太可能与输入中的在技术上相同。我试图获取大多数参数,并至少跟踪这些默认值在不同版本之间是否会发生变化。如果它对你有帮助,这里就是:
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}https://stackoverflow.com/questions/55618140
复制相似问题