Skip to content

Instantly share code, notes, and snippets.

@adensur
Created May 20, 2022 10:46
Show Gist options
  • Save adensur/134b82c304cc69eed278e258e6b2a685 to your computer and use it in GitHub Desktop.
Save adensur/134b82c304cc69eed278e258e6b2a685 to your computer and use it in GitHub Desktop.
xgboost train code
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