开始使用免费开始使用

使用 lift 的热图

创始人很喜欢您为她的流媒体服务制作的热图。不过,在进一步讨论项目后,您们决定在最终确定要授权的电影前,还需要查看其他评估指标。特别是,创始人建议选择一种指标,用来判断某个共现支持度是否高于基于各自单片支持度所能预期的水平。

您想起 lift 正适合这个目的,决定将其作为指标。您也记得 lift 在 1.0 处有一个重要阈值,因此决定关闭颜色条并开启标注,便于判断某个值是否大于 1.0。请注意,上一练习得到的规则已保存在 rules 中,可供使用。

本练习是课程的一部分

Python 中的购物篮分析

查看课程

练习说明

  • 按标准别名导入 seaborn
  • 使用 lift 指标将包含规则的 DataFrame 转换为矩阵。
  • 生成一个热图,开启标注 annot,关闭颜色条 cbar

交互式实操练习

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

# Import seaborn under its standard alias
____

# Transform the DataFrame of rules into a matrix using the lift metric
pivot = rules.____(index = 'consequents', 
                   columns = 'antecedents', values= '____')

# Generate a heatmap with annotations on and the colorbar off
sns.heatmap(pivot, annot = ____, ____)
plt.yticks(rotation=0)
plt.xticks(rotation=90)
plt.show()
编辑并运行代码