認真作筆記的你真的很棒!
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 貝氏定理 [TOC] ## 機率原理介紹 * 條件機率 * 交集、聯集 * Margianl Probability:將指定機率相加起來的結果 * 獨立定義 # 貝氏分類器 ## Decision Theory 剛剛有提到貝氏定律的原理,而ML也是特過部分已知的特徵,來決定最後的label,這和貝氏定理有異曲同工之妙 ![](https://i.imgur.com/UP8RwiX.png) ## Terms of Bayes Theorem ![](https://i.imgur.com/SxsqCvn.png) * X: 證據,如魚的長度為3公分 * H: 未知的假設,如猜測這條魚是一隻鮭魚 * P(H): priorb proability,假設成立的可能性 * 假設先捕捉1000隻魚,觀察是鮭魚的機率 * P(X): evidence probability,已知的證據成立的可能性,如這條魚真的是3公分 * 假設先捕捉1000隻魚,觀察是3公分的機率 * P(X|H): likelihood,已知假設成立,則符合證據的likelihood(似然度) * P(H|X): posterior probability,已知證據成立,則假設亦成立的posterior probability(後驗機率) * 今天有一條新的魚,只知道他為三公分,則預測他是否為鮭魚 ## Bayes Formula ![](https://i.imgur.com/M79rwVO.png) ## Problem Type #### Decision before Observations ### Decision after Observations * 例子: 假設我們現在已經知道這條魚確切的身長(X),那我們該如何利用X證明H呢 ![](img from page 38) ## Class-conditional Probability Desnity Function ![](https://i.imgur.com/1LZwNY3.png) * 例: 今天要從樣本當中魚的長度判斷說這條魚是哪種魚,則我們應該會有以下條件 * 樣本魚的長度範圍(可能從20~50cm) * 兩種魚出現的機率(A魚有30%,B魚有70%) * 這兩種魚的長度分布pdf(可能有20%A魚有30公分之類的) 從這三種來推斷說當今天抓了一條45公分的魚,則最可能為哪一種魚 * 公式為P(X|H) * ![](https://i.imgur.com/2H20kDZ.png) * 你也可以將已知的證據與圖之間的關係畫出來 接著我們就可以根據\*X的值,來判斷比較有可能是哪個類別 已知的部分: * Prior probability: P(H) * Class-conditional pdf: P(X|H) * 證據們: \*X * 自己覺得這邊有點像是Random Variable的概念 Bayes Formula: 把已知的部分轉換成未知的機率P(H|\*X) 未知的部分: P(H|\*X) ## 貝氏分類法 ### 介紹 * A statistical classifier: predict class的memebership/label的機率 * Foundation(理論): 基於貝氏定理所推出 * Performance(效能表現):跟decision tree和選擇性的CNN有的比 * Standard: 雖然有時候很難靠著貝氏定律直接算出想要的答案結果,但是可以靠著貝氏來判段衡量哪種計算方式比較好 ### Prediction on Baye's Theorem ![](img from page 58 up) 其實也是上面筆記有提到的部分 ### Naive Bayes Classifier 那現在要介紹的Naive Bayes Classifier又跟上面所提到的部份差在哪裡呢? 現在我們可以有很多個Feature\(x~1~\~x~n~\)及多個事件\(C~1~\~C~n~\) 而Naive Bayes Classifier就是透過條件機率來探討 ![](img from page 60 up) 則我們可透過上述公式中知道如果想了解一個特定事件,則需要了解已知該事件的情況下,所有X的發生機率為多少。 而如果想算出P(X~i~|C~i),又須了解該事件分布是否為連續 * 若不連續,就按照發生事情的數量相持即可 * 若為連續,則透過平均數與標準差計算 * ![](img from page 60 down) * miu為平均數 * sigma為標準差 #### Example 現在來分析(age <=30, Income = medium, Student = yes, Credit_rating = Fair)的顧客買與不買哪個機率較高 ![](table from page 61) 算法如下 ![](whole calculating process from page 62) #### 分析 * 優點: * 比較好去做計算(至少還勉強算得出來) * 在大多數的情況下都可以有不錯的結果 * 缺點: * 該分類法假設所有事件都是完全獨立的,但有時候有些class/label是有關連性的 * 例如:假設今天有人有高血壓的問題,則它同時也有心臟病的問題可能也會高一些 ### Avoiding the Zero-Probability 今天公式如下: ![](img from page 64 up) 如果今天有一個子事件是沒有發生過的,則很有可能會有分母為0的不好狀況,因此我們會透過laplacian correction來從其他子事件當中移一些過去 ## 模型評估與選擇 ### Confusion Matrix ![](img from page 67 up) 下面是實際計算的例子 ![](img from page 67 down)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully