Try   HackMD
tags: machine learning|python

機器學習 - R平方(R Squared)

介紹

  • 方程式:
    R2=1SSresSStot
  • R2
    大代表模型是理想的
  • R2
    落在0~1之間
  • 自變量不論是否改變,都不會影響總平方和
    SStot
    ,故分母不變
  • 斜直線落在哪,會改變
    yi^
    ,即改變殘差平方和
    SSres
    ,故分子會改變
    SSres
    小(斜線上
    yi^
    和所有點
    yi
    差距小),
    SStot
    不變,
    R2

    SSres
    大(斜線上
    yi^
    和所有點
    yi
    差距大
    不理想),
    SStot
    不變,
    R2

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


調整R平方(Adjusted R Squared)

前言

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

原因:
假設應變量

y為薪水,自變量
x1
為工作年資、
x2
為證照數
x2
是合適的自變量,可解釋應變量與自變量的關係,殘差平方和
SSres
會變小,
R2
變大
假設
x3
為身分證第一碼,與應變量沒任何關係,
b3=0
,殘差平方和
SSres
不變,
R2
不變

介紹

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • 為了解決自變量不斷盲目增加,使
    SSres
    不斷變小,
    R2
    不斷變大的情況
  • 方程式:
    Adj R2=1(1R2)×n1np1

    p:number of regressors 自變量個數
    n:sample size 資料個數

  • 自變量變多不一定是好的
    p
    變大,其他參數不變,
    Adj R2
    變小
  • (1R2)
    n1np1

    p
    變大能使
    SSres
    變更小,
    R2
    變大,
    (1R2)
    變小,
    n1np1
    變大
    (1R2)
    n1np1
    互相拉扯

結論:

  1. 自變量個數增加,若能使
    R2
    上升幅度足夠【影響
    (1R2)
    】,則
    Adj R2
    變大
  2. 自變量個數增加,若
    R2
    上升幅度不足夠,則
    Adj R2
    變小