SlideShare a Scribd company logo
1 of 19
Download to read offline
Naive Bayes classifier
이희덕, 20091435
9TH, MAY, 2013
필기 숫자 인식기
문제의 이해
 숫자는 0에서 9까지 존재하고, 이를 컴퓨터에서는 일종의 데이터로 표현할
수 있다.
Ex) “2”(10) → 10(2)
 “그림”으로 된 “숫자“가 있을 때, 컴퓨터가 숫자 “데이터”를 인식하는 방법
에 대해 고려해 보자.
분류기
2
그림 “2” 데이터 “2”
그림 숫자 인식
그림으로 된 숫자
모양이 “정해진“
숫자
모양이
“정해지지 않은“
숫자
활자체 인식
필기체 인식
활자
활자체숫자인식
숫자의 모양이 정해져있음.
예) Helvetica체를 사용
크기와 회전정도를 같게 한다음에
일치하는지 대조
Helvetica체의
0에서 9까지의 숫자를 인식함
(10번의 비교 동작내의 인식가능)
2
0 1 2 3 4 5 6 7 8 9
필기체숫자인식
“사람의 필기체는 „자획구성‟, „자획형태„, „필순„, „배자„, „필세„, „오자„, „오용‟등을 구분해
확연한 개성을 가지기 때문에 각 개인임을 분류 할 수 있습니다”
- 국립과학수사연구원 필적감정사 “한정수“ 수석연구원
필기체숫자인식
1. 글자를 그리는 순서로 결정
> 왼손잡이, 오른손잡이의
경우에는
2. 획의 방향으로 결정
> 1의 경우 왼쪽, 오른쪽으로
내려 긋는 방향이 다름
3. 획의 개수로 결정
> 컴퓨터에서 획의 개수를
어떻게 구할수있을까?
한 획을 생략하는 경우에는?
4. 대략적인 모양의
일치 확률로 결정
사용된 데이터
 “대략적인 모양의 일치 확률로 구분한다는데, 그럼 수 없이 많은 숫자 모양
에 대한 정보가 필요하지 않나요?”
 THE MNIST DATABASE of handwritten digits
약 6만개의 0부터 9까지의 각각 다른 개인별 필적에 대한 정보가 있음.
http://yann.lecun.com/exdb/mnist/
 28x28 의 이미지 파일 형태와, 필기를 한 사람이 실제로 쓰려고 한 숫자 데
이터 정보로 구성됨
Naive Bayes classifier
 사후확률은 사전확률과 우도들의 곱셈으로 구할 수 있음.
 이 문제에서의 사전확률은?
“이 숫자가, 0부터 9중 하나일 확률“ -> 모든 경우들이 0.1로 동일
 이 문제에서의 우도는? -> 우도(“클래스 조건 확률“)에 들어가는 조건은?
조건1)
픽셀이 흰색인 경우 0으로 나타냄
조건2)
픽셀이 검은색인 경우 1로 나타냄
Navie Bayes classifier - likelihood
0,2가 on일때 우도 = 0,2가 on일 때의 개수 / 전체 데이터의 개수
= 2 / 3 = 0.6666
Naive Bayes classifier
 3의 경우를 예로들어,
{F0,0 = 0, F0,1 = 0, F0,2 = 1, …… ,
F8,8=0}
 나이브 베이지안 모델
배열의 클래스 사후확률 =
사전확률 x 배열의 시작지점 0,0부터 끝지
점 8,8까지의 우도
 0….9까지 사후확률을 구해 최대값으로
