XGBoost的保存模型、加载模型、继续训练
假设有这样一个模型:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# coding: utf-8 import numpy as np import pandas as pd import xgboost as xgb # 构造模型 model = xgb.XGBRegressor( learning_rate=0.2, n_estimators=2000, max_depth=10, min_child_weight=1, gamma=8, subsample=0.8, colsample_bytree=0.8, objective="reg:linear", booster="gbtree", n_jobs=4, scale_pos_weight=1, random_state=27 ) # 训练 model.fit(X_train, Y_train) # 预测 Y_pred = model.predict(X_test) |