Cost Function of Support Vector Machine

时间:2022-03-29 17:06:02

Logistic Regression 中的函数 f , g

f ( x ) = ln ( 1 + e x ) , x R , g ( x ) = f ( x )

f , g 的性质

f ( x ) = e x 1 + e x > 0 , x R
f ( x ) = ( e x 1 + e x ) = e x ( 1 + e x ) 2 > 0 , x R
lim x + f ( x ) = + , lim x f ( x ) = 0
lim x f ( x ) x = lim x f ( x ) = 1
lim x + [ f ( x ) x ] = lim x + ln ( 1 + e x ) = 0

g ( x ) = f ( x ) = ln ( 1 + e x ) , x R
g ( x ) = 1 1 + e x e x ( 1 ) = 1 1 + e x < 0 , x R
g ( x ) = ( 1 1 + e x ) = e x ( 1 + e x ) 2 > 0 , x R

SVM 的函数 cost 0 , cost 1

c o s t 0 ( x ) = max ( 0 , x 1 )
c o s t 1 ( x ) = max ( 0 , 1 x )

Cost function of Logistic Regression

h θ ( X i ) = 1 1 + e θ X i
J ( θ ) = 1 m i = 1 m { y i ln ( h θ ( X i ) ) + ( 1 y i ) ln ( 1 h θ ( X i ) ) } + λ 2 m j = 1 n θ j 2
ln h θ ( X i ) = g ( θ X i )
ln ( 1 h θ ( X i ) ) = f ( θ X i )
于是 J ( θ ) = i = 1 m [ y i g ( θ X i ) + ( 1 y i ) f ( θ X i ) ] + λ 2 m j = 1 n θ j 2

Cost function of Support Vector Machine

h θ ( X i ) = { 1 , θ X i 0 , 0 , otherwise ,
J ( θ ) = C i = 1 m [ y i cost 1 ( θ X i ) + ( 1 y i ) cost 0 ( θ X i ) ] + j = 1 n λ 2 θ j 2