Coursera-Machine Learning 之 Logistic Regression (逻辑回归)-0x01
2015-02-11 17:53
453 查看
Hypothesis Representation (假设函数表达式)
Logistic Regression ModelWant 0≤hθ(x)≤10\leq h_{\theta}(x) \leq 1
hθ(x)=g(θTx)g(z)=11+e−z⎫⎭⎬⎪⎪→hθ(x)=11+e−θTx
\left.
\begin{array}{l}
h_{\theta}(x) = g(\theta^{T}x) \\
g(z) = \dfrac{1}{1+e^{-z}}
\end{array}
\right\}
\to
h_{\theta}(x) = \dfrac{1}{1+e^{-\theta^{T}x}}
Sigmoid function
Logistic function
This two concept are basically synonyms and mean the same things.
这两个函数概念基本是同义词,表示了g(z)g(z)
Sigmoid function wiki pedia
Sigmoid 函数 百度百科
Interpretation of Hypothesis Output
对于一个已存在的数据集,我们需要为假设函数寻找一个θ\theta来拟合这个数据集;
hθ(x)=P(y=1|x;θ)h_{\theta}(x) = P(y=1|x;\theta)
在给定的特征值xx,参数值θ\theta下,y=1y=1的概率。
P(y=0|x;θ)=1−P(y=1|x;θ)P(y=0|x;\theta) = 1 - P(y=1|x;\theta)
Decision Regression(决策边界)
Logistic Regression假设预测:
如果 hθ(x)≥0.5h_{\theta}(x) \geq 0.5,则 y=1y=1;
如果 hθ(x)<0.5h_{\theta}(x) < 0.5,则 y=0y=0;
在g(z)g(z)函数中
如果 z≥0z \geq 0,则 0.5≤g(z)<10.5\leq g(z)<1;
如果 z<0z<0,则 0<g(z)<0.50< g(z)<0.5;
所以
θTx≥0⇒hθ(x)≥0.5⇒y=1\color{blue}{\theta^{T}x \geq 0} \Rightarrow h_{\theta}(x)\geq0.5 \Rightarrow \color{blue}{y = 1}
θTx<0⇒hθ(x)<0.5⇒y=0\color{navy}{\theta^{T}x < 0} \Rightarrow h_{\theta}(x) < 0.5 \Rightarrow \color{navy}{y = 0}
Decision Boundary
hθ(x)=g(θ0+θ1x1+θ2x2)h_{\theta}(x) = g(\theta_{0}+\theta_{1} x_{1}+\theta_{2} x_{2})
假设: θ0=−3,θ1=1,θ2=1\theta_{0} = -3, \theta_{1} = 1, \theta_{2} = 1
θ=⎡⎣⎢−311⎤⎦⎥
\theta = \begin{bmatrix}
-3\\
1\\
1
\end{bmatrix}
Predict
"y=1""y = 1" if −3+x1+x2≥0 -3 + x_{1} + x_{2} \geq 0
"y=0""y = 0" if −3+x1+x2<0 -3 + x_{1} + x_{2} < 0
这里可以看出 x1+x2=3x_{1} + x_{2} = 3 这条线 是上述两个等式取不同值得分界线,这条分界线就被称为决策边界;
在这里,决策边界是假设函数的一个属性,由参数决定,与数据集无关。
Non-linear decision Boundaries
hθ(x)=g(θ0+θ1x1+θ2x2+θ3x21+θ4x22)h_{\theta}(x) = g(\theta_{0}+\theta_{1} x_{1}+\theta_{2} x_{2}+\theta_{3} x_{1}^{2}+\theta_{4} x_{2}^{2})
support:
θ=⎡⎣⎢⎢⎢⎢⎢⎢−10011⎤⎦⎥⎥⎥⎥⎥⎥
\theta = \begin{bmatrix}
-1\\
0\\
0\\
1\\
1
\end{bmatrix}
Predict
"y=1""y = 1" if −1+x21+x22≥0 -1 + x_{1}^{2} + x_{2}^{2} \geq 0
"y=0""y = 0" if −1+x21+x22<0 -1 + x_{1}^{2} + x_{2}^{2} < 0
此时,决策边界为 x21+x22=1 x_{1}^{2} + x_{2}^{2} = 1
参数 θ\theta 并不是由训练集所决定的,但是可以由训练集拟合出 θ\theta
高阶复杂的假设函数:
hθ(x)=g(θ0+θ1x1+θ2x2+θ3x21+θ4x21x2+θ5x21x22+...)h_{\theta}(x) = g(\theta_{0}+\theta_{1} x_{1}+\theta_{2} x_{2}+\theta_{3} x_{1}^{2}+\theta_{4} x_{1}^{2} x_{2} + \theta_{5} x_{1}^{2} x_{2}^{2}+ ...)
相关文章推荐
- Coursera DeepLearning.ai Logistic Regression逻辑回归总结
- Coursera Machine Learning 课程笔记之第三周:逻辑回归(Logistic Regression)
- Coursera机器学习-第三周-逻辑回归Logistic Regression
- Coursera吴恩达《神经网络与深度学习》课程笔记(2)-- 神经网络基础之逻辑回归
- Coursera吴恩达机器学习课程 总结笔记及作业代码——第3周逻辑回归
- Coursera机器学习笔记 第3周 六、逻辑回归(二)
- Coursera吴恩达《神经网络与深度学习》课程笔记(2)-- 神经网络基础之逻辑回归
- Coursera-Machine Learning 之 Logistic Regression (逻辑回归)-0x02
- Coursera_DeepLearning_神经网络之逻辑回归
- stanford coursera 机器学习编程作业 exercise 3(逻辑回归实现多分类问题)
- Coursera机器学习笔记 第3周 六、逻辑回归(一)
- Coursera_机器学习_week3_逻辑回归
- Coursera deeplearning.ai 深度学习笔记1-2-Neural Network Basics-逻辑回归原理推导与代码实现
- Coursera 机器学习(by Andrew Ng)课程学习笔记 Week 3——逻辑回归、过拟合与正则化
- 斯坦福机器学习Coursera课程:第三周作业--逻辑回归
- Coursera《machine learning》--(6)逻辑回归
- Coursera机器学习 Week3:逻辑回归、Decision Boundary、过拟合
- 【原】Andrew Ng斯坦福机器学习 Coursera—Programming Exercise 3 逻辑回归多分类和神经网络
- Coursera公开课笔记: 第六课 逻辑回归
- 逻辑回归详谈