집단지성프로그래밍 - 6장 문서 필터링

24
문문 문문문 집집집집 집집집집집 Ch.6 문문

Transcript of 집단지성프로그래밍 - 6장 문서 필터링

Page 1: 집단지성프로그래밍 - 6장 문서 필터링

문서 필터링집단지성 프로그래밍 Ch.6

허윤

Page 2: 집단지성프로그래밍 - 6장 문서 필터링

Document Filtering

Filtering == Classification Problem

Data Mining Problem

Estimation Classification Predication

Clustering Description

Affinity Grouping

Document?A set of feature -> text document, image, etc.

p( document ) = ?

Page 3: 집단지성프로그래밍 - 6장 문서 필터링

Spam Filtering

Binary Classification Problem

‘Spam’ or ‘Ham’

Techniques

Naïve Bayesian Classifier

Support Vector Machine

Decision Tree

Rule vs. Modelpros and cons

Page 4: 집단지성프로그래밍 - 6장 문서 필터링

Spam Filtering in Practice

Referred at: Sahil Puri1 et al, “COMPARISON AND ANALYSIS OF SPAM DETECTION ALGORITHMS”, 2013, IJAIEM

Page 5: 집단지성프로그래밍 - 6장 문서 필터링

Referred at: Rene, “New insights into Gmail’s spam filtering”, 2012, emailmarketingtipps.de

Page 6: 집단지성프로그래밍 - 6장 문서 필터링

Naïve Bayesian Classifier

Bayes Theorem

Naïve?

Bayesian Theorem with string independence assumption

Classifier ignore evidence term

Posterior1 > posterio2Posterior1 < posterio2

Page 7: 집단지성프로그래밍 - 6장 문서 필터링

Example

1. 상자 A 가 선택될 확률 P( A ) =  7 / 10 

2. 상자 A 에서 흰공 뽑힐 확률 P( 흰공 | A )=  2 / 10

3. 주머니에서는 A, 상자 A 에서 흰공 뽑힐 확률

4. 흰공의 확률

❶ ❷

Page 8: 집단지성프로그래밍 - 6장 문서 필터링

Example ❶ ❷

어디선가 흰공이 나왔는데… P( A | 흰공 )A 에서 나왔을 확률 ?

B 에서 나왔을 확률 ? P( B | 흰공 )

P( A | 흰공 ) = ?

Page 9: 집단지성프로그래밍 - 6장 문서 필터링

Bayes Rule

❶ Conditional Prob. A given B ❷ Conditional Prob. B given A

❸ Bayes Rule

Page 10: 집단지성프로그래밍 - 6장 문서 필터링

Document Representation Extracting words from document

Implementation: Preparation

Page 11: 집단지성프로그래밍 - 6장 문서 필터링

Implementation: Preparation

Representation of Classifier

{'python': {'bad': 0, 'good': 6}, 'the': {'bad': 3, 'good': 3}}

# getwords

Page 12: 집단지성프로그래밍 - 6장 문서 필터링

How to access dict

Implementation: Preparation

Page 13: 집단지성프로그래밍 - 6장 문서 필터링

Training

Implementation: Preparation

Page 14: 집단지성프로그래밍 - 6장 문서 필터링

Result

Implementation: Preparation

Page 15: 집단지성프로그래밍 - 6장 문서 필터링

Recall

Bayesian Theorem

p( category | doc ) = p( doc )

p( doc | category ) * p( category)

Page 16: 집단지성프로그래밍 - 6장 문서 필터링

Implementation : Classifier

P( feature | category ) as prior

Page 17: 집단지성프로그래밍 - 6장 문서 필터링

Assumed Probability to resolve data sparseness

Implementation : Classifier

Page 18: 집단지성프로그래밍 - 6장 문서 필터링

Results

Implementation : Classifier

Page 19: 집단지성프로그래밍 - 6장 문서 필터링

P( document | category ) as likelihood

Implementation : Classifier

Page 20: 집단지성프로그래밍 - 6장 문서 필터링

P( document | category ) * p( category )

Implementation : Classifier

Page 21: 집단지성프로그래밍 - 6장 문서 필터링

Classifying

Implementation : Classifier

Page 22: 집단지성프로그래밍 - 6장 문서 필터링

Result

Implementation : Classifier

Page 23: 집단지성프로그래밍 - 6장 문서 필터링

Recall: Naïve Bayesian Classifier

Fisher’s Method

Fisher’s Method

First, p( document| category ) = p( feature_1| category ) * p( feature_2| category ) … * p( feature_N| category )

p( category | document ) ??

p( category | feature ) = # of documents having feature in category

# of documents having feature

Page 24: 집단지성프로그래밍 - 6장 문서 필터링

Q&A

Thank You