Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- def extractFeatures(model, k_features, fscore = None):
- '''
- :params: model: Trained XGBoost Model
- :params: k_features: Numbers of features to extract
- :params: fscore: threshhold score to extract features
- :Return: list of features from model
- '''
- features = Counter(model.get_booster().get_score())
- features = features.most_common(k_features)
- features = [x[0] for x in features if x[1] >= fscore]
- return features
- features = extractFeatures(xgbmodel, 10, 20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement