logestic regression
import pandas as pd
from sklearn import linear_model
import matplotlib.pyplot as plt
In [59]:
df = pd.read_csv("areadata.csv")
df
Out[59]:
In [60]:
%matplotlib inline
plt.xlabel("age")
plt.ylabel("bought_insaurance")
plt.scatter(df.age,df.bought_insaurance,color="red",marker=".")
Out[60]:
In [63]:
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test = train_test_split(df[["age"]],df.bought_insaurance,test_size=0.1)
In [66]:
x_test
Out[66]:
In [67]:
x_train
Out[67]:
In [73]:
from sklearn.linear_model import LogisticRegression
model= LogisticRegression()
model.fit(x_train,y_train)
Out[73]:
In [74]:
x_test
Out[74]:
In [79]:
model.predict_proba([[91]])
Out[79]:
In [ ]:
Comments
Post a Comment