使用scikit-learn機器學習庫裡面的xgboost

打嗝_小王子發表於2020-12-05
from xgboost import XGBRegressor
from sklearn.datasets import make_regression

if __name__ == "__main__":
    x,y = make_regression(n_samples=50,n_features=2,n_informative=2)
    xgb = XGBRegressor(n_estimators=2,max_depth=2)
    xgb.fit(x,y)

    data = xgb.get_booster().trees_to_dataframe()
    print(data)

# X,y = shap.datasets.boston()
# model = xgboost.train({"learning_rate": 0.01}, xgboost.DMatrix(X, label=y), 100)

 

相關文章