머신러닝

로지스틱 회귀모델의 모수 추정

적외선 2019. 3. 6. 14:56

Sigmoid 함수 (logistic function)

sigmoid(x)=11+ex


Sigmoid 함수 미분

ddxsigmoid(x)=ddx(1+ex)1

=(1)1(1+ex)2ddx(1+ex)

=(1)1(1+ex)2(0+ex)ddx(x)

=(1)1(1+ex)2ex(1)

=(1)1(1+ex)2ex(1)

=(1)1(1+ex)2ex(1)

=(1+ex)(1+ex)21(1+ex)2

=11+ex1(1+ex)2

=11+ex(111+ex)

=sigmoid(x)(1sigmoid(x))

=σ(x)=σ(x)(1σ(x))


Cost 함수

Cost(hθ(x),y)=ylog(hθ(x))(1y)log(1hθ(x))


전체 Cost 함수

j(θ)=1mi=1m[y(i)log(hθ(x(i)))+(1y(i))log(1hθ(x(i)))]


Cost 함수 미분

θjj(θ)=θj1mi=1m[y(i)log(hθ(x(i)))+(1y(i))log(1hθ(x(i)))]

=1mi=1m[y(i)θjlog(hθ(x(i)))+(1y(i))θjlog(1hθ(x(i)))]

=1mi=1m[y(i)θjhθ(x(i))hθ(x(i))+(1y(i))θj(1hθ(x(i)))1hθ(x(i))]

=1mi=1m[y(i)θjσ(θTx(i))hθ(x(i))+(1y(i))θj(1σ(θTx(i)))1hθ(x(i))]

=1mi=1m[y(i)σ(θTx(i))(1σ(θTx(i)))θjθTx(i)hθ(x(i))+(1y(i))σ(θTx(i))(1σ(θTx(i)))θjθTx(i)1hθ(x(i))]

=1mi=1m[y(i)hθ(x(i))(1hθ(x(i)))θjθTx(i)hθ(x(i))+(1y(i))hθ(x(i))(1hθ(x(i)))θjθTx(i)1hθ(x(i))]

=1mi=1m[y(i)hθ(x(i))(1hθ(x(i)))xj(i)+(1y(i))hθ(x(i))xj(i)]

=1mi=1m[y(i)hθ(x(i))(1hθ(x(i)))+(1y(i))hθ(x(i))]xj(i)

=1mi=1m[y(i)y(i)hθ(x(i))hθ(x(i))+y(i)hθ(x(i))]xj(i)

=1mi=1m[y(i)hθ(x(i))]xj(i)

=1mi=1m[hθ(x(i))y(i)]xj(i)



Gradient Desent

Repeat{θj :=θjαθjJ(θ)}