机器学习第三课

Classification:不能用线性回归
Logistic Regression:0 ≤ h θ ( x ) ≤ 1 {\leq}h_{\theta}(x){\leq}1 hθ(x)1
(a classification algortihm)

h θ ( x ) = g ( θ T x ) h_{\theta}(x)=g({\theta}^Tx) hθ(x)=g(θTx)
g(z)= 1 1 + e − z \frac{1}{1+e^{-z}} 1+ez1

h θ ( x ) = P ( y = 1 ∣ x ; θ ) h_{\theta}(x)=P(y=1|x;{\theta}) hθ(x)=P(y=1x;θ)
x, θ \theta θ已知条件下y=1的概率

Suppose predict “y=1” if h θ ( x ) ≥ 0.5 h_{\theta}(x)\geq0.5 hθ(x)0.5
predict “y=0” if h θ ( x ) < 0.5 h_{\theta}(x)<0.5 hθ(x)<0.5

Decision Boundary
h θ ( x ) = g ( θ 0 + θ 1 x 1 + θ 2 x 2 ) h_{\theta}(x)=g(\theta_0+\theta_1x_1+\theta_2x_2) hθ(x)=g(θ0+θ1x1+θ2x2) θ \theta θ= [ − 3 1 1 ] \begin{bmatrix} -3 \\ 1 \\ 1 \end{bmatrix}\quad 311
Predict “y=1” if -3+ x 1 x_1 x1+ x 2 ≥ x_2\geq x2 0
在这里插入图片描述

Non-linear decision boundaries
在这里插入图片描述

Logistic regression cost function
cost( h θ ( x ) , y h_{\theta}(x),y hθ(x),y) = { − l o g ( h θ ( x ) ) i f y = 1 − l o g ( 1 − h θ ( x ) ) i f y = 0 =\left\{\begin{aligned}-log(h_{\theta}(x)) \qquad if \quad y=1\\-log(1-h_{\theta}(x)) \qquad if \quad y=0 \end{aligned} \right. ={log(hθ(x))ify=1log(1hθ(x))ify=0

J ( θ ) = 1 m ∑ i = 1 m c o s t ( h θ ( x ( i ) ) , y ( i ) ) J(\theta)=\frac{1}{m}\sum_{i=1}^{m} cost(h_{\theta}(x^{(i)}),y^{(i)}) J(θ)=m1i=1mcost(hθ(x(i)),y(i))
cost( h θ ( x ) , y ) h_{\theta}(x),y) hθ(x),y)=-ylog( h θ ( x ) h_{\theta}(x) hθ(x))-(1-y)log(1- h θ ( x ) h_{\theta}(x) hθ(x))

J ( θ ) = − 1 m [ ∑ i = 1 m y ( i ) l o g h θ ( x ( i ) ) + ( 1 − y ( i ) ) l o g ( 1 − h θ ( x ( i ) ) ) ] J(\theta)=-\frac{1}{m}[\sum_{i=1}^{m}y^{(i)}logh_\theta(x^{(i)})+(1-y^{(i)})log(1-h_\theta(x^{(i)}))] J(θ)=m1[i=1my(i)loghθ(x(i))+(1y(i))log(1hθ(x(i)))]

Want mine ( J ( θ ) J(\theta) J(θ))
Repeat
{
θ j = θ j − α ∂ ∂ θ j J ( θ ) \theta_j=\theta_j-\alpha\frac{\partial}{\partial\theta_j}J(\theta) \quad θj=θjαθjJ(θ)
}simultaneously update all θ j \theta_j θj

∂ ∂ θ j J ( θ ) = 1 m ( h θ ( x ( i ) ) − y ( i ) ) x j ( i ) \frac{\partial}{\partial\theta_j}J(\theta)=\frac{1}{m}(h_{\theta}(x^{(i)})-y^{(i)})x^{(i)}_j θjJ(θ)=m1(hθ(x(i))y(i))xj(i)

Optimization algorithms(没有细看)

多元分类
在这里插入图片描述
Train a logistic regression classier h θ ( i ) ( x ) f o r h_\theta^{(i)}(x) for \quad \qquad hθ(i)(x)for each class i to predict the possibility that y=i
On a new input x,to make a prediction,pick the class i that maximizes Z m a x i \mathop{max}\limits_{i} imax h θ ( i ) ( x ) h_\theta^{(i)}(x) hθ(i)(x)

最后说一句,写博客真的好费时间(不是)
祝能有一个不错的五一

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值