Logistic Regression 中的函数 f,g f , g
f(x)=ln(1+ex),x∈R,g(x)=f(−x) f ( x ) = ln ( 1 + e x ) , x ∈ R , g ( x ) = f ( − x )
f,g f , g 的性质
f′(x)=ex1+ex>0,x∈R
f
′
(
x
)
=
e
x
1
+
e
x
>
0
,
x
∈
R
f′′(x)=(ex1+ex)′=ex(1+ex)2>0,x∈R
f
″
(
x
)
=
(
e
x
1
+
e
x
)
′
=
e
x
(
1
+
e
x
)
2
>
0
,
x
∈
R
limx→+∞f(x)=+∞,limx→−∞f(x)=0
lim
x
→
+
∞
f
(
x
)
=
+
∞
,
lim
x
→
−
∞
f
(
x
)
=
0
limx→−∞f(x)x=limx→−∞f′(x)=1
lim
x
→
−
∞
f
(
x
)
x
=
lim
x
→
−
∞
f
′
(
x
)
=
1
limx→+∞[f(x)−x]=limx→+∞ln(1+e−x)=0
lim
x
→
+
∞
[
f
(
x
)
−
x
]
=
lim
x
→
+
∞
ln
(
1
+
e
−
x
)
=
0
g(x)=f(−x)=ln(1+e−x),x∈R
g
(
x
)
=
f
(
−
x
)
=
ln
(
1
+
e
−
x
)
,
x
∈
R
g′(x)=11+e−xe−x(−1)=−11+ex<0,x∈R
g
′
(
x
)
=
1
1
+
e
−
x
e
−
x
(
−
1
)
=
−
1
1
+
e
x
<
0
,
x
∈
R
g′′(x)=−(11+ex)′=ex(1+ex)2>0,x∈R
g
″
(
x
)
=
−
(
1
1
+
e
x
)
′
=
e
x
(
1
+
e
x
)
2
>
0
,
x
∈
R
SVM 的函数 cost0,cost1 cost 0 , cost 1
cost0(x)=max(0,x−1)
c
o
s
t
0
(
x
)
=
max
(
0
,
x
−
1
)
cost1(x)=max(0,1−x)
c
o
s
t
1
(
x
)
=
max
(
0
,
1
−
x
)
Cost function of Logistic Regression
hθ(Xi)=11+e−θ⊺Xi
h
θ
(
X
i
)
=
1
1
+
e
−
θ
⊺
X
i
J(θ)=−1m∑i=1m{yiln(hθ(Xi))+(1−yi)ln(1−hθ(Xi))}+λ2m∑j=1nθ2j
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
则
−lnhθ(Xi)=g(θ⊺Xi)
−
ln
h
θ
(
X
i
)
=
g
(
θ
⊺
X
i
)
−ln(1−hθ(Xi))=f(θ⊺Xi)
−
ln
(
1
−
h
θ
(
X
i
)
)
=
f
(
θ
⊺
X
i
)
于是
J(θ)=∑i=1m[yig(θ⊺Xi)+(1−yi)f(θ⊺Xi)]+λ2m∑j=1nθ2j
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θ(Xi)={1,0,θ⊺Xi≥0,otherwise,
h
θ
(
X
i
)
=
{
1
,
θ
⊺
X
i
≥
0
,
0
,
otherwise
,
J(θ)=C∑i=1m[yicost1(θ⊺Xi)+(1−yi)cost0(θ⊺Xi)]+∑j=1nλ2θ2j
J
(
θ
)
=
C
∑
i
=
1
m
[
y
i
cost
1
(
θ
⊺
X
i
)
+
(
1
−
y
i
)
cost
0
(
θ
⊺
X
i
)
]
+
∑
j
=
1
n
λ
2
θ
j
2