결정
Naive Bayes classifier
1 0.1
2 0.1
3 0.1
4 0.1
5 0.1
6 0.1
7 0.1
8 0.1
9 0.1
0 0.1
1 0.01
2 0.05
3 0.05
4 0.30
5 0.80
6 0.90
7 0.05
8 0.60
9 0.50
0 0.80
1 0.05
2 0.01
3 0.90
4 0.80
5 0.90
6 0.90
7 0.05
8 0.60
9 0.50
0 0.80
사전확률 3,1이 꺼져있을때 우도 5,5가 켜져있을때 우도
Naive Bayes classifier
2인 경우 사후확률 3인 경우 사후확률
사전확률 = 0.1 사전확률 = 0.1
2,2 픽셀이 On일경우
0.8
2,2 픽셀이 On일경우
0.9
5,4 픽셀이 On일경우
0.1
5,4 픽셀이 On일경우
0.8
6,4 픽셀이 Off일경우
0.1
6,4 픽셀이 Off일경우
0.8
0.0008 0.0567
<
Naive Bayes classifier – 과적합현상
2인 경우 사후확률 3인 경우 사후확률
사전확률 = 0.1 사전확률 = 0.1
2,2 픽셀이 On일경우
0.8
2,2 픽셀이 On일경우
0.9
5,4 픽셀이 On일경우
0.1
5,4 픽셀이 On일경우
0.8
6,4 픽셀이 Off일경우
0.1
6,4 픽셀이 Off일경우
0.8
0.00008 0
>
8,8 픽셀이 On일경우
0.01
8,8 픽셀이 On일경우
0
Pseudo code
Int bayesclassifier(input[][], likelihood[][][])
{
Int result[10];
For(I = 0; I < 10; i++)
{
Result[i] = 0.1;
For(j = 0; j < 28; j++)
For(k=0; k<28; k++)
{
if(input[j][k] == 0)
Result[i] *= likelihood[i][j][k];
else
Result[i] *= (1 – likelihood[i][j][k];
}
}
Int max = -999;
Int maxi = 0;
For(int I = 0; i < 10; I++)
{
if(max < result[i])
{
max = result[i];
maxi = I;
}
}
Return maxi;
}
Void likelihoodcalc(input[][][], label[])
{
Int numcnt[10];
Double likelihood[10][28][28];
For(I = 0; I < 10000; i++)
{
numcnt[label[i]]++;
For(j = 0; I < 28; j++)
For(k=0; k<28; k++)
if(input[i][j][k] == 1)
likelihood[label[i]][j][k]++;
}
For(I = 0; I < 10; i++)
{
For(j = 0; j < 28; j++)
For(k = 0; k < 28; k++)
likelihood[i][j][k] = likelihood[i][j][k] /
numcnt[i];
}
}
Demo
Q&A
감사합니다.

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Naive bayes classifier - digit recognition

  • 1. Naive Bayes classifier 이희덕, 20091435 9TH, MAY, 2013
  • 3. 문제의 이해  숫자는 0에서 9까지 존재하고, 이를 컴퓨터에서는 일종의 데이터로 표현할 수 있다. Ex) “2”(10) → 10(2)  “그림”으로 된 “숫자“가 있을 때, 컴퓨터가 숫자 “데이터”를 인식하는 방법 에 대해 고려해 보자. 분류기 2 그림 “2” 데이터 “2”
  • 4. 그림 숫자 인식 그림으로 된 숫자 모양이 “정해진“ 숫자 모양이 “정해지지 않은“ 숫자 활자체 인식 필기체 인식
  • 6. 활자체숫자인식 숫자의 모양이 정해져있음. 예) Helvetica체를 사용 크기와 회전정도를 같게 한다음에 일치하는지 대조 Helvetica체의 0에서 9까지의 숫자를 인식함 (10번의 비교 동작내의 인식가능) 2 0 1 2 3 4 5 6 7 8 9
  • 7. 필기체숫자인식 “사람의 필기체는 „자획구성‟, „자획형태„, „필순„, „배자„, „필세„, „오자„, „오용‟등을 구분해 확연한 개성을 가지기 때문에 각 개인임을 분류 할 수 있습니다” - 국립과학수사연구원 필적감정사 “한정수“ 수석연구원
  • 8. 필기체숫자인식 1. 글자를 그리는 순서로 결정 > 왼손잡이, 오른손잡이의 경우에는 2. 획의 방향으로 결정 > 1의 경우 왼쪽, 오른쪽으로 내려 긋는 방향이 다름 3. 획의 개수로 결정 > 컴퓨터에서 획의 개수를 어떻게 구할수있을까? 한 획을 생략하는 경우에는? 4. 대략적인 모양의 일치 확률로 결정
  • 9. 사용된 데이터  “대략적인 모양의 일치 확률로 구분한다는데, 그럼 수 없이 많은 숫자 모양 에 대한 정보가 필요하지 않나요?”  THE MNIST DATABASE of handwritten digits 약 6만개의 0부터 9까지의 각각 다른 개인별 필적에 대한 정보가 있음. http://yann.lecun.com/exdb/mnist/  28x28 의 이미지 파일 형태와, 필기를 한 사람이 실제로 쓰려고 한 숫자 데 이터 정보로 구성됨
  • 10. Naive Bayes classifier  사후확률은 사전확률과 우도들의 곱셈으로 구할 수 있음.  이 문제에서의 사전확률은? “이 숫자가, 0부터 9중 하나일 확률“ -> 모든 경우들이 0.1로 동일  이 문제에서의 우도는? -> 우도(“클래스 조건 확률“)에 들어가는 조건은? 조건1) 픽셀이 흰색인 경우 0으로 나타냄 조건2) 픽셀이 검은색인 경우 1로 나타냄
  • 11. Navie Bayes classifier - likelihood 0,2가 on일때 우도 = 0,2가 on일 때의 개수 / 전체 데이터의 개수 = 2 / 3 = 0.6666
  • 12. Naive Bayes classifier  3의 경우를 예로들어, {F0,0 = 0, F0,1 = 0, F0,2 = 1, …… , F8,8=0}  나이브 베이지안 모델 배열의 클래스 사후확률 = 사전확률 x 배열의 시작지점 0,0부터 끝지 점 8,8까지의 우도  0….9까지 사후확률을 구해 최대값으로 결정
  • 13. Naive Bayes classifier 1 0.1 2 0.1 3 0.1 4 0.1 5 0.1 6 0.1 7 0.1 8 0.1 9 0.1 0 0.1 1 0.01 2 0.05 3 0.05 4 0.30 5 0.80 6 0.90 7 0.05 8 0.60 9 0.50 0 0.80 1 0.05 2 0.01 3 0.90 4 0.80 5 0.90 6 0.90 7 0.05 8 0.60 9 0.50 0 0.80 사전확률 3,1이 꺼져있을때 우도 5,5가 켜져있을때 우도
  • 14. Naive Bayes classifier 2인 경우 사후확률 3인 경우 사후확률 사전확률 = 0.1 사전확률 = 0.1 2,2 픽셀이 On일경우 0.8 2,2 픽셀이 On일경우 0.9 5,4 픽셀이 On일경우 0.1 5,4 픽셀이 On일경우 0.8 6,4 픽셀이 Off일경우 0.1 6,4 픽셀이 Off일경우 0.8 0.0008 0.0567 <
  • 15. Naive Bayes classifier – 과적합현상 2인 경우 사후확률 3인 경우 사후확률 사전확률 = 0.1 사전확률 = 0.1 2,2 픽셀이 On일경우 0.8 2,2 픽셀이 On일경우 0.9 5,4 픽셀이 On일경우 0.1 5,4 픽셀이 On일경우 0.8 6,4 픽셀이 Off일경우 0.1 6,4 픽셀이 Off일경우 0.8 0.00008 0 > 8,8 픽셀이 On일경우 0.01 8,8 픽셀이 On일경우 0
  • 16. Pseudo code Int bayesclassifier(input[][], likelihood[][][]) { Int result[10]; For(I = 0; I < 10; i++) { Result[i] = 0.1; For(j = 0; j < 28; j++) For(k=0; k<28; k++) { if(input[j][k] == 0) Result[i] *= likelihood[i][j][k]; else Result[i] *= (1 – likelihood[i][j][k]; } } Int max = -999; Int maxi = 0; For(int I = 0; i < 10; I++) { if(max < result[i]) { max = result[i]; maxi = I; } } Return maxi; } Void likelihoodcalc(input[][][], label[]) { Int numcnt[10]; Double likelihood[10][28][28]; For(I = 0; I < 10000; i++) { numcnt[label[i]]++; For(j = 0; I < 28; j++) For(k=0; k<28; k++) if(input[i][j][k] == 1) likelihood[label[i]][j][k]++; } For(I = 0; I < 10; i++) { For(j = 0; j < 28; j++) For(k = 0; k < 28; k++) likelihood[i][j][k] = likelihood[i][j][k] / numcnt[i]; } }
  • 17. Demo
  • 18. Q&A