xgboost使用

来源:互联网 发布:阿里云mx记录值 编辑:程序博客网 时间:2024/06/05 07:51
from sklearn.ensemble import GradientBoostingClassifierfrom sklearn import cross_validation, metricsfrom sklearn.model_selection import cross_val_scorefrom sklearn.tree import DecisionTreeRegressorimport sklearn.preprocessingfrom sklearn import linear_modelfrom sklearn.preprocessing import ImputerX_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y, test_size=0.3, random_state=198)print(X_train.shape, X_test.shape)xlf = xgb.XGBRegressor(max_depth=10, learning_rate=0.1, n_estimators=10, silent=True, objective='reg:linear', nthread=-1,gamma=0,min_child_weight=1, max_delta_step=0, subsample=0.85, colsample_bytree=0.7, colsample_bylevel=1, reg_alpha=0, reg_lambda=1,scale_pos_weight=1,seed=1440,missing=None)xlf.fit(X_train, y_train, eval_metric='rmse', verbose = True, eval_set = [(X_test, y_test)],early_stopping_rounds=100)