Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
simpleregressionandleastsquares
Search
yuki
December 13, 2020
0
3.2k
simpleregressionandleastsquares
yuki
December 13, 2020
Tweet
Share
More Decks by yuki
See All by yuki
240315_発表資料_清水.pdf
yuyumoyuyu
2
720
230315_symposium
yuyumoyuyu
1
510
220305_kenkyukai
yuyumoyuyu
2
120
221124_kenkyukai
yuyumoyuyu
1
500
voltageequation5
yuyumoyuyu
1
11k
210910_kenkyukai
yuyumoyuyu
1
280
210826_bumontaikai
yuyumoyuyu
0
160
voltageequation4
yuyumoyuyu
33
14k
210518_iemdc
yuyumoyuyu
0
130
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
173
14k
Practical Orchestrator
shlominoach
190
11k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Testing 201, or: Great Expectations
jmmastey
45
7.7k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
4 Signs Your Business is Dying
shpigford
185
22k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
580
A better future with KSS
kneath
239
18k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
How to Think Like a Performance Engineer
csswizardry
27
2k
Speed Design
sergeychernyshev
32
1.1k
Transcript
最小二乗法を用いた単回帰分析 Simple Regression Analysis and Least Squares Method 大阪府立大学 工学研究科
清水 悠生
2 回帰分析とは? ✓ あるデータ群から,入力データ(x)と 目標データ(y)の関係をモデル化(数式化)し 両者の関係を定量的に分析することを回帰分析という ✓ モデル化した曲線(直線)のことを回帰曲線(直線)という x y
x y 回帰直線 y=ax+b 生データたち
3 どのように回帰直線を引くか? ✓ 回帰直線は各データをよく表すように引きたい… ⇒各データと回帰直線の誤差(残差)が最小となる ように回帰直線の係数a, bを決定する ✓ 機械学習の人は誤差,統計の人は残差と呼んでる印象 x
y i番目のデータ(x(i),y(i)) x(i) y(i) ax(i)+b 回帰直線 y=ax+b 誤差 (残差)
4 最小二乗法で扱う誤差関数 ✓ 誤差関数を誤差の2乗の和とし,誤差関数が最小となる ような係数a, bを計算する方法が最小二乗法 最小二乗法で扱う誤差関数E(a,b) , =
=1 1 2 () − () + 2 aとbの 2変数関数 誤差の2乗 x y i番目のデータ(x(i),y(i)) x(i) y(i) ax(i)+b 回帰直線 y=ax+b 誤差 (残差) 各データの2乗誤差を 全データ(n個)足し合わせたもの
5 誤差関数は下に凸の2次関数 ✓ 誤差関数をa,bそれぞれに着目して展開すると それぞれ下に凸の2次関数であることがわかる ✓ 偏微分により簡単に最小値を求めることが可能 , =
=1 1 2 () − () + 2 = =1 1 2 () 2 − 2() () − + () − 2 =1 1 2 2 + 2 () − () + () − () 2 E a E b a,bどちらに着目しても 誤差関数はa,bに関して下に凸の2次関数 (狭義の凸関数と呼ばれる) 最小となる1点が存在
6 誤差関数を最小化する(1/2) ✓ 誤差関数をa,bそれぞれ偏微分して0とし連立方程式を 解くことで,誤差関数を最小とする解a*,b*を求める , = =1 1
2 () − () + 2 ∗, ∗ = − =1 () − ∗() − ∗ () = 0 ∗, ∗ = − =1 () − ∗() − ∗ = 0 ⟺ ∗ =1 () 2 + ∗ =1 () = =1 ()() ∗ =1 () + ∗ = =1 () 合成関数の微分
7 誤差関数を最小化する(2/2) この関係式を前頁1段目の式に代入する ∗ =1 () 2 + ∗
=1 () = =1 ()() ⟺ ∗ =1 () 2 + −∗ + =1 () = =1 ()() ⇔ ∗ = σ ()() − σ () σ () 2 − σ () = − ∙ 2 − 2 = (との共分散) (の分散) ∗ =1 () + ∗ = =1 () ⟺ ∗ = −∗ σ () + σ () = −∗ + n個のx i ,y i の平均 ✓ このように回帰直線の係数a*,b*が求められる
8 行列で記述するほうがすっきり ✓ 行列で記述するほうが簡単にかける = =1 1 2 ()
− () + 2 = 1 2 (1) − (1) + 2 + ⋯ + () − () + 2 = 1 2 − T − (1) = (1) + (2) = (2) + () = () + … (1) (2) ⋮ () = (1) (2) ⋮ () + = (1) (2) ⋮ () 1 1 ⋮ 1 ⟺ = このように行列を定義すると,誤差関数は下記のとおり
9 行列表現での最小化 ✓ 誤差関数を係数ベクトルwで微分して0とする = 1 2 − T −
∗ = 0 ⟺ 1 2 ∙ 2 −T − ∗ = ⟺ T − T∗ = ⟺ T∗ = T ⟺ ∗ = T −1 T ✓ ベクトルの微分がわからない方は「ベクトル 微分」で検索してください (いろいろ公式がでてきます) ✓ ここらへんの式変形は成分表示してがんばって計算したら大体理解できます ベクトルの微分公式より 展開 移行 両辺に逆行列を左からかける (Tが逆行列を持つと仮定)
10 なぜ誤差を二乗したのか? , = =1 () − () +
✓ 各データの誤差は正/負両方存在するため そのまま足し合わせると誤差が相殺されてしまう ✓ 誤差を2乗すれば非負となり,和で評価が可能になる ✓ 誤差の絶対値をとると最小値を求めるのが難しくなるため 2乗する方法を採用 これだと解析的に最小値を求めるのが難しい!