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]:
agebought_insaurance
0220
1250
2471
3520
4461
5560
6240
7651
8230
9321
10431
11341
12450
13541
14650
15130
16421
17350
18531
19610
20620
In [60]:
%matplotlib inline 
plt.xlabel("age")
plt.ylabel("bought_insaurance")
plt.scatter(df.age,df.bought_insaurance,color="red",marker=".")
Out[60]:
<matplotlib.collections.PathCollection at 0x18712cad548>
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]:
age
125
932
446
In [67]:
x_train
Out[67]:
age
2062
1245
1642
823
1853
1354
1961
765
1735
1465
247
022
352
624
1513
1134
556
1043
In [73]:
from sklearn.linear_model import LogisticRegression
model= LogisticRegression()
model.fit(x_train,y_train)
Out[73]:
LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
                   intercept_scaling=1, l1_ratio=None, max_iter=100,
                   multi_class='auto', n_jobs=None, penalty='l2',
                   random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
                   warm_start=False)
In [74]:
x_test
Out[74]:
age
125
932
446
In [79]:
model.predict_proba([[91]])
Out[79]:
array([[0.29397733, 0.70602267]])
In [ ]:
 

Comments

Popular posts from this blog

spealized the work. Be ready for the future

lest just create a basic bot operation in python

scatterplot/ violon plot /histogram /boxplot