Exercise

# Computing association and dissociation

The library has returned to you once again about your recommendation to promote *Harry Potter* using *Twilight*. They're worried that the two might be dissociated, which could have a negative impact on their promotional effort. They ask you to verify that this is not the case.

You immediately think of Zhang's metric, which measures association and dissociation continuously. Association is positive and dissociation is negative. As with the previous exercises, the DataFrame `books`

has been imported for you, along with `numpy`

under the alias `np`

. Zhang's metric is computed as follows:

$$Zhang(A \rightarrow B) = $$ $$\frac{Support(A \& B) - Support(A) Support(B)}{ max[Support(AB) (1-Support(A)), Support(A)(Support(B)-Support(AB)]}$$

Instructions

**100 XP**

- Compute the support of
*{Twilight}*and the support of*{Potter}*. - Compute the support of
*{Twilight, Potter}*. - Complete the expression for the denominator.
- Compute Zhang's metric for
*{Twilight}*\(\rightarrow\)*{Potter}*.