elphick.sklearn_viz.features.importance.plot_feature_importance

elphick.sklearn_viz.features.importance.plot_feature_importance(mdl, sort=False, top_k=None, horizontal=False, permute=False, pipeline_input_features=False, x_test=None, y_test=None, title=None)[source]
Parameters:
  • mdl – The scikit-learn model or pipeline.

  • sort (bool) – If True, sort by decreasing importance

  • top_k (Optional[int]) – Include only the top k features in the plot. Will ignore the sort argument.

  • horizontal (bool) – If True plot horizontal bars, if False vertical bars.

  • permute (bool) – If True plot permutation importance. Better, but slower. Requires X_test and y_test to be provided.

  • pipeline_input_features (bool) – If True, and a pipeline is provided, report the features provided as inputs to the pipeline. If False, reports the estimator (last pipeline step) input features. Requires permute = True.

  • x_test (Optional[DataFrame]) – X values provided to execute permuted importance.

  • y_test (Union[DataFrame, Series, None]) – y values provided to execute permuted importance.

  • title (Optional[str]) – title for the plot

Return type:

Figure

Returns:

a plotly GraphObjects.Figure