Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from collections import Counter
  2. def extractFeatures(model, k_features, fscore = None):
  3. '''
  4. :params: model: Trained XGBoost Model
  5. :params: k_features: Numbers of features to extract
  6. :params: fscore: threshhold score to extract features
  7. :Return: list of features from model
  8. '''
  9. features = Counter(model.get_booster().get_score())
  10. features = features.most_common(k_features)
  11. features = [x[0] for x in features if x[1] >= fscore]
  12. return features
  13.  
  14. features = extractFeatures(xgbmodel, 10, 20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement