support と conviction によるフィルタリング
動画では、あなたが電子書籍販売のスタートアップ創業者に継続的なコンサルティングを行っている状況について説明しました。創業者からは、かつて在籍していたデータサイエンティストの作業結果を含む DataFrame rules が共有されています。これには、前件(antecedents)と後件(consequents)の列に加え、複数の指標に対する各ルールのパフォーマンスが含まれています。
あなたの目的は、このデータセットに対して複数の指標を用いたフィルタリングを行い、有用になり得るルールを特定することです。pandas は pd、numpy は np として利用できます。さらに、rules はすでに定義済みで利用可能です。
この演習はコースの一部です
Python で学ぶマーケットバスケット分析
演習の手順
.head()メソッドを print と併用して、データセットをプレビューしてください。- antecedent 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)