Diabetes Prediction Using Logistic Regression - Untitled - Ipynb at Main Prajwal10031999 - Diabetes Prediction Using Logistic Regression GitHub
Diabetes Prediction Using Logistic Regression - Untitled - Ipynb at Main Prajwal10031999 - Diabetes Prediction Using Logistic Regression GitHub
Diabetes-Prediction-using-Logistic-Regression / Untitled.ipynb
In [2]:
df1=pd.read_csv("diabetes.csv")
In [3]:
df1.head()
0 6 148 72 35 0 33.6
1 1 85 66 29 0 26.6
2 8 183 64 0 0 23.3
3 1 89 66 23 94 28.1
In [4]:
df1.describe()
In [5]:
sns.heatmap(df1.isnull(),yticklabels=False,cmap='viridis')
Out[5]: <AxesSubplot:>
In [6]:
sns.heatmap(df1,yticklabels=False,cmap='viridis')
Out[6]: <AxesSubplot:>
In [7]:
sns.set_style('whitegrid')
In [9]:
sns.countplot(x='Outcome',hue='Outcome',data=df1,palette='cubehelix')
In [11]:
sns.distplot(df1['Age'],kde=False,color='darkblue',bins=30)
C:\Users\Hp\anaconda3\envs\car\lib\site-packages\seaborn\distributions.py:2551:
FutureWarning: `distplot` is a deprecated function and will be removed in a fut
ure version. Please adapt your code to use either `displot` (a figure-level fun
ction with similar flexibility) or `histplot` (an axes-level function for histo
grams).
warnings.warn(msg, FutureWarning)
Out[11]: <AxesSubplot:xlabel='Age'>
In [12]:
sns.distplot(df1['BloodPressure'],kde=False,color='royalblue',bins=20)
Out[12]: <AxesSubplot:xlabel='BloodPressure'>
In [13]:
sns.jointplot(x='Age',y='BloodPressure',data=df1)
In [16]:
df1.head()
0 6 148 72 35 0 33.6
1 1 85 66 29 0 26.6
2 8 183 64 0 0 23.3
3 1 89 66 23 94 28.1
In [17]:
x=['Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','D
In [18]:
y=['Output']
In [19]:
df2=pd.DataFrame(data=df1)
df2.head()
0 6 148 72 35 0 33.6
1 1 85 66 29 0 26.6
2 8 183 64 0 0 23.3
3 1 89 66 23 94 28.1
In [20]:
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(df1.drop('Outcome',axis=1),df1
In [21]:
X_test.head()
42 7 106 92 18 0 22.7
543 4 84 90 23 56 39.5
In [30]:
from sklearn.linear_model import LogisticRegression
LRModel=LogisticRegression(solver='lbfgs', max_iter=7600)
LRModel.fit(X_train,y_train)
Out[30]: LogisticRegression(max_iter=7600)
In [31]:
predictions_diabetes=LRModel.predict(X_test)
In [33]:
from sklearn.metrics import classification_report, confusion_matrix
print(classification_report(y_test,predictions_diabetes))
In [58]:
# paitentid_54=pd.DataFrame([1,123,126,60,0,30.1,0.349,47],columns=x)
#Defining a sample data to test the model
x=['Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','D
data=[0,170,126,60,35,30.1,0.649,78]
paitentid_54=pd.DataFrame([data],columns=x)
paitentid_54.head()
In [59]:
df1.head()
0 6 148 72 35 0 33.6
1 1 85 66 29 0 26.6
2 8 183 64 0 0 23.3
3 1 89 66 23 94 28.1
In [61]:
print(predictions_diabetes)
[1]
In [ ]: