各模型常用的损失函数

各模型常用的损失函数

线性模型

J θ ( x ) = 1 2 m ∑ i = 1 m ( h θ ( x ( i ) ) − y ( i ) ) 2 J_\theta(x)=\frac{1}{2m}\sum_{i=1}^m(h_\theta(x^{(i)})-y^{(i)})^2 Jθ(x)=2m1i=1m(hθ(x(i))y(i))2

Logistic Regression

J ( θ ) = 1 m ∑ i = 1 m C o s t ( h θ ( x ( i ) ) , y ( i ) ) C o s t ( h θ ( x ) , y ) = − l o g ( h θ ( x ) ) i f   y = 1 C o s t ( h θ ( x ) , y ) = − l o g ( 1 − h θ ( x ) ) i f   y = 0 J(θ)=\frac1m\sum_{i=1}^mCost(h_θ(x^{(i)}),y^{(i)})\\ Cost(h_θ(x),y)=−log(h_θ(x)) \quad if\ y=1\\ Cost(h_θ(x),y)=−log(1−h_θ(x)) \quad if \ y = 0 J(θ)=m1i=1mCost(hθ(x(i)),y(i))Cost(hθ(x),y)=log(hθ(x))if y=1Cost(hθ(x),y)=log(1hθ(x))if y=0
该损失函数可以简写为:
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)}log(h_\theta(x^{(i)}))+(1-y^{(i)})log(1-h_\theta(x^{(i)}))] J(θ)=m1i=1m[y(i)log(hθ(x(i)))+(1y(i))log(1hθ(x(i)))]


持续更新

你可能感兴趣的:(机器学习)