# Diabetes: Pandas PD Numpy NP Seaborn Sns
# Diabetes: Pandas PD Numpy NP Seaborn Sns
# Diabetes: Pandas PD Numpy NP Seaborn Sns
November 6, 2024
[28]: # Diabetes
C:\Users\ASUS\AppData\Local\Temp\ipykernel_12308\1285016483.py:1:
DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of
pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better
interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
import pandas as pd
[2]: df = pd.read_csv(r"C:\Users\ASUS\Downloads\diabetes.csv")
[3]: df
1
2 0.672 32 1
3 0.167 21 0
4 2.288 33 1
.. … … …
763 0.171 63 0
764 0.340 27 0
765 0.245 30 0
766 0.349 47 1
767 0.315 23 0
# output data
y = df['Outcome']
[5]: sns.countplot(x = y)
2
[6]: y.value_counts()
[6]: Outcome
0 500
1 268
Name: count, dtype: int64
[8]: # cross-validation
from sklearn.model_selection import train_test_split
xtrain, xtest, ytrain, ytest = train_test_split(x, y, random_state = 0,␣
↪test_size=0.5)
[10]: x.shape
[10]: (768, 8)
[11]: xtrain.shape
[11]: (384, 8)
[12]: ytrain.shape
[12]: (384,)
[16]: KNeighborsClassifier()
3
precision recall f1-score support
[24]: tn=confusion_matrix[0][0]
fp=confusion_matrix[0][1]
fn=confusion_matrix[1][0]
tp=confusion_matrix[1][1]
[ ]: