SHARE
TWEET

Untitled

a guest Sep 17th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top