Linear/Logistic/Softmax Regression是常见的机器学习模型,且都是广义线性模型的一种,有诸多相似点,详细对比之。原文见Linear/Logistic/Softmax Regression对比。
概述
Linear Regression是回归模型,Logistic Regression是二分类模型,Softmax Regression是多分类模型,但三者都属于广义线性「输入的线性组合」模型「GLM」。
其中Softmax Regression可以看做Logistic Regression在多类别上的拓展。
Softmax Regression (synonyms: Multinomial Logistic, Maximum Entropy Classifier, or just Multi-class Logistic Regression) is a generalization of logistic regression that we can use for multi-class classification (under the assumption that the classes are mutually exclusive).
符号约定
- 样本 ( x ( i ) , y ( i ) ) (x^{(i)}, y^{(i)}) (x(i),y(i))
- 样本数 m m m
- 特征维度 n n n
- Linear Regression输出 y ( i ) y^{(i)} y(i)
- Logistic Regression类别 y ( i ) ∈ { 0 , 1 } y^{(i)}\in\{0,1\} y(i)∈{ 0,1}
- Softmax Regression类别 y ( i ) ∈ { 1 , … , K } y^{(i)}\in\{1,\ldots,K\} y(i)∈{ 1,…,K}
- Softmax Regression类别数 K K K
- 损失函数 J ( θ ) J(\theta) J(θ)
- Indicator函数 I { b o o l e a n } I\{boolean\} I{ boolean}
模型参数对比
Linear Regression,维度为 ( n ⋅ 1 ) (n \cdot 1) (n⋅1)的向量
θ = [ ∣ θ ∣ ] \theta = \begin{bmatrix} \vert \\ \theta \\ \vert \end{bmatrix} θ=⎣⎡∣θ∣⎦⎤
Logistic Regression,维度为 ( n ⋅ 1 ) (n \cdot 1) (n⋅1)的向量
θ = [ ∣ θ ∣ ] \theta = \begin{bmatrix} \vert \\ \theta \\ \vert \end{bmatrix} θ=⎣⎡∣θ∣⎦⎤
Softmax Regression,维度为 ( n ⋅ K ) (n \cdot K) (n⋅K)的矩阵
θ = [ ∣ ∣ ∣ ∣ θ ( 1 ) θ ( 2 ) … θ ( K ) ∣ ∣ ∣ ∣ ] \theta = \begin{bmatrix} \vert & \vert & \vert & \vert \\ \theta^{(1)} & \theta^{(2)} & \dots & \theta^{(K)} \\ \vert & \vert & \vert & \vert \\ \end{bmatrix}