Part Ⅳ

本文介绍了广义线性模型的基本概念,包括其三个核心假设,并详细解释了牛顿法在参数估计中的应用。通过具体的例子如逻辑回归、高斯分布及softmax回归等,展示了如何将广义线性模型应用于实际问题中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Part Ⅳ

4.1 Words list

  • logistic regression logistic 回归
  • exponential family 指数族
  • Newton’s method 牛顿方法
  • generalized linear models 广义线性模型

4.2 The Newton’s method

The Newton’s method is a method for solving the root of an equation. Here’s a picture of the Newton’s method in action.

在这里插入图片描述

Newton’s method performs the following update:

θ:=θ−αf(θ)f′(θ)\theta := \theta - \alpha\frac{f(\theta)}{f^{'}(\theta)}θ:=θαf(θ)f(θ).

Newton’s method gives a way of getting f(θ)=0f(\theta) = 0f(θ)=0.What if we want to use it to maximize some functions ℓ\ell.The maximize of ℓ\ell correspond to points where its first derivative ℓ′(θ)ℓ′(θ)(θ) is zero.And we obtain update rule:

θ:=θ−αℓ′(θ)ℓ′′(θ)\theta := \theta - \alpha\frac{\ell^{'}(\theta)}{\ell^{''}(\theta)}θ:=θα(θ)(θ).

If θ\thetaθ is a vector-value.The update rule is given by

θ:=θ−H−1∇θℓ(θ)\theta:=\theta-H^{-1}\nabla_{\theta}\ell(\theta)θ:=θH1θ(θ).

4.3 The exponential family

The exponential family be written in the from

p(y;η)=b(y)exp(ηTT(y)−a(η))p(y; \eta) = b(y)exp(\eta^T T(y) - a(\eta))p(y;η)=b(y)exp(ηTT(y)a(η)).

Here, η\etaη is called the natural parameter (also called the canonical parameter) of the distribution; T(y)T(y)T(y) is the sufficient statistic (for the distributions we consider, it will often be the case that T(y)=yT(y) = yT(y)=y); and a(η)a(η)a(η) is the log partition function. The quantity e−a(η)e^{-a(\eta)}ea(η)) essentially plays the role of a normalization constant, that makes sure the distribution p(y;η)p(y; η)p(y;η) sums/integrates over y to 1.

Gaussian and Bernoulli are is familiar to us.They are proved to belong to the exponential family.

In the Bernoulli distribution:

T(y)=yT(y) = yT(y)=y.

b(y)=1b(y) = 1b(y)=1.

a(η)=−log(1−ϕ)=log(1+e−η)a(\eta) = -log(1 - \phi) = log(1 + e^{-\eta})a(η)=log(1ϕ)=log(1+eη).

In the Gaussian distribution:

η=μ\eta = \muη=μ.

T(y)=yT(y) = yT(y)=y.

a(η)=−μ2/2=−η2/2a(\eta) = -\mu^2/2 = -\eta^2/2a(η)=μ2/2=η2/2.

b(y)=(1/2π)exp((−y2/2))b(y) = (1/\sqrt{2\pi})exp((-y^2/2))b(y)=(1/2π)exp((y2/2)).

4.4 The generalized linear models

The generalized linear models is use to the prediction function of independent variable as the estimated value of dependent variable.

The generalized linear models are based on three assumptions:

  1. y∣x;θy | x; θyx;θ ∼ Exponential Family(η)(η)(η). I.e., given xxx and θθθ, the distribution of yyy follows some exponential family distribution, with parameter ηηη.
  2. Given xxx, our goal is to predict the expected value of T(y)T(y)T(y) given xxx.In most of our examples, we will have T(y)=yT(y) = yT(y)=y, so this means we would like the prediction h(x)h(x)h(x) output by our learned hypothesis hhh to satisfy h(x)=E[y∣x]h(x) = E[y|x]h(x)=E[yx]. (Note that this assumption is satisfied in the choices for hθ(x)h_\theta(x)hθ(x) for both logistic regression and linear regression. For instance, in logistic regression, we had hθ(x)=p(y=1∣x;θ)=0⋅p(y=0∣x;θ)+1⋅p(y=1∣x;θ)=E[y∣x;θ].)h_\theta(x) = p(y = 1|x; θ) = 0 · p(y = 0|x; θ) + 1 · p(y = 1|x; θ) = E[y|x; θ].)hθ(x)=p(y=1x;θ)=0p(y=0x;θ)+1p(y=1x;θ)=E[yx;θ].).
  3. The natural parameter ηηη and the inputs xxx are related linearly: η=θTxη = θ^Txη=θTx.(Or, if ηηη is vector-valued, then ηi=θiTxη_i = θ_i^T xηi=θiTx).

There are three examples of the generalized linear models:

  1. Ordinary Least Squares.

According to assumption 2,we get:

hθ(x)=E[y∣x]h_\theta(x) = E[y|x]hθ(x)=E[yx].

Because of the Ordinary least Squares is satisfied Gaussian distribution so E[y∣x]=uE[y|x] = uE[yx]=u because of hθ(x)h_\theta(x)hθ(x) belong to the exponential family,so hθ(x)=μ=ηh_\theta(x) = \mu = \etahθ(x)=μ=η,according to assumption 3 we get hθ(x)=μ=η=θTxh_\theta(x) = \mu = \eta = \theta^Txhθ(x)=μ=η=θTx.

2.Logistic Regression.

We get the equation according to above three assumptions:

hθ(x)=E[y∣x;θ]=ϕ=1/(1+e−η)=1/(1+e−θTx)h_\theta(x) = E[y|x;\theta] = \phi = 1/(1 + e^{-\eta}) = 1/(1+e^{-\theta^Tx})hθ(x)=E[yx;θ]=ϕ=1/(1+eη)=1/(1+eθTx).

3.Softmax Regression(For solving the multiple classification).

Softmax Regression is for solving the multiple classification. So the first of all,we need to prove it belong to exponential family.Then we can get:

η=[log(ϕ1/ϕk)log(ϕ2/ϕk)⋮log(ϕk−1/ϕk)]\eta = \left[\begin{matrix}log(\phi_1/\phi_k) \\ log(\phi_2/\phi_k) \\ \vdots\\ log(\phi_{k-1/}\phi_k)\end{matrix}\right]η=log(ϕ1/ϕk)log(ϕ2/ϕk)log(ϕk1/ϕk).

a(η)=−log(k)a(\eta) = -log(k)a(η)=log(k). b(y)=1b(y) = 1b(y)=1.

because ηi=logϕiϕk\eta_i = log\frac{\phi_i}{\phi_k}ηi=logϕkϕi,so

eηi=ϕi/ϕke^{\eta_i} = \phi_i/\phi_keηi=ϕi/ϕk.

ϕi=eηiϕk\phi_i = e^{\eta_i}\phi_kϕi=eηiϕk.

ϕk∑i=1keηi=∑i=1kϕi=1\phi_k\sum_{i=1}^{k}e^{\eta_i} = \sum_{i=1}^k\phi_i = 1ϕki=1keηi=i=1kϕi=1.

so the

ϕi=eηi/∑j=1keηj\phi_i = e^{\eta_i}/\sum_{j=1}^k e^{\eta_j}ϕi=eηi/j=1keηj.

we come to the conclusion

p(y=i∣x;θ)=ϕip(y=i|x;\theta) = \phi_ip(y=ix;θ)=ϕi.

=eηi∑j=1keηj=\frac{e^{\eta_i}}{\sum_{j=1}^k e^{\eta_j}}=j=1keηjeηi.

=eθiTx∑j=1keθjTx=\frac{e^{\theta_i^Tx}}{\sum_{j=1}^k e^{\theta_j^Tx}}=j=1keθjTxeθiTx.

So our hypothesis will output:

hθ(x)=E[T(y)∣x;θ]=[ϕ1ϕ2⋮ϕk−1]h_\theta(x) = E[T(y)|x;\theta] = \left[\begin{matrix} \phi_1\\\phi_2\\ \vdots \\ \phi_{k-1}\end{matrix}\right]hθ(x)=E[T(y)x;θ]=ϕ1ϕ2ϕk1.

Hence,we can use the log-likelihood to solve the parameters of this model.

ℓ(θ)=∑i=1mlogp(y(i)∣x(i);θ)\ell(\theta) = \sum_{i=1}^m logp(y^{(i)}|x^{(i)};\theta)(θ)=i=1mlogp(y(i)x(i);θ).
=∑i=1mlog∏l=1k(eθlTxi∑j=1keθjTx(i))1{y(i)=l} = \sum_{i=1}^m log \prod_{l=1}^k(\frac{e^{\theta_l^Tx^{i}}}{\sum_{j=1}^ke^{\theta_j^T x^{(i)}}})^{1\{y^{(i)}=l\}}=i=1mlogl=1k(j=1keθjTx(i)eθlTxi)1{y(i)=l}.

Using a method such as gradient ascent or Newton’s method.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值