시작하기무료로 시작하기

support와 conviction으로 필터링하기

영상에서, 전자책 판매 스타트업의 창업자를 계속해서 자문하고 있다는 상황을 살펴봤어요. 창업자는 이전에 근무하던 데이터 과학자가 만든 작업물이 담긴 DataFrame rules를 가져왔습니다. 이 DataFrame에는 전건(antecedents)과 후건(consequents) 열이 있으며, 여러 지표 관점에서 각 규칙의 성능이 포함되어 있어요.

여러 지표를 한꺼번에 적용해 데이터셋을 필터링하여 잠재적으로 유용한 규칙을 찾아보세요. 참고로 pandaspd, numpynp로 제공됩니다. 또한 rules는 이미 정의되어 있어 바로 사용할 수 있습니다.

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

Python으로 배우는 Market Basket Analysis

강의 보기

연습 안내

  • .head() 메서드를 print와 함께 사용하여 데이터셋을 미리 살펴보세요.
  • 전건 지원도(antecedent support)가 0.05보다 큰 규칙의 부분집합을 선택하세요.
  • 후건 지원도(consequent support)가 0.02보다 큰 규칙의 부분집합을 선택하세요.
  • conviction이 1.01보다 큰 규칙의 부분집합을 선택하세요.

실습형 인터랙티브 연습

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

# 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)
코드 편집 및 실행