evalml.model_understanding.prediction_explanations.explain_prediction

evalml.model_understanding.prediction_explanations.explain_prediction(pipeline, input_features, y, index_to_explain, top_k_features=3, include_shap_values=False, output_format='text')[source]

Creates table summarizing the top_k positive and top_k negative contributing features to the prediction of a single datapoint.

XGBoost models and CatBoost multiclass classifiers are not currently supported.

Parameters
  • pipeline (PipelineBase) – Fitted pipeline whose predictions we want to explain with SHAP.

  • input_features (ww.DataTable, pd.DataFrame) – Dataframe of features - needs to correspond to data the pipeline was fit on.

  • y (ww.DataColumn, pd.Series) – Labels for the input data.

  • index_to_explain (int) – The index of the row to explain in the input features.

  • top_k_features (int) – How many of the highest/lowest features to include in the table. Default is 3.

  • include_shap_values (bool) – Whether the SHAP values should be included in an extra column in the output. Default is False.

  • output_format (str) – Either “text”, “dict”, or “dataframe”. Default is “text”.

Returns

str, dict, or pd.DataFrame - A report explaining the most positive/negative contributing features to the predictions.

Raises

ValueError – if an output_format outside of “text”, “dict” or “dataframe is provided.