Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Market Basket Analysis in Python

Cursus bekijken

Oefeninstructies

  • 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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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)
Code bewerken en uitvoeren