ComeçarComece de graça

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.

Este exercício faz parte do curso

Market Basket Analysis in Python

Ver curso

Instruções do exercício

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

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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)
Editar e executar o código