绘制相对重要性热力图
做得好!现在,您将构建一个热力图,用于可视化每个簇的相对得分。
我们已将相对重要性得分加载为 relative_imp。seaborn 库已以 sns 加载,matplotlib 的 pyplot 模块可通过 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()