Created
May 20, 2022 10:46
-
-
Save adensur/134b82c304cc69eed278e258e6b2a685 to your computer and use it in GitHub Desktop.
xgboost train code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xgboost as xgb | |
import random | |
features2d = [] | |
targets = [] | |
for i in range(10): | |
features = [] | |
for j in range(10): | |
feature = random.random() | |
features.append(feature) | |
features2d.append(features) | |
target = random.random() | |
targets.append(target) | |
dtrain = xgb.DMatrix(features2d, label=targets) | |
param = {'max_depth': 3, 'eta': 0.025, 'objective': 'reg:squarederror'} | |
num_round = 300 | |
tree = xgb.train(param, dtrain, num_round) | |
tree.save_model("tree.json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment