Professional Documents
Culture Documents
19ME 3220
III/IV B.Tech
Odd Sem
for the Academic Year 2021-21
Sesion-25
Logistic Regression
S. Ramesh Kumar
Course Co-ordinator
Logistic Regression using Python
Logistic Regression is a supervised learning
classification algorithm used to predict the
probability of a target variable.
The nature of target or dependent variable is
dichotomous, which means there would be only two
possible classes.
In logistic regression,
the dependent variable
is a binary variable that
contains data coded as
1 (yes, success, etc.) or
0 (no, failure, etc.).
Logistic Regression using Python
X_test
age bought_insurance 29 0
22 0 49 1
25 0 55 1
47 1 25 1
52 0 58 1
6 X_train 46
56
1
1
19
18
0
0
55 0 21 0
60 1 26 0
62 1 40 1
61 1 45 1
18 0 50 1
28 0 54 1
27 0 23 0
from sklearn.linear_model import LogisticRegression
7 model = LogisticRegression()
model.fit(X_train,Y_train)
age
------------------
model.predict(X_test) 10 18
8 array[0, 0, 1], dtype=int64) 26 23
22 40
Model.predict(25) Model.predict(56)
10
Array([0], dtype=int64) Array([1], dtype=int64)