Basic Data Science : Logistic Regression

Logistic function หรือ Sigmoid function [1]

Sigmoid curve



f(x)=L1ek(xx0)(1)


เมื่อ
e คือ  Euler's number [2]
k คือ ความชัน
x0 ค่าที่อยู่ตรงกลางของ Sigmoid (Sigmoid midpoint)
x คือจำนวนจริง มีค่าระหว่าง ,+
L คือ maximum value

standard Logistic function คือ Logistic function ที่มีค่าของ  L = 1,x0=0 และ k = 1 ได้สมการคือ

f(x)=11+ex(2)

หรือ
f(x)=ex1+ex(3)


Logistic Regression

Logistic regression คือ classification algorithm  เทียบกับ Linear Regression , h(x)=XβT แล้ว Logistic Regression ไม่ใช้ค่าของ Response variable (h(x)) โดยตรง แต่ใช้ค่าความน่าจะเป็น ของ Response variable ผ่าน Logistic function

hβ(x)=g(z)=ez1+ez


เมื่อ g(z) คือ Logistic function หรือ Sigmoid function ของ h(x) และ z=Xβ

จะตีความ hβ(x) ที่ได้ว่าเป็น "probability" ของ Response variable (y) จะมีค่าเป็น "1"

hβ(x)=P(y=1x;β) (probability ของ y ที่จะมีค่าเป็น 1 เมื่อ x ใช้ parameter β ในทางตรงข้ามจะได้ P(y=0x;β)=1P(y=1x;β)

การแบ่งกลุ่มสามารถอาศัยค่าความน่าจะเป็นเหมือนกับการใช้คำตอบ "ใช่" กับ "ไม่ใช่" หรือ "1" กับ "0" 

Update rule (Stochastic gradient descent) [4][5]

βj=βj+α(y(i)hβ(xi))xj(i)(1)

เมื่อ α คือ Learning rate

[Download Code ]

เอกสารอ้างอิง
[1] https://en.wikipedia.org/wiki/Logistic_function
[2] https://en.wikipedia.org/wiki/E_(mathematical_constant)
[3] https://en.wikipedia.org/wiki/Logistic_regression
[4] http://thegrandjanitor.com/2015/08/20/gradient-descent-for-logistic-regression/
[5] http://www.holehouse.org/mlclass/06_Logistic_Regression.html



ความคิดเห็น