python - CatBoost 训练后特征信息
问题描述
我想了解在训练 CatBoost 模型后如何访问有关数值和分类特征的信息。为了举例,这里有一些玩具代码:
import pandas as pd
from catboost import CatBoostClassifier, Pool
train_pool = Pool(pd.DataFrame({'size': [1,1,2,1],
'shape': ['square','square','square', 'circle']}),
[1,1,0,1],
feature_names = ['size','shape'],
cat_features= ['shape'])
model = CatBoostClassifier(iterations=2,
cat_features = ['shape'],
ctr_leaf_count_limit=1)
model.fit(train_pool, plot=False)
我现在想在model
对象上运行一个函数以获得以下内容:
数值特征
size
具有最小值0
和最大值1
(这应该是 CatBoosts 数值特征拆分逻辑的一部分)分类特征
shape
具有以下训练值:values=['square', None]
.请注意,
circle
它不在,values
因为car_leaf_count_limit=1
会选择出现次数最多的值,在本例中是'square'
。我放在None
这里是因为我很确定 cat boost 会分配None
给任何看不见的课程。接下来,我选择了上述数据示例以确保 CatBoost 决定拆分
shape=='square'
. 理想情况下,我希望看到一个数组used_values=['square']
,它强调该square
值至少有一个拆分。
这里需要强调的是,我只想对model
对象进行操作。显然,可以通过在训练数据上运行函数来获得其中的一些细节。我的动机是双重确保我完全理解模型输入的训练范围,以及它在预处理中可能对它们做什么。
解决方案
推荐阅读
- gis - TableToTable_conversion 和 FeatureClassToFeatureClass_conversion 在脚本中失败,但使用 Postgres 手动成功
- php - iPhone 6 无法正确加载 CSS
- angular - Bing Map API:右键单击打开弹出窗口并显示纬度和经度
- python - 使用查询对象附加 URL
- python - 为什么这些模型不同?keras 是否标准化渐变?
- android-studio - android studio v3.2.1 运行时显示 sdk 丢失
- java - 获取俄罗斯时间和当前电话时间之间的差异
- ios - 当 AVPlayer 替换当前 AVPlayerItem 时如何去除黑框?
- c# - SpreadsheetLight C# - 按名称将 Excel 表加载到数据表中
- ms-access - 是否可以在某些字段被锁定时将记录添加到 Ms Access 表单中?