IDE: Jupyter Notebook
Problem Task : Let we have a data set(insurance.csv) having two attributes like age and buy_insurance and these two attribute containing training data. We will predict who will buy insurance by implementing Logistic Regression technique.
#Import required libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model import seaborn as sns
#Create a scatter plot plt.scatter(df.age,df.buy_insurance,marker='+',color='red')
#We split data set into training and testing data set from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(df[['age']],df.buy_insurance,test_size=0.3) X_test
#Crearte a LogisticRegression model from sklearn.linear_model import LogisticRegression model=LogisticRegression() model.fit(X_train,y_train)
#predict which age value will buy insurance model.predict(X_test) Output: array([1, 1, 1, 0, 0], dtype=int64)
#Check the accuracy model.score(X_test,y_test) Output: 1.0
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc