Part Ⅳ

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 ( θ ) = 0 f(\theta) = 0 f(θ)=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 ) e x p ( η T T ( 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 ) = y T(y) = y T(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 ) = y T(y) = y T(y)=y.

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

a ( η ) = − l o g ( 1 − ϕ ) = l o g ( 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 ) = y T(y) = y T(y)=y.

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

b ( y ) = ( 1 / 2 π ) e x p ( ( − y 2 / 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 x x x and θ θ θ, the distribution of y y y follows some exponential family distribution, with parameter η η η.
  2. Given x x x, our goal is to predict the expected value of T ( y ) T(y) T(y) given x x x.In most of our examples, we will have T ( y ) = y T(y) = y T(y)=y, so this means we would like the prediction h ( x ) h(x) h(x) output by our learned hypothesis h h h 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 x x x are related linearly: η = θ T x η = θ^Tx η=θTx.(Or, if η η η is vector-valued, then η i = θ i T x η_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 ] = u E[y|x] = u E[yx]=u because of h θ ( x ) h_\theta(x) hθ(x) belong to the exponential family,so h θ ( x ) = μ = η h_\theta(x) = \mu = \eta hθ(x)=μ=η,according to assumption 3 we get h θ ( x ) = μ = η = θ T x h_\theta(x) = \mu = \eta = \theta^Tx hθ(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 − θ T x ) 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:

η = [ l o g ( ϕ 1 / ϕ k ) l o g ( ϕ 2 / ϕ k ) ⋮ l o g ( ϕ 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 ( η ) = − l o g ( k ) a(\eta) = -log(k) a(η)=log(k). b ( y ) = 1 b(y) = 1 b(y)=1.

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

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

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

ϕ k ∑ i = 1 k e η i = ∑ i = 1 k ϕ 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 = 1 k e η 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 ; θ ) = ϕ i p(y=i|x;\theta) = \phi_i p(y=ix;θ)=ϕi.

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

= e θ i T x ∑ j = 1 k e θ j T x =\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 = 1 m l o g p ( y ( i ) ∣ x ( i ) ; θ ) \ell(\theta) = \sum_{i=1}^m logp(y^{(i)}|x^{(i)};\theta) (θ)=i=1mlogp(y(i)x(i);θ).
= ∑ i = 1 m l o g ∏ l = 1 k ( e θ l T x i ∑ j = 1 k e θ j T x ( 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、付费专栏及课程。

余额充值