HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    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
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Course 3 -- Supervised Learning 前面講說,Supervised Learning 可以分為,Classification 和 Regression 兩種。 首先來說一下,Classification。 ## Classification 一個分類問題,主要可以讓接下來所給予未被判別的資料, 得到分類過後的解答,是或不是被分在此類。 若有兩種類型,則此分類方式可以稱為 Binary classification 以下列舉出幾種此類型方法: 1. [k-NN](https://zh.wikipedia.org/wiki/K-%E8%BF%91%E9%82%BB%E7%AE%97%E6%B3%95) 2. [SVM (Support Vector Machine)](https://zh.wikipedia.org/wiki/%E6%94%AF%E6%8C%81%E5%90%91%E9%87%8F%E6%9C%BA) 其中的 hyper-parameters 不是由演算法制定,接由人為決定,例如: * k-NN 中 K 的值 * SVM 中 kernel 的類別 (linear, polynomial, rbf...) ## Linear classifier * 在機器學習領域,分類的目標是指將具有相似特徵的對象聚集。 * 而一個線性分類器則==透過特徵的線性組合來做出分類決定==,以達到目的。 * 對象的特徵通常被描述為特徵值,而在向量中則描述為特徵向量。 對於一個二元分類問題,可以設想成是==將一個線性分類利用超平面劃分高維空間==的情況: 在超平面一側的所有點都被分類成"是",另一側則分成"否"。 $f(x) = w^{T}x + b, (b \ is \ scalar)$ $x ∈ A \ if \ f(x) < 0, otherwise \ x ∈ B$ ## Data Partition * Training Set * Validation Set: used to fine-tune hyper-parameters * Testing Set We use accuracy in test set to predict actual accuracy in the future (called **==generalization accuracy==**) ## Model Complexity Model complexity is measured by ==VC-dimension== 多於二類的分類問題稱為 multiclass classification problem 可分為以下幾種: * One vs one: 最多需要 $\frac{M(M-1)}{2}$ 個平面去分類 M-calss 問題 * One vs all: 最多需要 $M-1$ 個平面去分類 M-class 問題 * ... ## k-NN * k-nearest neighbors algorithm (k-NN) 是一種非參數方法 * 基於即時的學習(也稱為懶惰學習) * k 是一個參數 * k-NN 是個 discriminative model (判斷模型) ### Training (model fit) Store the feature vectors and class labels of the training samples ### Classification (prediction) Unlabeled vector (a query or test point) is classified by assigning the label which is most frequent among ==the k training samples nearest to that query point== $x_{i}$ 是一個特徵空間,即為鄰近之 k 的點 而 k-NN 是基於 Occam’s razor principle 實作,即為「**切勿浪費多餘功夫去做本可以較少功夫完成之事**」。換言之,如果關於同一個問題有許多種理論,每一種都能作出同樣準確的預言,那麼應該挑選其中使用假定最少的。 Classification 講完來說 Regression ## Linear regression 主要服務連續型數據,再給予數據後判斷此數據的趨勢為何。 設此 function 為 $y = ax + b$ 我們已經有$(x_{1}, y_{1}), ... , (x_{10}, y_{10})$,如何藉此數據出找出,a 和 b ==有方法叫做 Least-square solution== Let $J\left(a,b\right) = \sum_{i=1}^{10}\left(y_i-\left(ax_i+b\right)\right)^2$ 並尋找參數 a 和 b 的值,使得 J 能夠有最小值,$arg_{a,b} \ min \ J\left(a,b\right)$ 以下皆可實作成 Regression: 1. [Gradient Descent](https://medium.com/@jackson1998/note-machine-learning-lecture-1-e455cb56d38c#:~:text=find%20best%20function-,Gradient%20Descent,-%E7%9B%AE%E7%9A%84%20%3A%20%E5%B0%8B%E6%89%BE%E6%9C%80%E5%B0%8F) 2. [k-NN](https://zh.wikipedia.org/wiki/K-%E8%BF%91%E9%82%BB%E7%AE%97%E6%B3%95) 而如何判斷說 Regression error,是藉由 MSE (mean square error) ## [Bias & Variance](https://towardsdatascience.com/understanding-the-bias-variance-tradeoff-165e6942b229) * Bias: 偏差是模型平均預測與實際正確值的差異 * Variance: 數據分布在模型預測的變異性 ![](https://i.imgur.com/GE51uCs.png) 而通常若模型過於簡單會導致有較高的 Bias 以及較低的 Variance 相反地,當模型參數增加,Variance 會增高,而 Bias 會降低 ![](https://i.imgur.com/CiwFccH.png) 整體 Error 的公式如下: ![](https://i.imgur.com/KAa4rOL.png)

    Import from clipboard

    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 lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in via Google

    New to HackMD? Sign up

    Help

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

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    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

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    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. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        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
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

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

        Syncing

        Push failed

        Push successfully