我正在使用具有大量分类特征(> 80%)的数据集来预测连续目标变量(即回归)。我已经阅读了很多关于处理分类特征的方法。并且了解到我过去一直使用的单热编码是一个非常糟糕的主意,特别是当涉及到许多具有多个级别的分类特征时(阅读这些帖子和这个)。
虽然我遇到过诸如基于目标的分类特征编码(平滑)之类的方法,这些方法通常基于每个特征的目标值的平均值,也许是 Kaggle 中的这篇文章/内核。我仍然在努力寻找更具体的方法,直到我发现CatBoost是 Yandex 集团去年发布的决策树上的开源梯度提升。它们似乎为分类特征提供了额外的统计计数选项,可能比简单的 one-hot 编码或平滑更有效。
问题是文档对如何设置CTR 设置没有帮助。我尝试了不同的方法,但它不起作用。该文档将 CTR 设置为simple_ctr,以(CTR 设置部分)给出:
['CtrType[:TargetBorderCount=BorderCount][:TargetBorderType=BorderType][:CtrBorderCount=Count][:CtrBorderType=Type][:Prior=num_1/denum_1]..[:Prior=num_N/denum_N]',
'CtrType[:TargetBorderCount=BorderCount][:TargetBorderType=BorderType][:CtrBorderCount=Count][:CtrBorderType=Type][:Prior=num_1/denum_1]..[:Prior=num_N/denum_N]',
...]
这是一个超级简单的示例,数据如下所示:
import pandas as pd
import catboost
data = [{'profit': '342','country': 'holland','account': 'Jones LLC', 'saving': 150, 'debt': -60, 'age': 28},
{'profit': '875','country': 'germany','account': 'Alpha Co', 'saving': 200, 'debt': -10, 'age': 42},
{'profit': '127','country': 'italy','account': 'Blue Inc', 'saving': 50, 'debt': -300, 'age': 38 }]
df = pd.DataFrame(data)
这是一个简单的 Catboost 回归器:
X_train = df.drop(['profit'],axis=1)
Y_train = df['profit']
categorical_features_indices = [0,2]
train_pool = catboost.Pool(X_train, Y_train, cat_features=categorical_features_indices)
model = catboost.CatBoostRegressor(
depth=3,
iterations=5,
eval_metric='RMSE',
simple_ctr=None)
model.fit(train_pool);
CTR 设置之一的simple_ctr是问题所在!!很遗憾,因为看起来这个包提供了各种方法,到目前为止还没有办法访问它们。
2018 年 8 月 9 日更新:几天前,我向 Catboost 开发人员提出了这个问题,请参见此处,他们为它开了一张票以提供教程。