시작하기무료로 시작하기

conviction으로 eBook 프로모션 살펴보기

이전 연습 문제에서는 conviction을 계산하는 함수를 정의했어요. 그 함수를 goodreads-10k 데이터셋의 모든 두 책 순열에 적용하라는 요청이 있었죠. 이번 연습에서는 이전에 사용했던 가장 인기 있는 세 권의 책, The Hunger Games, Harry Potter, Twilight에 그 함수를 적용해 테스트해 보겠습니다.

함수는 이미 정의되어 있으며 conviction으로 제공됩니다. 이 함수는 전건(antecedent)과 후건(consequent) 두 개의 인수를 받는다는 점을 기억하세요. 또한 이전 연습에서 사용한 books DataFrame의 열들은 각각 별도의 DataFrame으로 제공되며, 이름은 potter, twilight, hunger입니다.

이 연습은 강의의 일부입니다

Python으로 배우는 Market Basket Analysis

강의 보기

연습 안내

  • {Twilight} \(\rightarrow\) {Potter}{Potter} \(\rightarrow\) {Twilight}의 conviction을 계산하세요.
  • {Twilight} \(\rightarrow\) {Hunger}{Hunger} \(\rightarrow\) {Twilight}의 conviction을 계산하세요.
  • {Potter} \(\rightarrow\) {Hunger}{Hunger} \(\rightarrow\) {Potter}의 conviction을 계산하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Compute conviction for twilight -> potter and potter -> twilight
convictionTP = conviction(twilight, potter)
convictionPT = conviction(____, twilight)

# Compute conviction for twilight -> hunger and hunger -> twilight
convictionTH = conviction(____, ____)
convictionHT = ____(hunger, twilight)

# Compute conviction for potter -> hunger and hunger -> potter
convictionPH = ____(potter, hunger)
convictionHP = ____

# Print results
print('Harry Potter -> Twilight: ', convictionHT)
print('Twilight -> Potter: ', convictionTP)
코드 편집 및 실행