BaşlayınÜcretsiz Başlayın

Computing conviction

After hearing about the useful advice you provided to the library, the founder of a small ebook selling start-up approaches you for consulting services. As a test of your abilities, she asks you if you are able to compute conviction for the rule {Potter} \(\rightarrow\) {Hunger}, so she can decide whether to place the books next to each other on the company's website. Fortunately, you still have access to the goodreads-10k data, which is available as books. Additionally, pandas has been imported as pd and numpy as np.

Bu egzersiz

Market Basket Analysis in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Compute the support for {Potter} and assign it to supportP.
  • Compute the support for NOT {Hunger}.
  • Compute the support for {Potter} and NOT {Hunger}.
  • Complete the expression for the conviction metric in the return statement.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Compute support for Potter AND Hunger
supportPH = np.logical_and(books['Potter'], books['Hunger']).mean()

# Compute support for Potter
supportP = ____.mean()

# Compute support for NOT Hunger
supportnH = 1.0 - books['____'].mean()

# Compute support for Potter and NOT Hunger
supportPnH = ____ - supportPH

# Compute and print conviction for Potter -> Hunger
conviction = ____ * supportnH / supportPnH
print("Conviction: %.2f" % conviction)
Kodu Düzenle ve Çalıştır