You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

week3.md 3.1 kB

7 years ago
7 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. [TOC]
  2. # 6 逻辑回归(Logistic Regression)
  3. ## 6.1 分类(Classification)
  4. 在分类问题中,预测的结果是离散值(结果是否属于某一类),逻辑回归算法(Logistic Regression)被用于解决这类分类问题。
  5. - 垃圾邮件判断
  6. - 金融欺诈判断
  7. - 肿瘤诊断
  8. 肿瘤诊断问题:
  9. ![](image/20180109_144040.png)
  10. 肿瘤诊断问题是一个**二元分类问题(binary class problems)**,则定义 $ y \in\lbrace 0, 1\rbrace$,其中 0 表示**负向类(negative class)**,代表恶性肿瘤("-"),1 为**正向类(positive class)**,代表良性肿瘤("+")。如图,定义最右边的样本为**偏差项**。
  11. 在未加入偏差项时,线性回归算法给出了品红色的拟合直线,若规定
  12. $h_\theta(x) \geqslant 0.5$ ,预测为 $y = 1$,即正向类;
  13. $h_\theta(x) \lt 0.5$ ,预测为 $y = 0$,即负向类。
  14. 即以 0.5 为**阈值**(threshold),则我们就可以根据线性回归结果,得到相对正确的分类结果 $y$。
  15. 接下来加入偏差项,线性回归算法给出了靛青色的拟合直线,如果阈值仍然为 0.5,可以看到算法在某些情况下会给出完全错误的结果。
  16. 不仅如此,线性回归算法的值域为 $R$,则当线性回归函数给出诸如 $h = 10000, h = -10000$ 等很大/很小(负数)的数值时,结果 $y \in \lbrace 0, 1\rbrace$,这显得非常怪异。
  17. 区别于线性回归算法,逻辑回归算法是一个分类算法,**其输出值永远在 0 到 1 之间**,即 $h \in (0,1)$。
  18. ## 6.2 假设函数表示(Hypothesis Representation)
  19. 为了使 $h \in \left(0, 1\right)$,引入逻辑回归模型,定义假设函数
  20. $$
  21. h_\theta \left( x \right)=g\left(\theta^{T}X \right)
  22. $$
  23. 对比线性回归函数 $h_\theta \left( x \right)=\theta^{T}X$,$g$ 表示逻辑函数([logistic function][1]),复合起来,则为线性回归函数。
  24. 一个常用的逻辑函数是 S 形函数,叫做 **[sigmoid 函数][2]**(如下图),其公式为 $g\left( z \right)=\frac{1}{1+{{e}^{-z}}}$。
  25. ![sigmoid function](image/2413fbec8ff9fa1f19aaf78265b8a33b_Logistic_function.png)
  26. 应用 sigmoid 函数,则逻辑回归模型:$$h_{\theta}(x)=g(\theta^Tx) =\frac{1}{1+e^{-\theta^Tx}}$$
  27. $h_\theta \left( x \right)$ 的作用是,根据输入 $x$,参数 $\theta$ 计算得出”输出 $y=1$“的可能性(estimated probability),概率学中表示为:
  28. $\begin{align*}& h_\theta(x) = P(y=1 | x ; \theta) = 1 - P(y=0 | x ; \theta) \newline & P(y = 0 | x;\theta) + P(y = 1 | x ; \theta) = 1\end{align*}$
  29. 以肿瘤诊断为例,$h_\theta \left( x \right)=0.7$ 表示病人有 $70\%$ 的概率得了恶性肿瘤。
  30. [1]: https://en.wikipedia.org/wiki/Logistic_function
  31. [2]: https://en.wikipedia.org/wiki/Sigmoid_function
  32. ## 6.3 Decision Boundary
  33. ## 6.4 Cost Function
  34. ## 6.5 Simplified Cost Function and Gradient Descent
  35. ## 6.6 Advanced Optimization
  36. ## 6.7 Multiclass Classification_ One-vs-all
  37. # 7 Regularization
  38. ## 7.1 The Problem of Overfitting
  39. ## 7.2 Cost Function
  40. ## 7.3 Regularized Linear Regression
  41. ## 7.4 Regularized Logistic Regression

机器学习

Contributors (1)