code: def xgb_to_features(model, X_train, X_test):
      
      import xgboost as xgb
      f_train = model.predict(xgb.DMatrix(X_train), pred_leaf=True)
      f_test = model.predict(xgb.DMatrix(X_test), pred_leaf=True)
      enc = OneHotEncoder()
      enc.fit(f_train)
      return enc.transform(f_train), enc.transform(f_test)
docs: Converts xgboost model into categorical features.
      Reference:
      "Practical Lessons from Predicting Clicks on Ads at Facebook"
      https://research.fb.com/publications/practical-lessons-from-predicting-clicks-on-ads-at-facebook/