Try   HackMD
tags: machine learning|python

機器學習 - 單純貝氏分類器(Naive Bayes)

介紹

  • 假設特徵之間強(樸素)獨立下運用貝氏定理為基礎的簡單機率分類器
  • 特徵之間為相互獨立的(但現實中不太可能完全獨立),公式為
    P(A|X)=P(X|A)P(A)P(X)
    (
    X
    為特徵,
    A
    為類別)

貝式定理

公式:

P(A|B)=P(B|A)P(A)P(B)

P(A|B)表示在B發生的情況下,A發生的機率為何

例子

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Ans:

P(Defect|Mach2)=P(Mach2|Defect)P(Defect)P(Mach1)=0.50.010.4=0.0125=1.25
%

Naive Bayes

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

P(Walks|X)=P(X|Walks)P(Walks)P(X)
P(Drives|X)=P(X|Drives)P(Drives)P(X)

  • Likelihood為可能性,表示獨立特徵X(以此例來說是
    Salary
    Age
    )發生的可能性
  • 用來比較
    P(Walks|X)
    P(Drives|X)
    哪個較高,較高者就將此資料點分為那類(以此例來說是
    Walks
    Drives
    )

算法

我還沒寫ouo

程式碼操作

練習

機器學習-第14週教學影片觀看【Naive Bayes(單純貝氏分類器)】

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Ans:

  1. P(Defect|Mach1)=P(Mach1|Defect)P(Defect)P(Mach1)=0.50.010.6=0.0083¯=0.833
    %
  2. 運用貝氏定理為基礎的簡單機率分類器,特徵之間為相互獨立的(但現實中不太可能完全獨立),公式為
    P(A|X)=P(X|A)P(A)P(X)
    (
    X
    為特徵,
    A
    為類別)

機器學習-作業