Skip to content

Instantly share code, notes, and snippets.

@srishtis
Created September 15, 2018 05:02
Show Gist options
  • Save srishtis/b573223c4db3bfd88b98b744c2256220 to your computer and use it in GitHub Desktop.
Save srishtis/b573223c4db3bfd88b98b744c2256220 to your computer and use it in GitHub Desktop.
LGBM for importance type 'gain'
class LGBMClassifier_GainFE(lgb.LGBMClassifier):
@property
def feature_importances_(self):
if self._n_features is None:
raise LGBMNotFittedError('No feature_importances found. Need to call fit beforehand.')
return self.booster_.feature_importance(importance_type='gain')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment