Wednesday, 10 April 2019

To implement Logistic Regression (Python)

import pandas as pd

"""
import matplotlib.pyplot as plt
"""

from sklearn.linear_model import LogisticRegression

df=pd.read_csv("/home/aiktc/Desktop/ins.csv")

lr=LogisticRegression()

lr.fit(df[['age']],df.insurance)


print("Prediction= ",lr.predict([[38]]))

Dataset:

age,insurance
23,0
19,0
44,1
50,1
39,0
25,0
29,0
51,1

Output:

Prediction=  [1]

No comments:

Post a Comment