【发布时间】:2017-08-21 22:25:08
【问题描述】:
我使用 scikit-learn 构建了一个 XGBoost 模型,我对此非常满意。作为避免过度拟合的微调,我想确保某些特征的单调性,但在那里我开始面临一些困难......
据我所知,scikit-learn 中没有关于 xgboost 的文档(我承认我对此感到非常惊讶 - 知道这种情况会持续几个月)。我找到的唯一文档直接在http://xgboost.readthedocs.io
在这个网站上,我发现可以使用“monotone_constraints”选项来强制执行单调性。 我尝试在 Scikit-Learn 中使用它,但收到一条错误消息“TypeError: init() got an unexpected keyword argument 'monotone_constraints'”
你知道怎么做吗?
这是我用python写的代码(使用spyder):
grid = {'learning_rate' : 0.01, 'subsample' : 0.5, 'colsample_bytree' : 0.5,
'max_depth' : 6, 'min_child_weight' : 10, 'gamma' : 1,
'monotone_constraints' : monotonic_indexes}
#'monotone_constraints' ~ = "(1,-1)"
m07_xgm06 = xgb.XGBClassifier(n_estimators=2000, **grid)
m07_xgm06.fit(X_train_v01_oe, Label_train, early_stopping_rounds=10, eval_metric="logloss",
eval_set=[(X_test1_v01_oe, Label_test1)])
【问题讨论】:
标签: python scikit-learn xgboost