按 support 与 conviction 进行筛选
在视频中,我们继续了您为一家电子书销售初创公司创始人提供咨询的案例。创始人向您提供了一个名为 rules 的 DataFrame,它包含了一位前员工数据科学家的工作成果。该数据包含前件(antecedents)和后件(consequents)两列,以及针对多种评估指标的规则表现。
您的目标是对该数据集进行多指标筛选,以找出可能有用的规则。请注意,pandas 已以 pd 导入,numpy 以 np 导入。此外,rules 已经定义并可直接使用。
本练习是课程的一部分
Python 中的购物篮分析
练习说明
- 使用
.head()方法配合 print 预览数据集。 - 选择前件 support 大于 0.05 的规则子集。
- 选择后件 consequent support 大于 0.02 的规则子集。
- 选择 conviction 大于 1.01 的规则子集。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Preview the rules DataFrame using the .head() method
print(____)
# Select the subset of rules with antecedent support greater than 0.05
rules = rules[rules['antecedent support'] > ____]
# Select the subset of rules with a consequent support greater than 0.02
rules = rules[____]
# Select the subset of rules with a conviction greater than 1.01
rules = ____
# Print remaining rules
print(rules)