Skip to content

Instantly share code, notes, and snippets.

@RAMitchell
Created May 19, 2020 03:03
Show Gist options
  • Save RAMitchell/d0f1f94579a3e4100674089b5300202e to your computer and use it in GitHub Desktop.
Save RAMitchell/d0f1f94579a3e4100674089b5300202e to your computer and use it in GitHub Desktop.
import numpy as np
import xgboost as xgb
import time
print("Xgboost version: {}".format(xgb.__version__))
n = 10000000
query_groups = 100000
group_size = n / query_groups
m = 10
X = np.random.randn(n, m)
y = np.random.randn(n)
groups = np.array([group_size] * query_groups, dtype=np.uint32)
start = time.time()
clf = xgb.XGBRanker(tree_method='gpu_hist', objective='rank:map', max_depth=6, eta=0.1)
clf.fit(X, y, groups)
print("Ranking time: {}s".format(time.time() - start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment