LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Market Basket Analysis in Python

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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 bearbeiten und ausführen