force_plots#

Force plots.

Module Contents#

Functions#

force_plot

Function to generate the data required to build a force plot.

graph_force_plot

Function to generate force plots for the desired rows of the training data.

Contents#

evalml.model_understanding.force_plots.force_plot(pipeline, rows_to_explain, training_data, y)[source]#

Function to generate the data required to build a force plot.

Parameters
  • pipeline (PipelineBase) – The pipeline to generate the force plot for.

  • rows_to_explain (list[int]) – A list of the indices of the training_data to explain.

  • training_data (pandas.DataFrame) – The data used to train the pipeline.

  • y (pandas.Series) – The target data.

Returns

list of dictionaries where each dict contains force plot data. Each dictionary

entry represents the explanations for a single row.

For single row binary force plots:
[{‘malignant’: {‘expected_value’: 0.37,

’feature_names’: [‘worst concave points’, ‘worst perimeter’, ‘worst radius’], ‘shap_values’: [0.09, 0.09, 0.08], ‘plot’: AdditiveForceVisualizer}]

For two row binary force plots:
[{‘malignant’: {‘expected_value’: 0.37,

’feature_names’: [‘worst concave points’, ‘worst perimeter’, ‘worst radius’], ‘shap_values’: [0.09, 0.09, 0.08], ‘plot’: AdditiveForceVisualizer},

{‘malignant’: {‘expected_value’: 0.29,

’feature_names’: [‘worst concave points’, ‘worst perimeter’, ‘worst radius’], ‘shap_values’: [0.05, 0.03, 0.02], ‘plot’: AdditiveForceVisualizer}]

Return type

list[dict]

Raises
  • TypeError – If rows_to_explain is not a list.

  • TypeError – If all values in rows_to_explain aren’t integers.

evalml.model_understanding.force_plots.graph_force_plot(pipeline, rows_to_explain, training_data, y, matplotlib=False)[source]#

Function to generate force plots for the desired rows of the training data.

Parameters
  • pipeline (PipelineBase) – The pipeline to generate the force plot for.

  • rows_to_explain (list[int]) – A list of the indices indicating which of the rows of the training_data to explain.

  • training_data (pandas.DataFrame) – The data used to train the pipeline.

  • y (pandas.Series) – The target data for the pipeline.

  • matplotlib (bool) – flag to display the force plot using matplotlib (outside of jupyter) Defaults to False.

Returns

The same as force_plot(), but with an additional

key in each dictionary for the plot.

Return type

list[dict[shap.AdditiveForceVisualizer]]