force_plots#

力图。

模块内容#

函数#

force_plot

用于生成构建力图所需数据的函数。

graph_force_plot

用于为训练数据的所需行生成力图的函数。

内容#

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

用于生成构建力图所需数据的函数。

参数
  • pipeline (PipelineBase) – 要生成力图的管道。

  • rows_to_explain (list[int]) – 要解释的 training_data 的索引列表。

  • training_data (pandas.DataFrame) – 用于训练管道的数据。

  • y (pandas.Series) – 目标数据。

返回

字典列表,每个字典包含力图数据。每个字典

条目代表单行的解释。

对于单行二分类力图
[{‘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.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}]

返回类型

list[dict]

抛出
  • TypeError – 如果 rows_to_explain 不是列表。

  • TypeError – 如果 rows_to_explain 中的所有值都不是整数。

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

用于为训练数据的所需行生成力图的函数。

参数
  • pipeline (PipelineBase) – 要生成力图的管道。

  • rows_to_explain (list[int]) – 指示要解释 training_data 中哪些行的索引列表。

  • training_data (pandas.DataFrame) – 用于训练管道的数据。

  • y (pandas.Series) – 管道的目标数据。

  • matplotlib (bool) – 用于使用 matplotlib(在 jupyter 之外)显示力图的标志。默认为 False。

返回

与 force_plot() 相同,但每个字典中多了一个

用于图的键。

返回类型

list[dict[shap.AdditiveForceVisualizer]]