斯坦福機器學習實現與分析之四(廣義線性模型)

來源:互聯網
上載者:User

標籤:

指數分布族

   首先需要提及下指數分布族,它是指一系列的分布,只要其機率密度函數可以寫成下面這樣的形式:

\(\begin{aligned} p(y;\eta)=b(y)exp(\eta^TT(y)-a(\eta))\end{aligned}\)

  一般的很多分布(如高斯分布,泊松分布,二項式分布,伽馬分布等)都屬於指數分布族。該分布族有很多良好的特性,參見《Generalized Linear Models (2nd ed.)》一書3.3節。

 

廣義線性模型構建假設

   廣義線性模型主要基於以下假設:

    1.\(y|x;\theta\)的分布屬於指數分布族

    2.預測值為\(T(y)\),因此模型就是\(E(T(y)|x)\)

    3.模型線性性,即\( \eta=\theta^Tx\)

 

線性迴歸與羅吉斯迴歸模型推導

   線性迴歸中,假設\(y|x;\theta\)服從高斯分布\( N(\mu,\sigma^2)\),則將其寫成指數分布族形式如下:

\( \begin{aligned} p(y|x;\theta)&={\frac{1}{\sqrt{2\pi}\sigma}}exp(-\frac{(y-\mu)^2}{2\sigma^2})\\&={\frac{1}{\sqrt{2\pi}\sigma}}e^{-\frac{y}{2\sigma^2}}exp(\frac{{\mu}y}{\sigma^2}-\frac{\mu^2}{2\sigma^2}) \end{aligned} \)

  注意這裡\(\eta\)和\(T(y)\)可以有多種取法滿足上面這個式子,但根據上面假設的第二條,由於我們需要預測的是\(y\),則\(T(y)=y\),從而就有

\(\begin{aligned} b(y)= {\frac{1}{\sqrt{2\pi}\sigma}}e^{-\frac{y}{2\sigma^2}}\end{aligned}\)

\(\begin{aligned} \eta =\frac{\mu}{\sigma^2}\end{aligned}\)

\(\begin{aligned} a(\eta)=\frac{\mu^2}{2\sigma^2}\end{aligned}\)

   從而:

\(\begin{aligned} h_\theta(x)=E(y|x;\theta)=\mu=\sigma^2\eta=\sigma^2\theta^Tx \end{aligned}\)

  這裡\(\begin{aligned}\sigma^2 \end{aligned}\)是一個常數,則上式可寫為:

\(\begin{aligned} h_\theta(x)=\theta^{‘T}x \end{aligned}\)

  此即為線性迴歸中使用的線性模型的來源。同理,對於羅吉斯迴歸,有

\( \begin{aligned} p(y|x;\theta)&=\phi^y(1-\phi)^{1-y}\\&=exp(ylog{\phi}+(1-y)log{(1-\phi)})\\&=exp(log{\frac{\phi}{1-\phi}}+log(1-\phi)) \end{aligned} \)

  則

\(\begin{aligned} T(y)=y \end{aligned}\)

\(\begin{aligned} b(y)= 1 \end{aligned}\)

\(\begin{aligned} \eta =log{\frac{\phi}{1-\phi}} \end{aligned}\)

\(\begin{aligned} a(\eta)=-log(1-\phi)\end{aligned}\)

   由此可得:

\(\begin{aligned} \phi=\frac{1}{1+e^{-\eta}} \end{aligned}\)

  故而有

\( \begin{aligned} h_\theta(x)=E(y|x;\theta)=\phi=\frac{1}{1+e^{-\eta}}=\frac{1}{1+e^{-\theta^T{x}}} \end{aligned}\)

  此即為羅吉斯迴歸使用的模型。

  同理,對於其他分布,我們也可以寫出對應的迴歸模型。上面給出了線性迴歸和羅吉斯迴歸的模型,通過最大似然估計與梯度下降法,即可求出參數。

 

問題與思考

  1.構建GLM的三條假設,其中假設一在此模型構建中起了什麼作用,目前還未理解。假如分布不屬於指數分布族,那是否也可以構建其他形式的線性模型?有理解的同學望不吝賜教。

  2.假設三即是模型的線性假設,這也能說明了羅吉斯迴歸只能處理線性可分情況。

斯坦福機器學習實現與分析之四(廣義線性模型)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.