提问人:Lorenzo Boletti 提问时间:11/3/2023 更新时间:11/3/2023 访问量:43
Python 中 xgboost 库的“enable_categorical=True”编码方法
"enable_categorical=True" encoding method for xgboost library in Python
问:
假设同时包含数值变量和分类变量。X_train
import xgboost as xgb
dtrain = xgb.DMatrix(data=X_train, label=y_train, enable_categorical=True)
params = {
'objective': 'binary:logistic',
'max_depth': 10,
'learning_rate': 0.01,
'eval_metric': 'logloss',
'subsample': 0.90,
'colsample_bytree': 0.90,
'min_child_weight': 10
}
model = xgb.train(params, dtrain, num_boost_round=1000)
我怎么知道使用了哪种编码方法?是一热编码、目标编码还是标签编码之一?还是一个明智的选择?
答:
0赞
seralouk
11/3/2023
#1
该功能是实验性的,目前功能有限。
这似乎是一个简单的标志,它允许函数您的数据具有分类特征,因此函数应该使用它。xgboost
基本思想是创建具有类别特征类型的数据帧,并通过设置 enable_categorical 参数告诉 XGBoost 使用它。
另请看一下源代码:
来源: https://xgboost.readthedocs.io/en/stable/tutorials/categorical.html
评论