Filtering with support and conviction
In the video, we discussed the continued consulting work you are doing for the founder of an ebook selling start-up. The founder has approached you with the DataFrame rules
, which contains the work of a data scientist who was previously on staff. It includes columns for antecedents and consequents, along with the performance for each of those rules with respect to a number of metrics.
Your objective will be to perform multi-metric filtering on the dataset to identify potentially useful rules. Note that pandas
is available as pd
and numpy
as np
. Additionally, rules
has been defined and is available.
Este exercício faz parte do curso
Market Basket Analysis in Python
Instruções do exercício
- Use the
.head()
method with print to preview the dataset. - Select the subset of rules with an antecedent support greater than 0.05.
- Select the subset of rules with a consequent support greater than 0.02.
- Select the subset of rules with a conviction greater than 1.01.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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)