Logistic regression

การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

Nele Verbiest, Ph.D

Data Scientist @PythonPredictions

Logistic regression: แนวคิดเบื้องต้น

การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

Logistic regression: ฟังก์ชัน Logit

  • ผลลัพธ์ของ $a*age + b$ คือจำนวนจริง
  • ต้องการทำนายค่า 0 หรือ 1
  • ฟังก์ชัน Logit แปลง $a*age + b$ ให้เป็นความน่าจะเป็น

การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

Logistic regression ใน Python

from sklearn import linear_model

logreg = linear_model.LogisticRegression()
X = basetable[["age"]]
y = basetable[["target"]]
logreg.fit(X,y)
print(logreg.coef_)
[[ 0.02449202]]
print(logreg.intercept_)
[-4.3299131]
การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

Multivariate logistic regression

Univariate: $ax + b$

Multivariate: $a_1x_1 + a_2x_2 + ... + a_nx_n + b$

X = basetable[["age","max_gift","income_low"]]

y = basetable[["target"]]
logreg.fit(X,y)
print(logreg.coef_)
[[ 0.0243308   0.03906065 -0.76793773]]
print(logreg.intercept_)
[-8.80643545]
การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

มาฝึกกันเถอะ!

การวิเคราะห์เชิงพยากรณ์เบื้องต้นด้วย Python

Preparing Video For Download...