开始使用免费开始使用

绘制相对重要性热力图

做得好!现在,您将构建一个热力图,用于可视化每个簇的相对得分。

我们已将相对重要性得分加载为 relative_impseaborn 库已以 sns 加载,matplotlibpyplot 模块可通过 plt 使用。

本练习是课程的一部分

Python 中的客户细分

查看课程

练习说明

  • 使用 8×2 英寸的图像尺寸初始化一个绘图。
  • 添加图标题。
  • 基于 relative_imp 数据绘制热力图。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Initialize a plot with a figure size of 8 by 2 inches 
plt.____(____=(____, ____))

# Add the plot title
plt.____('Relative importance of attributes')

# Plot the heatmap
sns.____(data=____, annot=True, ____='.2f', ____='RdYlGn')
plt.show()
编辑并运行代码