henchman.learning.feature_importances

henchman.learning.feature_importances(X, model, n_feats=5)[source]

Print a list of important features. Also returns a list of column names.

Parameters:
  • X (pd.DataFrame) – The dataframe from which the features are drawn.
  • model (sklearn.ensemble) – A model with a feature_importances_ attribute.
  • n_feats (int) – Number of feature importances to return.
Returns:

A list of n_feats feature column names.

Return type:

list[str]

Example

>>> from henchman.learning import feature_importances
>>> my_feats = feature_importances(X, fit_model, n_feats=5)
>>> X[my_feats].head()