pyreal.visualize.feature_bar_plot#

pyreal.visualize.feature_bar_plot(explanation, select_by='absolute', num_features=5, transparent=False, flip_colors=False, precision=2, prediction=None, include_averages=False, include_axis=True, show=False, filename=None, **kwargs)[source]#

Plot the most contributing features

Parameters:
  • explanation (DataFrame or FeatureBased) – One output DataFrame from RealApp.produce_feature_contributions or RealApp.prepare_feature_importance OR FeatureBased explanation object

  • select_by (one of "absolute", "max", "min") – Method to use when selecting features.

  • num_features (int) – Number of features to plot

  • transparent (Boolean) – If True, the background of the figure is set to transparent.

  • flip_colors (Boolean) – If True, make the positive explanation red and negative explanation blue. Useful if the target variable has a negative connotation

  • precision (int) – Number of decimal places to print for numeric float values

  • prediction (numeric or string) – Prediction to display in the title

  • include_averages (Boolean) – If True, include the mean values in the visualization (if provided in explanation)

  • include_axis (Boolean) – If True, include the contribution axis

  • show (Boolean) – Show the figure

  • filename (string or None) – If not None, save the figure as filename

  • **kwargs – Additional parameters to pass into plt.barh

Returns:

pyplot figure

Bar plot of top contributors