Logistische regressie

Introductie tot Predictive Analytics in Python

Nele Verbiest, Ph.D

Data Scientist @PythonPredictions

Logistische regressie: intuïtie

Introductie tot Predictive Analytics in Python

Logistische regressie: de logitfunctie

  • Uitvoer van $a*age + b$ is een reëel getal
  • We willen een 0 of 1 voorspellen
  • De logitfunctie zet $a*age + b$ om naar een kans

Introductie tot Predictive Analytics in Python

Logistische regressie in 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]
Introductie tot Predictive Analytics in Python

Multivariate logistische regressie

Univariaat: $ax + b$

Multivariaat: $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]
Introductie tot Predictive Analytics in Python

Laten we oefenen!

Introductie tot Predictive Analytics in Python

Preparing Video For Download...