{ "cells": [ { "cell_type": "code", "execution_count": 34, "id": "7bd58c56", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import warnings\n", "warnings.filterwarnings('ignore')" ] }, { "cell_type": "code", "execution_count": 35, "id": "8ecd1ce1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "Outcome | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "6 | \n", "148 | \n", "72 | \n", "35 | \n", "0 | \n", "33.6 | \n", "0.627 | \n", "50 | \n", "1 | \n", "
1 | \n", "1 | \n", "85 | \n", "66 | \n", "29 | \n", "0 | \n", "26.6 | \n", "0.351 | \n", "31 | \n", "0 | \n", "
2 | \n", "8 | \n", "183 | \n", "64 | \n", "0 | \n", "0 | \n", "23.3 | \n", "0.672 | \n", "32 | \n", "1 | \n", "
3 | \n", "1 | \n", "89 | \n", "66 | \n", "23 | \n", "94 | \n", "28.1 | \n", "0.167 | \n", "21 | \n", "0 | \n", "
4 | \n", "0 | \n", "137 | \n", "40 | \n", "35 | \n", "168 | \n", "43.1 | \n", "2.288 | \n", "33 | \n", "1 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
763 | \n", "10 | \n", "101 | \n", "76 | \n", "48 | \n", "180 | \n", "32.9 | \n", "0.171 | \n", "63 | \n", "0 | \n", "
764 | \n", "2 | \n", "122 | \n", "70 | \n", "27 | \n", "0 | \n", "36.8 | \n", "0.340 | \n", "27 | \n", "0 | \n", "
765 | \n", "5 | \n", "121 | \n", "72 | \n", "23 | \n", "112 | \n", "26.2 | \n", "0.245 | \n", "30 | \n", "0 | \n", "
766 | \n", "1 | \n", "126 | \n", "60 | \n", "0 | \n", "0 | \n", "30.1 | \n", "0.349 | \n", "47 | \n", "1 | \n", "
767 | \n", "1 | \n", "93 | \n", "70 | \n", "31 | \n", "0 | \n", "30.4 | \n", "0.315 | \n", "23 | \n", "0 | \n", "
768 rows × 9 columns
\n", "\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "Outcome | \n", "
---|---|---|---|---|---|---|---|---|---|
count | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "768.000000 | \n", "
mean | \n", "3.845052 | \n", "120.894531 | \n", "69.105469 | \n", "20.536458 | \n", "79.799479 | \n", "31.992578 | \n", "0.471876 | \n", "33.240885 | \n", "0.348958 | \n", "
std | \n", "3.369578 | \n", "31.972618 | \n", "19.355807 | \n", "15.952218 | \n", "115.244002 | \n", "7.884160 | \n", "0.331329 | \n", "11.760232 | \n", "0.476951 | \n", "
min | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.000000 | \n", "0.078000 | \n", "21.000000 | \n", "0.000000 | \n", "
25% | \n", "1.000000 | \n", "99.000000 | \n", "62.000000 | \n", "0.000000 | \n", "0.000000 | \n", "27.300000 | \n", "0.243750 | \n", "24.000000 | \n", "0.000000 | \n", "
50% | \n", "3.000000 | \n", "117.000000 | \n", "72.000000 | \n", "23.000000 | \n", "30.500000 | \n", "32.000000 | \n", "0.372500 | \n", "29.000000 | \n", "0.000000 | \n", "
75% | \n", "6.000000 | \n", "140.250000 | \n", "80.000000 | \n", "32.000000 | \n", "127.250000 | \n", "36.600000 | \n", "0.626250 | \n", "41.000000 | \n", "1.000000 | \n", "
max | \n", "17.000000 | \n", "199.000000 | \n", "122.000000 | \n", "99.000000 | \n", "846.000000 | \n", "67.100000 | \n", "2.420000 | \n", "81.000000 | \n", "1.000000 | \n", "
\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "Outcome | \n", "
---|---|---|---|---|---|---|---|---|---|
Pregnancies | \n", "1.000000 | \n", "0.129459 | \n", "0.141282 | \n", "-0.081672 | \n", "-0.073535 | \n", "0.017683 | \n", "-0.033523 | \n", "0.544341 | \n", "0.221898 | \n", "
Glucose | \n", "0.129459 | \n", "1.000000 | \n", "0.152590 | \n", "0.057328 | \n", "0.331357 | \n", "0.221071 | \n", "0.137337 | \n", "0.263514 | \n", "0.466581 | \n", "
BloodPressure | \n", "0.141282 | \n", "0.152590 | \n", "1.000000 | \n", "0.207371 | \n", "0.088933 | \n", "0.281805 | \n", "0.041265 | \n", "0.239528 | \n", "0.065068 | \n", "
SkinThickness | \n", "-0.081672 | \n", "0.057328 | \n", "0.207371 | \n", "1.000000 | \n", "0.436783 | \n", "0.392573 | \n", "0.183928 | \n", "-0.113970 | \n", "0.074752 | \n", "
Insulin | \n", "-0.073535 | \n", "0.331357 | \n", "0.088933 | \n", "0.436783 | \n", "1.000000 | \n", "0.197859 | \n", "0.185071 | \n", "-0.042163 | \n", "0.130548 | \n", "
BMI | \n", "0.017683 | \n", "0.221071 | \n", "0.281805 | \n", "0.392573 | \n", "0.197859 | \n", "1.000000 | \n", "0.140647 | \n", "0.036242 | \n", "0.292695 | \n", "
DiabetesPedigreeFunction | \n", "-0.033523 | \n", "0.137337 | \n", "0.041265 | \n", "0.183928 | \n", "0.185071 | \n", "0.140647 | \n", "1.000000 | \n", "0.033561 | \n", "0.173844 | \n", "
Age | \n", "0.544341 | \n", "0.263514 | \n", "0.239528 | \n", "-0.113970 | \n", "-0.042163 | \n", "0.036242 | \n", "0.033561 | \n", "1.000000 | \n", "0.238356 | \n", "
Outcome | \n", "0.221898 | \n", "0.466581 | \n", "0.065068 | \n", "0.074752 | \n", "0.130548 | \n", "0.292695 | \n", "0.173844 | \n", "0.238356 | \n", "1.000000 | \n", "
\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "Outcome | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "6 | \n", "148 | \n", "72 | \n", "35 | \n", "0 | \n", "33.6 | \n", "0.627 | \n", "50 | \n", "1 | \n", "
1 | \n", "1 | \n", "85 | \n", "66 | \n", "29 | \n", "0 | \n", "26.6 | \n", "0.351 | \n", "31 | \n", "0 | \n", "
3 | \n", "1 | \n", "89 | \n", "66 | \n", "23 | \n", "94 | \n", "28.1 | \n", "0.167 | \n", "21 | \n", "0 | \n", "
5 | \n", "5 | \n", "116 | \n", "74 | \n", "0 | \n", "0 | \n", "25.6 | \n", "0.201 | \n", "30 | \n", "0 | \n", "
6 | \n", "3 | \n", "78 | \n", "50 | \n", "32 | \n", "88 | \n", "31.0 | \n", "0.248 | \n", "26 | \n", "1 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
762 | \n", "9 | \n", "89 | \n", "62 | \n", "0 | \n", "0 | \n", "22.5 | \n", "0.142 | \n", "33 | \n", "0 | \n", "
764 | \n", "2 | \n", "122 | \n", "70 | \n", "27 | \n", "0 | \n", "36.8 | \n", "0.340 | \n", "27 | \n", "0 | \n", "
765 | \n", "5 | \n", "121 | \n", "72 | \n", "23 | \n", "112 | \n", "26.2 | \n", "0.245 | \n", "30 | \n", "0 | \n", "
766 | \n", "1 | \n", "126 | \n", "60 | \n", "0 | \n", "0 | \n", "30.1 | \n", "0.349 | \n", "47 | \n", "1 | \n", "
767 | \n", "1 | \n", "93 | \n", "70 | \n", "31 | \n", "0 | \n", "30.4 | \n", "0.315 | \n", "23 | \n", "0 | \n", "
536 rows × 9 columns
\n", "\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "6 | \n", "148 | \n", "72 | \n", "35 | \n", "0 | \n", "33.6 | \n", "0.627 | \n", "50 | \n", "
1 | \n", "1 | \n", "85 | \n", "66 | \n", "29 | \n", "0 | \n", "26.6 | \n", "0.351 | \n", "31 | \n", "
2 | \n", "8 | \n", "183 | \n", "64 | \n", "0 | \n", "0 | \n", "23.3 | \n", "0.672 | \n", "32 | \n", "
3 | \n", "1 | \n", "89 | \n", "66 | \n", "23 | \n", "94 | \n", "28.1 | \n", "0.167 | \n", "21 | \n", "
4 | \n", "0 | \n", "137 | \n", "40 | \n", "35 | \n", "168 | \n", "43.1 | \n", "2.288 | \n", "33 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
763 | \n", "10 | \n", "101 | \n", "76 | \n", "48 | \n", "180 | \n", "32.9 | \n", "0.171 | \n", "63 | \n", "
764 | \n", "2 | \n", "122 | \n", "70 | \n", "27 | \n", "0 | \n", "36.8 | \n", "0.340 | \n", "27 | \n", "
765 | \n", "5 | \n", "121 | \n", "72 | \n", "23 | \n", "112 | \n", "26.2 | \n", "0.245 | \n", "30 | \n", "
766 | \n", "1 | \n", "126 | \n", "60 | \n", "0 | \n", "0 | \n", "30.1 | \n", "0.349 | \n", "47 | \n", "
767 | \n", "1 | \n", "93 | \n", "70 | \n", "31 | \n", "0 | \n", "30.4 | \n", "0.315 | \n", "23 | \n", "
768 rows × 8 columns
\n", "LogisticRegression(verbose=1)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LogisticRegression(verbose=1)
KNeighborsClassifier(n_neighbors=7)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
KNeighborsClassifier(n_neighbors=7)
\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "6 | \n", "148 | \n", "72 | \n", "35 | \n", "0 | \n", "33.6 | \n", "0.627 | \n", "50 | \n", "
1 | \n", "1 | \n", "85 | \n", "66 | \n", "29 | \n", "0 | \n", "26.6 | \n", "0.351 | \n", "31 | \n", "
3 | \n", "1 | \n", "89 | \n", "66 | \n", "23 | \n", "94 | \n", "28.1 | \n", "0.167 | \n", "21 | \n", "
5 | \n", "5 | \n", "116 | \n", "74 | \n", "0 | \n", "0 | \n", "25.6 | \n", "0.201 | \n", "30 | \n", "
6 | \n", "3 | \n", "78 | \n", "50 | \n", "32 | \n", "88 | \n", "31.0 | \n", "0.248 | \n", "26 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
762 | \n", "9 | \n", "89 | \n", "62 | \n", "0 | \n", "0 | \n", "22.5 | \n", "0.142 | \n", "33 | \n", "
764 | \n", "2 | \n", "122 | \n", "70 | \n", "27 | \n", "0 | \n", "36.8 | \n", "0.340 | \n", "27 | \n", "
765 | \n", "5 | \n", "121 | \n", "72 | \n", "23 | \n", "112 | \n", "26.2 | \n", "0.245 | \n", "30 | \n", "
766 | \n", "1 | \n", "126 | \n", "60 | \n", "0 | \n", "0 | \n", "30.1 | \n", "0.349 | \n", "47 | \n", "
767 | \n", "1 | \n", "93 | \n", "70 | \n", "31 | \n", "0 | \n", "30.4 | \n", "0.315 | \n", "23 | \n", "
536 rows × 8 columns
\n", "LogisticRegression(verbose=1)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LogisticRegression(verbose=1)