本文整理汇总了Python中sklearn.ensemble.RandomForestClassifier.get_xgb_params方法的典型用法代码示例。如果您正苦于以下问题:Python RandomForestClassifier.get_xgb_params方法的具体用法?Python RandomForestClassifier.get_xgb_params怎么用?Python RandomForestClassifier.get_xgb_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.RandomForestClassifier
的用法示例。
在下文中一共展示了RandomForestClassifier.get_xgb_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: XGBClassifier
# 需要导入模块: from sklearn.ensemble import RandomForestClassifier [as 别名]
# 或者: from sklearn.ensemble.RandomForestClassifier import get_xgb_params [as 别名]
clf = XGBClassifier(learning_rate = 0.01,
n_estimators = 5000,
reg_alpha = 0.025,
colsample_bytree = 0.8,
silent = 1,
scale_pos_weight = 0,
nthread = 4,
min_child_weight = 1,
subsample= 0.8,
seed = 1337,
objective= 'multi:softprob',
max_depth = 7,
gamma= .2)
# use the xgb interface
xgb_param = clf.get_xgb_params()
xgb_param['num_class'] = 5
xgb_param['eval_metric'] = 'mlogloss'
Xg_train = xgb.DMatrix(X_train, label=y_train, missing=np.nan)
cvresult = xgb.cv(xgb_param,
Xg_train,
num_boost_round = clf.get_params()['n_estimators'],
nfold = 5,
show_progress = True,
early_stopping_rounds = 100)
clf.set_params(n_estimators=cvresult.shape[0])
clf.fit(X_train, y_train)
best_outcome_params = clf.get_params()
best_outcome_score = cvresult.min()
try: