2024-05-08 08:48:17 +02:00
{
"cells": [
2024-06-07 20:52:07 +02:00
{
"cell_type": "markdown",
"id": "f9f54623-f404-4987-b490-ff028230bf22",
"metadata": {},
"source": [
"## Explorative Datenanalyse\n",
"\n",
"In diesem Notebook wird eine explorative Datenanalyse durchgeführt, um die Struktur und die wichtigsten Merkmale des Datensatzes zu verstehen. \n",
"Die Bereinigung der Daten wird in dem Notebook \"Cleaning.ipynb\" durchgeführt, deshalb wird hier direkt mit den bereinigten Daten gearbeitet. \n",
"Es wird hauptsächlich mit Visualisierungsmethoden wie unterschiedlichen Diagrammen gearbeitet, um die Daten übersichtlich darzustellen. Außerdem werden Methoden der deskriptiven Statistik verwendet, um festzustellen, ob bestimmte Korrelationen und Muster (z. B. der Zusammenhang zwischen einem erhöhten Cholesterinwert und einer Erkrankung) in den Daten von statistischer Signifikanz sind oder auch auf zufällige Variationen zurückgeführt werden können."
]
},
2024-05-08 08:48:17 +02:00
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 4,
2024-05-08 08:48:17 +02:00
"id": "37d611da-6f56-46d8-905a-62026750150c",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>age</th>\n",
" <th>sex</th>\n",
" <th>cp</th>\n",
" <th>trestbps</th>\n",
" <th>chol</th>\n",
" <th>fbs</th>\n",
" <th>restecg</th>\n",
" <th>thalach</th>\n",
" <th>exang</th>\n",
" <th>oldpeak</th>\n",
" <th>slope</th>\n",
" <th>ca</th>\n",
" <th>thal</th>\n",
" <th>goal</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>63</td>\n",
2024-06-07 15:16:29 +02:00
" <td>male</td>\n",
2024-05-08 08:48:17 +02:00
" <td>1</td>\n",
" <td>145</td>\n",
" <td>233</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>150</td>\n",
" <td>0</td>\n",
" <td>2.3</td>\n",
" <td>3</td>\n",
" <td>0.0</td>\n",
" <td>6.0</td>\n",
2024-06-07 20:52:07 +02:00
" <td>0</td>\n",
2024-05-08 08:48:17 +02:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>67</td>\n",
2024-06-07 15:16:29 +02:00
" <td>male</td>\n",
2024-05-08 08:48:17 +02:00
" <td>4</td>\n",
" <td>160</td>\n",
" <td>286</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>108</td>\n",
" <td>1</td>\n",
" <td>1.5</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
2024-06-07 20:52:07 +02:00
" <td>1</td>\n",
2024-05-08 08:48:17 +02:00
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>67</td>\n",
2024-06-07 15:16:29 +02:00
" <td>male</td>\n",
2024-05-08 08:48:17 +02:00
" <td>4</td>\n",
" <td>120</td>\n",
" <td>229</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>129</td>\n",
" <td>1</td>\n",
" <td>2.6</td>\n",
" <td>2</td>\n",
" <td>2.0</td>\n",
" <td>7.0</td>\n",
2024-06-07 20:52:07 +02:00
" <td>1</td>\n",
2024-05-08 08:48:17 +02:00
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>37</td>\n",
2024-06-07 15:16:29 +02:00
" <td>male</td>\n",
2024-05-08 08:48:17 +02:00
" <td>3</td>\n",
" <td>130</td>\n",
" <td>250</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>187</td>\n",
" <td>0</td>\n",
" <td>3.5</td>\n",
" <td>3</td>\n",
" <td>0.0</td>\n",
" <td>3.0</td>\n",
2024-06-07 20:52:07 +02:00
" <td>0</td>\n",
2024-05-08 08:48:17 +02:00
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>41</td>\n",
2024-06-07 15:16:29 +02:00
" <td>female</td>\n",
2024-05-08 08:48:17 +02:00
" <td>2</td>\n",
" <td>130</td>\n",
" <td>204</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>172</td>\n",
" <td>0</td>\n",
" <td>1.4</td>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>3.0</td>\n",
2024-06-07 20:52:07 +02:00
" <td>0</td>\n",
2024-05-08 08:48:17 +02:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2024-06-07 15:16:29 +02:00
" age sex cp trestbps chol fbs restecg thalach exang oldpeak \\\n",
"0 63 male 1 145 233 1 2 150 0 2.3 \n",
"1 67 male 4 160 286 0 2 108 1 1.5 \n",
"2 67 male 4 120 229 0 2 129 1 2.6 \n",
"3 37 male 3 130 250 0 0 187 0 3.5 \n",
"4 41 female 2 130 204 0 2 172 0 1.4 \n",
2024-05-08 08:48:17 +02:00
"\n",
2024-06-07 15:16:29 +02:00
" slope ca thal goal \n",
2024-06-07 20:52:07 +02:00
"0 3 0.0 6.0 0 \n",
"1 2 3.0 3.0 1 \n",
"2 2 2.0 7.0 1 \n",
"3 3 0.0 3.0 0 \n",
"4 1 0.0 3.0 0 "
2024-05-08 08:48:17 +02:00
]
},
2024-06-07 20:52:07 +02:00
"execution_count": 4,
2024-05-08 08:48:17 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2024-06-07 11:20:34 +02:00
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"df = pd.read_csv('./data/dataset_cleaned.csv')\n",
2024-06-07 20:52:07 +02:00
"df['sex'] = df['sex'].replace({0: 'female', 1: 'male'})\n",
2024-06-07 11:20:34 +02:00
"\n",
"# extract all columns except 'goal' --> X\n",
"X = df.loc[:, df.columns != 'goal']\n",
"# extract only the column 'goal' --> y\n",
"y = df.loc[:, 'goal']\n",
"\n",
2024-05-08 08:48:17 +02:00
"df.head()"
]
},
2024-06-05 11:20:55 +02:00
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 5,
2024-05-08 08:48:17 +02:00
"id": "6b3e5424-4a7e-4e53-82b9-d78e38939834",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAGxCAYAAACEFXd4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA4EElEQVR4nO3deVxVdf7H8fcN4YIKKCBbIqKSlZhrU2km7uKWS+5TMpo1o+P8SB3NysT5magzpZZTmuNaOmpOmuWKCy5p5ZLmUqYGLiMMasoFF1A5vz/6eacri4rgvRxfz8fjPB6e7/me7/kc6MK7c77nYDEMwxAAAIBJPeDsAgAAAEoSYQcAAJgaYQcAAJgaYQcAAJgaYQcAAJgaYQcAAJgaYQcAAJgaYQcAAJgaYQcAAJgaYQe4j7z77ruyWCyKiopydin5SklJkcVi0dy5c+1t8fHxslgsdzTOpUuXFB8fr6SkpDvaL79jVa1aVR06dLijcW5l4cKFmjJlSr7bLBaL4uPji/V4wP2OsAPcR2bPni1JOnjwoL7++msnV3N7XnzxRe3YseOO9rl06ZLGjh17x2GnKMcqisLCzo4dO/Tiiy+WeA3A/YSwA9wndu3apX379ql9+/aSpFmzZjm5ottTuXJlPfnkkyV6jEuXLt2zY93Kk08+qcqVKzu1BsBsCDvAfeJGuJkwYYIaNWqkRYsW2X/J/9qpU6f03HPPydvbWxUqVFDfvn21c+fOPLeXpF8CVKdOneTn5ydPT0/Vq1dPS5Ysua16Tp8+rR49esjb21u+vr7q2bOn0tL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"metadata": {},
"output_type": "display_data"
2024-06-07 15:16:29 +02:00
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"201\n"
]
2024-05-08 08:48:17 +02:00
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"\n",
2024-06-07 15:16:29 +02:00
"counts_male = sum(X['sex'] == 'male')\n",
"counts_female = sum(X['sex'] == 'female')\n",
2024-06-07 11:20:34 +02:00
"\n",
2024-06-07 15:16:29 +02:00
"counts_male_sick = sum(np.all([X['sex'] == 'male',\n",
2024-06-07 11:20:34 +02:00
" y > 0], axis=0))\n",
2024-06-07 15:16:29 +02:00
"counts_female_sick = sum(np.all([X['sex'] == 'female',\n",
2024-06-07 11:20:34 +02:00
" y > 0], axis=0))\n",
2024-05-08 08:48:17 +02:00
"\n",
2024-06-07 15:16:29 +02:00
"plt.bar([1, 0], [counts_male, counts_female])\n",
"plt.bar([1, 0], [counts_male_sick, counts_female_sick])\n",
"plt.xticks([1, 0],['male', 'female'])\n",
2024-06-07 20:52:07 +02:00
"plt.ylabel('counts')\n",
2024-05-08 08:48:17 +02:00
"plt.title('Age distribution')\n",
2024-06-07 11:20:34 +02:00
"plt.legend(['healthy', 'sick'])\n",
2024-06-07 15:16:29 +02:00
"plt.show()\n",
"print(counts_male)"
2024-05-08 08:48:17 +02:00
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 6,
2024-05-08 08:48:17 +02:00
"id": "48fd2655-1dcc-41f6-9938-ef6ea937d52e",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAHFCAYAAAAHcXhbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAt00lEQVR4nO3de1TVdb7/8dcudQsKpKZ7Q6GSc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N++s58zOzlZCQoIeffRRrVq1SjExMZo4caL+67/+65z1/tqrr76q3r17y+v1+mo726WtnTt3KiYmRrm5uXr55Ze1cuVKXXPNNRo9erRmzZpVYfyTTz6pvXv36vXXX9f8+fO1a9cu3XbbbTpx4kSVawXqFAPAakuXLjWSzLx584wxxpSVlZnGjRubPn36+I3761//aiSZtWvX+rWPGzfOSDKLFy/2tbVv395069bN/Pzzz35jb731VhMeHm5OnDhxxnpSU1ONJPP+++/7tT/wwAMVzjNt2jRz+n+GVqxYYSSZ7OzsMx7/+++/N5LMtGnTKvSdOt4zzzxzxr7TtWrVyrhcrgrnGzhwoAkNDTWHDh0yxhizePFiI8nk5eX5jdu0aZORZDZt2uRri4+PN61ataq09l/XPXz4cON2u82+ffv8xg0aNMgEBweb4uJiv/PccsstfuPeeecdI8ls2bKl0vMBFwtWZgDLLVy4UEFBQRo+fLgkqXHjxho6dKg+/vhj7dq1yzcuIyNDISEhuvnmm/0+f8899/jtf/vtt/rnP/+pkSNHSpKOHz/u22655RYdOHDgrJc2Nm3apJCQEN1+++1+7SNGjDjnd+natasaNGigP/3pT0pLS9Pu3bvP+ZnKDBky5LzHdujQQV26dPFrGzFihEpLS/X5559X6/zna+PGjerfv78iIyP92kePHq3Dhw9XWNX59Zx27txZkrR3795arRMIdIQZwGLffvutPvroI8XHx8sYo+LiYhUXF+uuu+6S9H9POEnSwYMH5fF4Khzj123//ve/JUmPP/646tev77eNHz9ekvTDDz+csaYzncfr9Z7z+7Rp00YffvihWrRooQkTJqhNmzZq06aNXnrppXN+9nTh4eHnPbayuk61HTx4sErnraqDBw9WWmtERESl52/WrJnfvtvtlvTLpT3gYlbP6QIAVN+iRYtkjNGKFSu0YsWKCv1paWl67rnndOmll6pZs2baunVrhTG/vjH38ssvlyQlJiZq8ODBlZ63Xbt2Z6zpfM9zJn369FGfPn104sQJbdu2Ta+88ooSEhLk8Xh8q0/nUpV311RW16m2U+GhYcOGkqTy8nK/cWcLdeejWbNmOnDgQIX2/fv3S/q//y0AnB0rM4ClTpw4obS0NLVp00abNm2qsD322GM6cOCA1q5dK0nq27evysrKfPunLF++3G+/Xbt2io6O1hdffKHu3btXuoWEhJyxrhtvvFFlZWVavXq1X/uyZcuq9P0uvfRS9ezZU3/9618lyXfJp6ZXI3Jzc/XFF1/4tS1btkwhISG69tprJf3ycj1J2rFjh9+4X3/HU/Wdb239+/fXxo0bfeHllKVLlyo4ONjxR8kBW7AyA1hq7dq12r9/v2bOnKnY2NgK/R07dtTcuXO1cOFC3XrrrRo1apRefPFF3XvvvXruuefUtm1brV27VuvXr5ckXXLJ//1/m9dee02DBg3STTfdpNGjR+uKK67Qjz/+qK+//lqff/55hSelTnfffffpxRdf1H333afnn39e0dHR+uCDD3znOZt58+Zp48aNio+PV8uWLXX06FHfpbIBAwZIkkJCQtSqVSu9//776t+/v5o2barLL7/cFziqKiIiQrfffruSkpIUHh6uN954Q+np6Zo5c6aCg4MlST169FC7du30+OOP6/jx42rSpIlWrVqlTz75pMLxOnXqpJUrVyo1NVXXXXedLrnkEnXv3r3Sc0+bNk3//d//rRtvvFHPPPOMmjZtqjfffFNr1qzRrFmzFBYWVq3vBFx0nL4DGUD13HnnnaZBgwamsLDwjGOGDx9u6tWrZwoKCowxxuzbt88MHjzYNG7c2ISEhJghQ4aYDz74oNKnj7744gtz9913mxYtWpj69esbr9dr+vXr53tq6my+++47M2TIEL/zZGZmnvNppi1btpg//OEPplWrVsbtdptmzZqZvn37mtWrV/sd/8MPPzTdunUzbrfbSDKjRo3yO973339foaYzPc0UHx9vVqxYYTp06GAaNGhgWrdubWbPnl3h8998842Ji4szoaGhpnnz5ubPf/6zWbNmTYWnmX788Udz1113mcsuu8y4XC6/c6qSp7BycnLMbbfdZsLCwkyDBg1Mly5d/ObImP97mundd9/1a8/Ly6swp8DFyGWMMQ7lKAABIDk5WU899ZT27dvH22kBWInLTMBFZO7cuZKk9u3b6+eff9bGjRv18ssv69577yXIALAWYQa4iAQHB+vFF1/Unj17VF5erpYtW2rKlCl66qmnnC4NAKqNy0wAAMBqPJoNAACsRpgBAABWI8wAAACr1fkbgE+ePKn9+/crJCSkSq84BwAAzjHGqKysTBEREX4v9axMnQ8z+/fvr/AXaQEAgB3y8/PP+eqIOh9mTv0Nmfz8fIWGhjpcDQAAOB+lpaWKjIw869+CO6XOh5lTl5ZCQ0MJMwAAWOZ8bhHhBmAAAGA1wgwAALAaYQYAAFiNMAMAAKxGmAEAAFYjzAAAAKsRZgAAgNUIMwAAwGqEGQAAYDXCDAAAsBphBgAAWI0wAwAArEaYAQAAViPMAAAAqxFmAACA1eo5XQAAXGxaP7HG6RKqbM+MeKdLAM6IlRkAAGA1wgwAALAaYQYAAFiNMAMAAKxGmAEAAFYjzAAAAKsRZgAAgNUIMwAAwGqEGQAAYDXCDAAAsBphBgAAWM3xMPOvf/1L9957r5o1a6bg4GB17dpV27dv9/UbY5SUlKSIiAgFBQUpNjZWubm5DlYMAAA
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.hist(X['age'])\n",
"plt.xlabel('Age')\n",
"plt.ylabel('counts')\n",
"plt.title('Age distribution')\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 7,
2024-05-08 08:48:17 +02:00
"id": "b9174a9d-6c8a-4915-9580-48f23cbdd038",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAHFCAYAAAAHcXhbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB9RklEQVR4nO3dd3hUZdrH8e+ZmkwaIYEUCCFAqAGpIk2KgCugrl3EgoC4UhRQwSBgRCUCCqi4qKyyuMq6Nl4L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8t7bzHdratWsXnTt3Ztu2bbz88st8/PHHNG/enMGDBzNjxoyzLj9x4kQOHTrEv/71L9544w327NnD9ddfj9PpvOhahQgoqhDCr7399tsqoL722muqqqpqUVGRGh4ernbr1q3C5V599VUVUL/88ssK+x988EEVUBcsWODd17RpU7VNmzZqeXl5hcsOGDBATUhIUJ1O55/WM2/ePBVQP/nkkwr7H3jggbPu56mnnlL/+DH04YcfqoC6efPmP739EydOqID61FNPnXWe5/amTJnyp+f9UXJysqooyln316dPHzUyMlItKSlRVVVVFyxYoALqgQMHKlxuxYoVKqCuWLHCu69///5qcnLyOWs/s+4777xTNZvN6uHDhytc7rrrrlMtFouan59f4X769etX4XLvv/++Cqhr16495/0JESykZUYIP/fmm28SGhrKnXfeCUB4eDi33XYb3333HXv27PFebtWqVURERPC3v/2twvUHDhxYYXvv3r3s3LmTQYMGAeBwOLynfv36cezYsfMe2lixYgURERHccMMNFfbfddddf/m3tG7dGpPJxPDhw1m4cCH79+//y+ucyy233HLBl23RogVXXHFFhX133XUXhYWFbNy48ZLu/0J9++23XHPNNSQlJVXYP3jwYEpLS89q1TnzMW3VqhUAhw4dqtI6hfB1EmaE8GN79+5l9erV9O/fH1VVyc/PJz8/n1tvvRX4fYQTQG5uLnFxcWfdxpn7jh8/DsBjjz2G0WiscBoxYgQAJ0+e/NOa/ux+4uPj//LvadiwId988w21a9dm5MiRNGzYkIYNG/LSSy/95XX/KCEh4YIve666PPtyc3Mv6n4vVm5u7jlrTUxMPOf9x8TEVNg2m82A+9CeEMHMoHUBQohL99Zbb6GqKh9++CEffvjhWecvXLiQZ599Fr1eT0xMDD/99NNZlzmzY25sbCwA6enp3Hzzzee83yZNmvxpTRd6P3+mW7dudOvWDafTyYYNG3jllVcYM2YMcXFx3tanv3Ixc9ecqy7PPk94CAkJAcBms1W43PlC3YWIiYnh2LFjZ+0/evQo8PtzIYQ4P2mZEcJPOZ1OFi5cSMOGDVmxYsVZp0cffZRjx47x5ZdfAtC9e3eKioq82x7vvfdehe0mTZqQmprKL7/8Qvv27c95ioiI+NO6evbsSVFREZ9++mmF/YsWLbqov0+v19OxY0deffVVAO8hn8pujdi2bRu//PJLhX2LFi0iIiKCtm3bAu7J9QB+/fXXCpc782/01HehtV1zzTV8++233vDi8fbbb2OxWDQfSi6Ev5CWGSH81JdffsnRo0eZPn06PXr0OOv8tLQ05s6dy5tvvsmAAQO47777mD17NnfffTfPPvssjRo14ssvv2Tp0qUA6HS//7Z5/fXXue6667j22msZPHgwderU4dSpU+zYsYONGzeeNVLqj+69915mz57Nvffey3PPPUdqaipffPGF937O57XXXuPbb7+lf//+1KtXD6vV6j1U1rt3bwAiIiJITk7mk08+4ZprrqFmzZrExsZ6A8fFSkxM5IYbbiAjI4OEhATeeecdvv76a6ZPn47FYgGgQ4cONGnShMceewyHw0F0dDSLFy/m+++/P+v2WrZsyccff8y8efNo164dOp2O9u3bn/O+n3rqKT7//HN69uzJlClTqFmzJu+++y5LlixhxowZREVFXdLfJETQ0boHshDi0vz9739XTSaTmpOT86eXufPOO1WDwaBmZ2erqqqqhw8fVm+++WY1PDxcjYiIUG+55Rb1iy++OOfoo19++UW9/fbb1dq1a6tGo1GNj49Xe/Xq5R01dT6//fabesstt1S4nzVr1vzlaKa1a9eqN910k5qcnKyazWY1JiZG7d69u/rpp59WuP1vvvlGbdOmjWo2m1VAve+++yrc3okTJ86q6c9GM/Xv31/98MMP1RYtWqgmk0mtX7++OmvWrLOuv3v3brVv375qZGSkWqtWLXX06NHqkiVLzhrNdOrUKfXWW29Va9SooSqKUuE+OccorC1btqjXX3+9GhUVpZpMJvWKK66o8Bip6u+jmT744IMK+w8cOHDWYypEMFJUVVU1ylFCCB8wbdo0Jk2axOHDh2V2WiGEX5LDTEIEkblz5wLQtGlTysvL+fbbb3n55Ze5++67JcgIIfyWhBkhgojFYmH27NkcPHgQm81GvXr1mDBhApMmTdK6NCGEuGRymEkIIYQQfk2GZgshhBDCr0mYEUIIIYRfkzAjhBBCCL8W8B2AXS4XR48eJSIi4qKmOBdCCCGEdlRVpaioiMTExAqTep5LwIeZo0ePnrUirRBCCCH8Q1ZW1l9OHRHwYcazhkxWVhaRkZEaVyOEEEKIC1FYWEhSUtJ514LzCPgw4zm0FBkZKWFGCCGE8DMX0kVEOgALIYQQwq9JmBFCCCGEX5MwI4QQQgi/JmFGCCGEEH5NwowQQggh/JqEGSGEEEL4NQkzQgghhPBrEmaEEEII4dckzAghhBDCr0mYEUIIIYRfkzAjhBBCCL8mYUYIIYQQfk3CjBBCCCH8WsCvmi2EECIwrFixgh9//JE2bdpw7bXXal2O8CGKqqqq1kVUpcLCQqKioigoKCAyMlLrcoQQQlwCVVXp06cPDocDgKVLl2I2mzWuSlSli/n+lsNMIqCoqkpWVhYul0vrUoQQlaisrMwbZACKi4s1rEb4Ggk
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ax = sns.violinplot(X, x='sex', y='age')\n",
"ax.set_xticklabels(['male', 'female'])\n",
"plt.title('Age distribution')\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 8,
2024-05-08 08:48:17 +02:00
"id": "522ff499-cd7f-4417-ae7d-d637402505b8",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAHFCAYAAAAUpjivAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA0VElEQVR4nO3de1xVVf7/8fdR4HARURE5oog4opW3HG+jNokZON66jTWllab1LUEbskklK9FvQdLkWGk2NpPSNI7No9QulmKpdCFHvKWp2Q0vNRLlBfAGCOv3hz/P1xNqiuA5rl7Px2M/Huy11977s89Gztu19z7HYYwxAgAAsFQdbxcAAABQmwg7AADAaoQdAABgNcIOAACwGmEHAABYjbADAACsRtgBAABWI+wAAACrEXYAAIDVCDvARbJ582bdddddio2NVWBgoOrVq6df//rXyszM1P79+939WrZsqcGDB9fYfnfu3CmHw6H58+fX2DZPlZubq7S0NB08eLBWtn+uWrZsqZEjR1Z7fYfDobS0NPf8/Pnz5XA4tHPnzvPaTnp6upYsWXJe65xuX/Hx8Wrfvv15befnvPPOOx7HeKoLff0AX0bYAS6CF198UV26dFFeXp4eeughLVu2TIsXL9bNN9+sF154QaNHj/Z2idWWm5urqVOnej3s1LRBgwbpk08+UdOmTc9rveqEneru63y98847mjp16mmXLV68WI8++mit7h/wFj9vFwDY7pNPPtGYMWOUkJCgJUuWyOl0upclJCTowQcf1LJly7xYoW86cuSIgoODvbb/iIgIRURE1Oo+jh49qsDAwIuyr5/TuXNnr+4fqE2M7AC1LD09XQ6HQ3PnzvUIOicFBATouuuuq9K+bNky/frXv1ZQUJAuu+wyvfTSS1X6fPbZZ7r++uvVsGFDBQYG6sorr1RWVtY51fXll19q2LBhatKkiZxOpy6//HLNnj3bo09lZaUef/xxtW3bVkFBQWrQoIE6duyoZ555RpKUlpamhx56SJIUGxsrh8Mhh8Oh1atXu7fx6quvqmfPngoJCVG9evXUv39/bdy40WM/I0eOVL169bRlyxYlJiYqNDRU/fr1kyTt379fSUlJatasmQICAtSqVStNnjxZpaWl53ScP1VcXKx77rlH4eHhqlevnn73u9/piy++qNLvdJeWNm7cqMGDB7tfs6ioKA0aNEjffvutpBOXwg4fPqysrCz3axEfH++xvezsbI0aNUoREREKDg5WaWnpWS+Zffjhh/rNb36joKAgNWvWTI8++qgqKircy1evXl3lNZeqXr4cOXKk+/yerO3UfZ7uMtbu3bt1++23e/yOPP3006qsrKyynz//+c+aMWOGYmNjVa9ePfXs2VNr1qw5hzMC1D5GdoBaVFFRoZUrV6pLly6Kjo4+5/U+/fRTPfjgg5o0aZIiIyP1t7/9TaNHj1br1q119dVXS5J27NihXr16qUmTJnr22WcVHh6uV155RSNHjtT333+vCRMmnHH727ZtU69evdSiRQs9/fTTcrlcWr58ue6//379+OOPmjJliiQpMzNTaWlpeuSRR3T11VervLxcn3/+ufuS1d133639+/frueee06JFi9yXYa644gpJJ4LeI488orvuukuPPPKIysrK9NRTT+m3v/2t1q5d6+4nSWVlZbruuut07733atKkSTp+/LiOHTumvn376uuvv9bUqVPVsWNHffjhh8rIyNCmTZu0dOnS8zofxhjdcMMNys3N1WOPPaZu3brp448/1oABA3523cOHDyshIUGxsbGaPXu2IiMjVVBQoFWrVqmkpETSiVG8a665Rn379nVfEqpfv77HdkaNGqVBgwbpH//4hw4fPix/f/8z7rOgoEC33nqrJk2apGnTpmnp0qV6/PHHdeDAAc2aNeu8jv3RRx/V4cOH9dprr+mTTz5xt5/p0tkPP/ygXr16qaysTP/7v/+rli1b6u2339af/vQnff3113r++ec9+s+ePVuXXXaZZs6c6d7fwIEDlZ+fr7CwsPOqFahxBkCtKSgoMJLMrbfees7rxMTEmMDAQLNr1y5329GjR02jRo3Mvffe62679dZbjdPpNLt37/ZYf8CAASY4ONgcPHjQGGNMfn6+kWTmzZvn7tO/f3/TvHlzU1RU5LHu2LFjTWBgoNm/f78xxpjBgwebK6+88qz1PvXUU0aSyc/P92jfvXu38fPzM+PGjfNoLykpMS6Xy9xyyy3uthEjRhhJ5qWXXvLo+8ILLxhJ5t///rdH+/Tp040kk52d7W6LiYkxI0aMOGut7777rpFknnnmGY/2J554wkgyU6ZMcbfNmzfP47jWrVtnJJklS5acdR8hISGnrePk9u68884zLjv1NezTp4+RZN544w2Pvvfcc4+pU6eO+/dj1apVRpJZtWqVR7/Tnffk5GRzpj/7P339Jk2aZCSZ//znPx79xowZYxwOh9mxY4fHfjp06GCOHz/u7rd27VojyfzrX/867f6Ai4nLWIAPuvLKK9WiRQv3fGBgoNq0aaNdu3a521auXKl+/fpVGTEaOXKkjhw54vG/91MdO3ZM77//vm688UYFBwfr+PHj7mngwIE6duyY+/JD9+7d9emnnyop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/fpp27ZtHscmnXjtHQ6H+7UELgWM7AC1rGfPnpozZ46SkpLUpUsXjRkzRu3atVN5ebk2btyouXPnqn379hoyZMh5bXfKlCl6++231bdvXz322GNq1KiR/vnPf2rp0qXKzMw86xMwzzzzjK666ir99re/1ZgxY9SyZUuVlJToq6++0ltvveW+H2PIkCFq3769unbtqoiICO3atUszZ85UTEyM4uLiJJ0Y7Ti5zREjRsjf319t27ZVy5YtNW3aNE2ePFnffPONfve736lhw4b6/vvvtXbtWoWEhJzxA+5OuvPOOzV79myNGDFCO3fuVIcOHfTRRx8pPT1dAwcO1LX
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ax = plt.hist(X['chol'])\n",
2024-06-07 20:52:07 +02:00
"plt.xlabel('Cholesterol')\n",
2024-05-08 08:48:17 +02:00
"plt.ylabel('counts')\n",
2024-06-07 20:52:07 +02:00
"plt.title('Cholesterol distribution')\n",
2024-05-08 08:48:17 +02:00
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 9,
2024-05-08 08:48:17 +02:00
"id": "f220fadf-33ec-4bf6-a225-a2c874f02088",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAHFCAYAAAAHcXhbAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA+A0lEQVR4nO3de1yUdf7//+d4YACF8YQMKCqueMhjm6aSCVqQh9SyLcsOmtW3RHPVLY+V1BaUpVFranortTVrt1IzNRVLyY1c0fTjqcxNPBVEGQKeAOX9+6Mfs46AAovOXPa4327X7ea8r/e8r9e8GZ2n7+u6GJsxxggAAMCiqnm6AAAAgP8FYQYAA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JYWFhbu3Dhw/XqVOnXP/b/fzzz3XNNdfo+uuvL9HPGONazdiwYYMCAgI0cOBAt36XWiG60L333uv2ODIyUk2bNtWGDRvc2uvWravevXu7ta1cuVLt2rVTp06ddPbsWdd2yy23uJ266NKliyTprrvu0j//+U/98MMPJeq4/vrr9X//93+Ki4vT2rVrlZubW6HXUZrevXurbt26rsdnzpzRZ599pttvv13+/v5uNffr109nzpy56KmN4jm5cM7KM+ctWrRQ3bp1NXHiRM2dO1d79+6t1Gu64447yt23rPdHUVGRvvjii0odv7zK+z4u1r9/f1WvXt31uEOHDpKkQ4cOXdY68ftBmAHO06ZNG3Xu3FmdO3dWnz599Oabbyo2NlYTJky46CmRY8eOlbokHxoa6tpf0X7BwcEl+jmdzgq9ntL6O51O13GKlVbTTz/9pJ07d6pmzZpuW0BAgIwx+uWXXyRJPXv21PLly3X27Fk98MADaty4sdq1a6f33nvPNdbkyZP1yiuvaPPmzerbt6/q16+vm266SVu3bq3Q67lYzceOHdPZs2f1t7/9rUTN/fr1kyRXzaU5duyYatSoofr167u1l2fOHQ6HUlJS1KlTJ02ZMkVt27ZVaGiopk2bpsLCwkq/pou52Pvjwp9vVSvv+7jYhXNqt9sl/XY6FagKXDMDXEKHDh20du1afffddyX+J1qsfv36ysjIKNH+448/SpIaNGhQ4X5btmwp0a+8FwBfrH9mZqZatGjh1nbhBbbFtfj5+entt98udeziWiVp0KBBGjRokPLz87V582YlJiZq6NChatasmbp3764aNWpo/PjxGj9+vI4fP67169drypQpuuWWW3TkyBH5+/vL19dX+fn5JY5TVgC5sOa6deuqevXquv/++zVq1KhSnxMeHl5qu/TbnJ89e1bHjh1z+/At75y3b99e77//vowx2rlzpxYuXKjnnntOfn5+mjRpUrnGKO3nUJaffvqpRFtxrcX1+/r6SlKJeb1YqCuP8r6PgSuFlRngEnbs2CFJF7099qabbtLnn3/u+se82DvvvCN/f39169bN1W/v3r36+uuvS/Sz2Wzq1auXJKlXr17Ky8vTihUr3PotWbKkQrW/++67bo9TU1N16NAh1100F3Prrbfq+++/V/369V2rVedvpd15ZLfbFRUVpZdeeknSb3f4XKhOnTr605/+pFGjRunXX391u2MmKyvL7UO6oKBAa9euLddr9ff3V69evbR9+3Z16NCh1JovXCE4X/HcXzhnFZ1zm82mjh076tVXX1WdOnXcftZ2u73KViPKen9Uq1ZNPXv2lCTXz2jnzp1u/S58XnFtUvlWS8r7PgauFFZmgPPs3r1bZ8+elfTbUvnSpUuVnJys22+//aL/q582bZpWrlypXr166ZlnnlG9evX07rvvatWqVZo+fbrrjo1x48bpnXfeUf/+/fXcc8+padOmWrVqlWbPnq2RI0eqZcu
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.hist(X['trestbps'])\n",
"plt.xlabel('Blood pressure (rest)')\n",
"plt.ylabel('counts')\n",
"plt.title('Blood pressure distribution')\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 10,
2024-06-07 15:16:29 +02:00
"id": "abe0020f-8588-48bf-af58-f67b326cdd25",
"metadata": {},
2024-05-08 08:48:17 +02:00
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "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CgoKnDqOC+nUqZOCgoJszwsLC/XVV1+pV69eqlGjhl3m7t27q7CwUN9+++0l9/npp5/Ky8tL3bp1u+S8Vq1a6fjx4+rbt68+/fRTHTlypMycpUuXqmPHjoqIiLDLkpCQIElau3atbW6bNm304osvasqUKXrsscd03333aeDAgc78OABUAZRbAFVOo0aN1KJFC7Vo0ULdunXTO++8o65du2r06NGX/BX60aNHdc0115QZj4iIsG13dl5YWFiZeeHh4U4dz4Xmh4eH277PeRfKdOjQIW3fvl2enp52D39/f5mmaSt07dq10+LFi3Xu3Dk98MADioyMVExMjD766CPbvp5++mm99tpr+vbbb5WQkKCQkBB17txZW7Zscep4LpX56NGjOnfunKZNm1Ymc/fu3SXpgiX0fy1YsEAJCQl/+Ga6+++/X//4xz+0f/9+9enTR3Xq1FHr1q21cuVK25xDhw5pyZIlZbLcfPPNF8zSr18/eXl5qaioSKNGjXL45wCg6mDNLYCrQpMmTbRixQr98MMPZa64nhcSEqKDBw+WGT9w4IAkKTQ01Ol5mzdvLjPP0TeUXWp+Xl6err/+erux379h63wWX19f/eMf/7jgvs9nlaS77rpLd911l4qKivTtt98qLS1NKSkpql+/vm6//XZ5eHho+PDhGj58uI4fP65Vq1bpmWeeUXx8vHJyclSjRg35+PioqKiozPe5WCH9feagoCC5u7vr/vvv1+OPP37B1zRo0OCC45KUn5+vr776yuF7CA8YMEADBgzQqVOntG7dOo0fP149evTQDz/8oHr16ik0NFRNmjTRiy++eMHXn/8fGum3td79+vVTUFCQvL29NXDgQH3zzTfy8vJyKAuAqoFyC+CqkJmZKUmqXbv2Red07txZixYt0oEDB+xKywcffKAaNWrotttus81LS0vTtm3bdOutt9rNMwxDHTt2lCR17NhRH3/8sT777DO7pQnz5s1zKvvcuXPVp08f2/P09HTt379fDz/88B++tkePHpo4caJCQkIuWQr/l7e3t9q3b69atWppxYoV+u6773T77bfbzalVq5buuece/fzzz0pNTdW+ffvUuHFj1a9fX4cPH9ahQ4dsV62Li4u1YsUKh753jRo11LFjR3333Xdq0qSJ08VwyZIlMgxDPXr0cOp1fn5+SkhIUHFxse6++27t3LlT9erVU48ePbRs2TJdd911dssnLmT8+PFav369vvzyS/n5+aldu3YaNWqU3d0kAFR9lFsAVc73339vu03T0aNH9cknn2jlypXq1avXJQve+PHjbWssx40bp+DgYM2dO1eff/65XnnlFQUGBkqShg0bpg8++EB/+tOf9Pzzz6tevXr6/PPP9eabb+qxxx7TDTfcIEl64IEHNHnyZD3wwAN68cUX1bBhQy1btszhonfeli1b9PDDD+vPf/6zcnJyNGbMGNWtW1eDBg36w9empqZq4cKFateunYYNG6YmTZqotLRU2dnZ+vLLLzVixAi1bt1a48aNU25urjp37qzIyEgdP35cU6dOlaenp9q3by9JSkxMtN1DuHbt2tq/f7+mTJmievXqqWHDhpKk5ORkjRs3Tvfee69GjRqlwsJCvfHGGyopKXH4eKdOnaq2bdvqjjvu0GOPPab69evrxIkT+umnn7RkyRK
2024-05-08 08:48:17 +02:00
"text/plain": [
2024-06-07 15:16:29 +02:00
"<Figure size 800x600 with 1 Axes>"
2024-05-08 08:48:17 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-06-07 15:16:29 +02:00
"plt.figure(figsize=(8, 6))\n",
"sns.boxplot(x='sex', y='trestbps', data=df)\n",
2024-06-07 20:52:07 +02:00
"plt.title('Blood pressure / sex')\n",
2024-06-07 15:16:29 +02:00
"plt.xlabel('sex')\n",
2024-05-08 08:48:17 +02:00
"plt.ylabel('Blood pressure (rest)')\n",
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 11,
2024-05-08 08:48:17 +02:00
"id": "5c174a9d-59b7-4efe-a0eb-a132388c1d2a",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAHFCAYAAAAUpjivAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAADo8ElEQVR4nOzdd3hUZfbA8e/0STKT3iuh995RqoioWLBRFsGu2FDcte0qrv50rYtr72DFjqKCiBSV3qX3GtJ7m35/f1wyYchMSCAQiOfzPHkk971z7ztjkjnzlnM0iqIoCCGEEEI0UdrG7oAQQgghxOkkwY4QQgghmjQJdoQQQgjRpEmwI4Q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MOOnTogNPpZP369bz99tt07NixTnltjvX444/zww8/MGTIEB577DEiIyP55JNP+PHHH3nuuecICwur87XcbjffffcdDz300AnP3bx5M6tWreKOO+5g6NChNdoHDBjAiy++yHvvvcddd93FRRddxIABA5g6dSolJSX06NGD5cuX8+GHHwKg1VZ/Dnv55Zc577zzOP/887njjjto1qwZpaWl7N69mzlz5rBw4cKA/Xrsscc4fPgww4YNIzk5maKiIl5++WUMBoM34KqSk5PDlVdeyS233EJxcTGPP/44ZrOZhx9+uK4vGQBWq5W0tDS+++47hg0bRmRkJNHR0TRr1qzWx9Xn/vfeey/XXXcdGo2GyZMnn7BPxcXFDBkyhHHjxtG2bVu
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from sklearn.linear_model import LinearRegression\n",
"\n",
"model = LinearRegression()\n",
"x = np.array(X['age'])\n",
"x = x[:, np.newaxis]\n",
"reg = model.fit(x, X['chol'])\n",
"pred = reg.predict(x)\n",
"\n",
"sns.scatterplot(X, x='age', y='chol', hue='sex')\n",
"plt.plot(x, pred, color='black')\n",
"plt.xlabel('Age')\n",
"plt.ylabel('Chol')\n",
2024-06-07 11:20:34 +02:00
"plt.title('Chol / Age split by sex')\n",
"plt.show()"
2024-05-08 08:48:17 +02:00
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 12,
2024-05-08 08:48:17 +02:00
"id": "b3d627cf-3ec9-4cd9-bee6-5baeb9d1a22d",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAHFCAYAAAAUpjivAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAADcKElEQVR4nOzdd3hTZfvA8W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Z53Jceq1d/TyvPlbW19wVPz8/Nm7cSOvWrXnxxRdp3rw5kZGRvPrqq5hMJodz3b0vroy3MpX1/k888QRr167l2LFjmEwm5syZw1133XXNfwfXer9dz3tl3LhxmEwmlEolTzzxxA09f6H2ufa6TEGo5Vq2bMnKlSs5fvy4U4/MJUFBQaSmpjodv3jxIgDBwcHlPm/Xrl1O55V1gnJp56elpdGgQQOHY1dPAL4Ui1ar5euvv3Z57UuxAgwdOpShQ4diMBjYsWMH06ZNY/To0cTFxdGlSxeUSiVPPfUUTz31FHl5eaxZs4YXX3yRpKQkUlJS8PT0xMPDA4PB4HQfdx/wV8ccEBCAQqHg/vvvZ+LEiS4fEx8f7/I4QH5+PmvXri3TMurjx4+zZcsWAOrVq+fynJUrVzJo0CCCgoIAWyJztbS0NIfenfK85q60aNGCBQsWIEkSBw4cYN68ebzxxhtotVqef/55h/u6igWwx1uZynr/0aNH89xzz/HZZ5/RuXNn0tLS3P5sr3St91t53yvFxcXcf//9NGrUiPT0dB566CF+//3
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"model = LinearRegression()\n",
"x = np.array(X['chol'])\n",
"x = x[:, np.newaxis]\n",
"reg = model.fit(x, X['trestbps'])\n",
"pred = reg.predict(x)\n",
"\n",
"sns.scatterplot(X, x='chol', y='trestbps', hue='sex')\n",
"plt.plot(x, pred, color='black')\n",
"plt.xlabel('Chol')\n",
"plt.ylabel('Blood pressure (rest)')\n",
2024-06-07 11:20:34 +02:00
"plt.title('Blood pressure / Age split by sex')\n",
"plt.show()"
2024-05-08 08:48:17 +02:00
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 13,
2024-05-08 08:48:17 +02:00
"id": "3a6dc91a-f3e9-4d7e-9e4b-58c59d24463c",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAA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FRnp6eDgDw8vLSGL4iIiLSaXo65CQWvZqjQ0RERKVnyZIlcHNzg6mpKRo2bIhDhw5prb9u3TrUrVsX5ubmcHJywmeffYbbt29L2kYmOkRERLpMplVXGzZswLhx4xAREYHk5GS0aNECHTt2REZGRrH14+Pj0a9fPwwaNAhnzpzBL7/8guPHj2vsdSeFdybRcXV1hSAIqFevntxNISIiEo9Mq64WLFiAQYMGYfDgwfDy8kJ0dDScnZ2xdOnSYusfPXoUrq6uGDNmDNzc3NC8eXMMGzYMiYmJYnwKJXpnEh0iIiLSrrjTAHJycorUy83NRVJSEgICAjTKAwICkJCQUOy9/f398e+//2LHjh0QBAHXr1/Hr7/+is6dO0vyLIWY6BAREekyEXt0ijsNICoqqkjIW7duoaCgAA4ODhrlDg4OyMrKKraZ/v7+WLduHXr16gUTExM4OjqiXLlyWLx4sSQfSyEmOkRERLpMxDk6xZ0GEB4eXmLoF08WEAShxNMGzp49izFjxmDy5MlISkpCbGwsrly5orEFjBT0bnk5ERERvRmlUgmlUvnSenZ2djA0NCzSe3Pjxo0ivTyFoqKi0KxZM0yYMAEAUKdOHVhYWKBFixaYOXMmnJyc3v4BisEeHSIiIl0mw2RkExMTNGzYEHFxcRrlcXFx8Pf3L/Y9jx8/hoGBZtphaPjsSCVBEF7zoV8de3SIiIh0mUw7I4eEhCAoKAi+vr7w8/PDsmXLkJGRoR6
2024-05-08 08:48:17 +02:00
"text/plain": [
"<Figure size 640x480 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-06-07 15:16:29 +02:00
"corr = df.loc[:,df.columns!='sex'].corr()\n",
2024-05-08 08:48:17 +02:00
"\n",
2024-06-07 11:20:34 +02:00
"sns.heatmap(corr)\n",
"plt.show()"
2024-05-08 08:48:17 +02:00
]
2024-06-07 15:16:29 +02:00
},
{
"cell_type": "markdown",
"id": "038d8abb-e88f-472d-95c4-bc0c51695196",
"metadata": {},
"source": [
2024-06-07 20:52:07 +02:00
"#### Cholesterinwerte im Vergleich Frauen/Männer"
2024-06-07 15:16:29 +02:00
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 15,
2024-06-07 15:16:29 +02:00
"id": "48e6d986-b7f9-45e6-8bf2-32e687eb132d",
"metadata": {},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArcAAAIhCAYAAABUopIpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA9OklEQVR4nO3deXQUVeL+/6fI1tkJQRLCEkEQB8IuMmaQgCwxbIKOKKCCoCIREAEZERV0kAyMAo44+BFEcWHQr4gbhE0QxYAsIiA4jiBL0ITIlgTMAsn9/eHPPrQB7A5JOlTer3P6HPrW7cpTRNvH6ttVljHGCAAAALCBat4OAAAAAJQVyi0AAABsg3ILAAAA26DcAgAAwDYotwAAALANyi0AAABsg3ILAAAA26DcAgAAwDYotwAAALANyi0AW9m5c6fuueceNWjQQA6HQyEhIWrTpo1mzJih48ePO+ddeeWV6tWrV5n93AMHDsiyLL322mtlts9zpaWlacqUKTp58mS57N9dV155pYYMGeL2/H/961+KjIzU2bNnyy8UAJyDcgvANubNm6e2bdtqy5YteuSRR7RixQotXbpUt912m1566SUNGzbM2xFLLS0tTU899ZTXy62nlixZoptvvlm+vr7ejgKgiuDdBoAtbNy4USNGjFC3bt30/vvvKyAgwLmtW7duGjdunFasWOHFhJXTL7/8oqCgoHLZ95EjR7RhwwZNmDChXPYPAOfDmVsAtjBt2jRZlqWXX37Zpdj+xt/fX3369CkxvmLFCrVp00aBgYG65pprtGDBghJzvvnmG918882KiIiQw+FQq1attHDhQrdyff/99xo4cKBq1aqlgIAA/elPf9KLL77oMqe4uFhTp05VkyZNFBgYqOrVq6tFixZ6/vnnJUlTpkzRI488Iklq0KCBLMuSZVn69NNPnft4++23df311ys4OFghISFKTEzU9u3bXX7OkCFDFBISol27dql79+4KDQ1Vly5dJEnHjx9XcnKy6tSpI39/fzVs2FCTJk1SQUGBW8d5PkuXLlVISIi6du160Xlz585Vy5YtFRISotDQUF1zzTV67LHHXOZkZmZq+PDhqlu3rvz9/dWgQQM99dRTzuUOxhj16NFDkZGROnTokPN1v/zyi5o1a6Y//elPOn36dKmPBcDlgzO3AC57RUVFWrt2rdq2bat69eq5/bodO3Zo3LhxevTRRxUVFaX58+dr2LBhatSokTp27ChJ+u677xQfH69atWo514+++eabGjJkiI4cOXLRs5J79uxRfHy86tevr+eee07R0dFauXKlRo8eraNHj2ry5MmSpBkzZmjKlCl6/PHH1bFjR505c0b//e9/nUsQ7r33Xh0/flwvvPCC3nvvPdWuXVuS1LRpU0m/FvvHH39c99xzjx5//HEVFhbqn//8p2644QZt3rzZOU+SCgsL1adPHw0fPlyPPvqozp49q/z8fHXu3Fn79u3TU089pRYtWujzzz9XSkqKvv76ay1btsyj38dvlixZol69ep33fzZ+s3jxYiUnJ2vUqFF69tlnVa1aNe3du1d79uxxzsnMzNR1112natWq6cknn9RVV12ljRs3aurUqTpw4IBeffVVWZalN954Q61atVL//v31+eefy8/PT8nJydq/f7++/PJLBQcHl+o4AFxmDABc5jIzM40kc8cdd7j9mtjYWONwOMzBgwedY3l5eaZGjRpm+PDhzrE77rjDBAQEmEOHDrm8PikpyQQFBZmTJ08aY4zZv3+/kWReffVV55zExERTt25dk52d7fLakSNHGofDYY4fP26MMaZXr16mVatWF837z3/+00gy+/fvdxk/dOiQ8fX1NaNGjXIZz83NNdHR0aZ///7OscGDBxtJZsGCBS5zX3rpJSPJvPPOOy7j06dPN5LMqlWrnGOxsbFm8ODBF81qjDFHjx41vr6+ZsmSJRedN3LkSFO9evWLzhk+fLgJCQlx+V0ZY8yzzz5rJJndu3c7xzZs2GB8fX3NmDFjzIIFC4wkM3/+/D/MC8A+WJYAoMpq1aqV6tev73zucDh09dVX6+DBg86xtWvXqkuXLiXOCA8ZMkS//PKLNm7ceN595+fn65NPPlG/fv0UFBSks2fPOh89evRQfn6+Nm3aJEm67rrrtGPHDiUnJ2vlypXKyclx+xhWrlyps2fP6u6773b5GQ6HQwkJCS5LF35z6623ujxfu3atgoOD9de//rXEMUrSJ5984nae33zwwQfy9/fXTTfddNF51113nU6ePKkBAwbogw8+0NGjR0vM+fjjj9W5c2fFxMS4HGNSUpIkaf369c65f/nLX/TMM89o9uzZGjFihO68887L+ouEADxHuQVw2atZs6aCgoK0f/9+j14XGRlZYiwgIEB5eXnO58eOHXMuAzhXTEyMc/v5HDt2TGfPntULL7wgPz8/l0ePHj0kyVnkJk6cqGeffVabNm1SUlKSIiMj1aVLF23duvUPj+HIkSOSpHbt2pX4OW+//XaJshgUFKSwsLASWaOjo2VZlst4rVq15Ovre8FjvJh3331XSUlJf/hltbvuuksLFizQwYMHdeutt6pWrVpq3769Vq9e7XKMH330UYnja9asmSSVOMZBgwbJ399fBQUFzrXKAKoO1twCuOz5+PioS5cuSk1N1eHDh1W3bt0y23dkZKQyMjJKjP/000+Sfi3W5xMRESEfHx/dddddevDBB887p0GDBpIkX19fjR07VmPHjtXJkye1Zs0aPfbYY0pMTFR6evpFC+JvP//dd99VbGzsHx7P7wus9OsxfvnllzLGuGzPysrS2bNnL3iMF5Kdna1PPvnE7Wv+3nPPPbrnnnt0+vRpffbZZ5o8ebJ69eql//3vf4qNjVXNmjXVokULPfPMM+d9/W//oyH9uv560KBBioiIUEBAgIYNG6YvvvhC/v7+Hh0DgMsX5RaALUycOFHLly/Xfffd5/xI/FxnzpzRihUr1Lt3b4/226VLFy1dulQ//fSTS4l6/fXXFRQUpD//+c/nfV1QUJA6d+6s7du3q0WLFm6Xq+rVq+uvf/2rfvzxR40ZM0YHDhxQ06ZNnV/KOvessiQlJibK19dX+/btK7HcwJNjfOedd/T++++rX79+Lsf423ZPfPTRR7Isy+ObZAQHByspKUmFhYXq27evdu/erdjYWPXq1UvLly/XVVddpYiIiIvuY/Lkyfr888+1atUqBQcHq2PHjnrkkUecV54AYH+UWwC2cP3112vu3LlKTk5W27ZtNWLECDVr1kxnzpzR9u3b9fLLLysuLs7jcjt58mTnms8nn3xSNWrU0FtvvaVly5ZpxowZCg8Pv+Brn3/+eXXo0EE33HCDRowYoSuvvFK5ubnau3evPvroI61du1aS1Lt3b8XFxenaa6/VFVdcoYMHD2r27NmKjY1V48aNJUnNmzd37nPw4MHy8/NTkyZNdOWVV+rpp5/WpEmT9MMPP+imm25SRESEjhw5os2bNys4OFhPPfXURY/x7rvv1osvvqjBgwfrwIEDat68uTZs2KBp06apR48ef3gpr99799131a1bN4WGhv7h3Pvuu0+BgYH6y1/+otq1ayszM1MpKSkKDw9Xu3btJElPP/20Vq9erfj4eI0ePVpNmjRRfn6+Dhw4oOXLl+ull15S3bp1tXr1aqWkpOiJJ55wFvKUlBSNHz9enTp1cinuAGzM299oA4Cy9PXXX5vBgweb+vXrG39/fxMcHGxat25tnnzySZOVleWcFxsba3r27Fni9QkJCSYhIcFlbNeuXaZ3794mPDzc+Pv7m5YtW7pcFcGY818t4bfxoUOHmjp16hg/Pz9zxRVXmPj4eDN16lTnnOeee87Ex8ebmjVrGn9/f1O/fn0zbNgwc+DAAZd9TZw40cTExJhq1aoZSWbdunXObe+//77p3LmzCQsLMwEBASY2Ntb89a9/NWvWrHHOGTx4sAkODj7v39uxY8fMAw88YGrXrm18fX1NbGysmThxosnPz3eZ90dXSzh16pRxOBwl/h4uZOHChaZz584mKirK+Pv7m5iYGNO/f3+zc+dOl3k///y
2024-06-07 15:16:29 +02:00
"text/plain": [
"<Figure size 800x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(8, 6))\n",
"sns.boxplot(x='sex', y='chol', data=df)\n",
2024-06-07 20:52:07 +02:00
"plt.title('Cholesterol / sex')\n",
"plt.xlabel('Sex')\n",
"plt.ylabel('Cholesterol in mg/dl')\n",
2024-06-07 15:16:29 +02:00
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 16,
2024-06-07 15:16:29 +02:00
"id": "3e85fdf6-3a77-41b0-bbc7-a407fbb1374f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-06-07 20:52:07 +02:00
" Geschlecht Untere Grenze Obere Grenze\n",
2024-06-07 15:16:29 +02:00
"0 Männer 234.288517 246.199046\n",
"1 Frauen 249.044612 275.413721\n"
]
}
],
"source": [
2024-06-07 20:52:07 +02:00
"# confidence interval (95%) for cholesterol level of men/women\n",
2024-06-07 15:16:29 +02:00
"from scipy import stats\n",
"\n",
2024-06-07 20:52:07 +02:00
"# filter by gender and calculate interval\n",
2024-06-07 15:16:29 +02:00
"conf_level = 0.95\n",
"chol_men = df.loc[df['sex'] == 'male', 'chol']\n",
"chol_women = df.loc[df['sex'] == 'female', 'chol']\n",
"conf_int_men = stats.t.interval(conf_level, len(chol_men) - 1, loc=chol_men.mean(), scale=stats.sem(chol_men))\n",
"conf_int_women = stats.t.interval(conf_level, len(chol_women) - 1, loc=chol_women.mean(), scale=stats.sem(chol_women))\n",
"\n",
"result_table_men_vs_women = pd.DataFrame({\n",
" 'Geschlecht': ['Männer', 'Frauen'],\n",
2024-06-07 20:52:07 +02:00
" 'Untere Grenze': [conf_int_men[0], conf_int_women[0]],\n",
" 'Obere Grenze': [conf_int_men[1], conf_int_women[1]]\n",
2024-06-07 15:16:29 +02:00
"})\n",
"\n",
"print(result_table_men_vs_women)"
]
},
2024-06-07 20:52:07 +02:00
{
"cell_type": "markdown",
"id": "249c97a2-b9dd-4041-ad40-ee3175a394ad",
"metadata": {},
"source": [
"Das 95%-Konfidenzintervall bedeutet, dass der wahre Mittelwert des Cholesterinspiegels mit 95%iger Wahrscheinlichkeit in den angegebenen Intervallen liegt. \n",
"Da sich die Intervalle für Männer und Frauen nicht überlappen, deutet dies auf einen signifikanten Unterschied im durchschnittlichen Cholesterinspiegel zwischen Männern und Frauen hin."
]
},
2024-06-07 15:16:29 +02:00
{
"cell_type": "markdown",
"id": "4d6ef765-3785-4263-a72f-6e3ab5822d61",
"metadata": {},
"source": [
2024-06-07 20:52:07 +02:00
"#### Cholesterin im Vergleich zur Erkrankung"
2024-06-07 15:16:29 +02:00
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 19,
2024-06-07 15:16:29 +02:00
"id": "fb8d7c02-936a-49c1-adfe-43943f7111d0",
"metadata": {},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1IAAAIhCAYAAABE54vcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABIWklEQVR4nO3daXRUVd7+/euQeQYCJEAG0ACKhBlpIs1gGAQBRWzQ0AKCNoIgkamlUYFuBkEN0OKtfxEFhYjeIjaizFOLEQmDii3aioxCiEwZMAmQnOcFN/VYJoFsSKgK+X7WqrWofXad+p0iGq7aw7Fs27YFAAAAACixSq4uAAAAAADKG4IUAAAAABgiSAEAAACAIYIUAAAAABgiSAEAAACAIYIUAAAAABgiSAEAAACAIYIUAAAAABgiSAEAAACAIYIUALi5r7/+Wg8//LDq1q0rX19fBQYGqnnz5po1a5ZOnTrl6FenTh316NGj1N73wIEDsixLCxcuLLVz/lZKSoomT56sM2fOlMn5S6pOnToaNGhQifv/85//VGhoqC5cuGD0PkV9npMnT5ZlWUbnKS8GDRqkOnXquLoMACgzBCkAcGPz589XixYtlJqaqnHjxmn16tVavny5/vSnP+nVV1/VkCFDXF3iVUtJSdGUKVNcHqRMLVu2TPfcc488PT2v+VyPPPKIPv/881Koyv0888wzWr58uavLAIAyc+2/BQAAZeLzzz/XsGHD1LlzZ3344Yfy8fFxHOvcubPGjBmj1atXu7BC9/Trr7/K39+/TM59/Phxbd26VePHjy+V80VERCgiIqJUzuVubr75ZleXAABlihEpAHBT06dPl2VZeu2115xC1CXe3t7q1atXofbVq1erefPm8vPz0y233KI33nijUJ9vvvlG99xzj6pUqSJfX181bdpUixYtKlFdP/zwgxISElSjRg35+Pjo1ltv1csvv+zUp6CgQFOnTlWDBg3k5+enypUrq3Hjxpo7d66ki1Paxo0bJ0mqW7euLMuSZVnavHmz4xzvvvuu2rRpo4CAAAUGBqpr167avXu30/sMGjRIgYGB2rNnj7p06aKgoCDFx8dLkk6dOqXhw4erdu3a8vb21k033aSJEycqLy+vRNdZlOXLlyswMFCdOnW6bL+jR4+qb9++CgoKUkhIiPr166e0tLRC/Yqa2vfuu++qS5cuqlmzpvz8/HTrrbfqqaee0tmzZwu9fv78+apfv758fHzUsGFDJScnF5pSd2lK4QsvvKCkpCTVrVtXgYGBatOmjbZt21bonCtWrFCbNm3k7++voKAgde7cudCo2S+//KK//OUvioyMlI+Pj6pXr6477rhD69evd/Qpamrf//7v/6p169YKCQmRv7+/brrpJg0ePPiynyUAuCtGpADADeXn52vjxo1q0aKFIiMjS/y6r776SmPGjNFTTz2lsLAwvf766xoyZIhiYmLUrl07SdL333+vuLg41ahRw7HeZ/HixRo0aJCOHz9+2dGWb7/9VnFxcYqKitKLL76o8PBwrVmzRk888YROnDihSZMmSZJmzZqlyZMn6+mnn1a7du10/vx5fffdd45pfI888ohOnTqll156SR988IFq1qwpSWrYsKGkiyHy6aef1sMPP6ynn35a586d0/PPP68//vGP2r59u6OfJJ07d069evXS0KFD9dRTT+nChQvKzc1Vx44dtW/fPk2ZMkWNGzfWp59+qhkzZujLL7/Uxx9/bPT3ccmyZcvUo0ePIoPtJTk5OerUqZOOHj2qGTNmqH79+vr444/Vr1+/Er3HDz/8oO7duysxMVEBAQH67rvvNHPmTG3fvl0bN2509Hvttdc0dOhQ9enTR7Nnz1ZGRoamTJlSbFB8+eWXdcstt2jOnDmSLk696969u/bv36+QkBBJUnJysvr3768uXbronXfeUV5enmbNmqUOHTpow4YNatu2rSTpoYce0q5duzRt2jTVr19fZ86c0a5du3Ty5Mlir+vzzz9Xv3791K9fP02ePFm+vr46ePCg0zUBQLliAwDcTlpami3JfuCBB0r8mujoaNvX19c+ePCgoy0nJ8euWrWqPXToUEfbAw88YPv4+NiHDh1yen23bt1sf39/+8yZM7Zt2/b+/fttSfabb77p6NO1a1c7IiLCzsjIcHrtiBEjbF9fX/vUqVO2bdt2jx497KZNm1623ueff96WZO/fv9+p/dChQ7anp6c9cuRIp/asrCw7PDzc7tu3r6Nt4MCBtiT7jTfecOr76quv2pLs9957z6l95syZtiR77dq1jrbo6Gh74MCBl63Vtm37xIkTtqenp71s2bLL9nvllVdsSfa//vUvp/ZHH3200Oc5adIk+3K/igsKCuzz58/bW7ZssSXZX331lW3btp2fn2+Hh4fbrVu3dup/8OBB28vLy46Ojna0Xfp7jI2NtS9cuOBo3759uy3JfueddxznrFWrlh0bG2vn5+c7+mVlZdk1atSw4+LiHG2BgYF2YmLiZT+HgQMHOtXxwgsv2JIcP18AUN4xtQ8AbiBNmzZVVFSU47mvr6/q16+vgwcPOto2btyo+Pj4QiNdgwYN0q+//lrs5ge5ubnasGGDevfuLX9/f124cMHx6N69u3Jzcx1TxW6//XZ99dVXGj58uNasWaPMzMwSX8OaNWt04cIFDRgwwOk9fH191b59e6fpf5f06dPH6fnGjRsVEBCg+++/v9A1StKGDRtKXM8l//rXv+Tt7a277rrrsv02bdqkoKCgQtMuExISSvQ+P/30kxISEhQeHi4PDw95eXmpffv2kqS9e/dKujiqmJaWpr59+zq9NioqSnfccUeR57377rvl4eHheN64cWNJcvxsfP/99zp69KgeeughVar0///zIDAwUH369NG2bdv066+/Srr497tw4UJNnTpV27Zt0/nz5694Xa1atZIk9e3bV++9955+/vnnEn0eAOCuCFIA4IaqVasmf39/7d+/3+h1oaGhhdp8fHyUk5PjeH7y5EnHVLrfqlWrluN4UU6ePKkLFy7opZdekpeXl9Oje/fukqQTJ05IkiZMmKAXXnhB27ZtU7du3RQaGqr4+Hjt2LHjitdw/PhxSRf/4f3793n33Xcd73GJv7+/goODC9UaHh5eaP1RjRo15OnpedkpaMV5//331a1btytuZHHy5EmFhYUVag8PD7/ie2RnZ+uPf/yjvvjiC02dOlWbN29WamqqPvjgA0ly/D1eqr+o9ymqTSr8s3FpeuLvz1ncz0ZBQYFOnz4t6eI6roEDB+r1119XmzZtVLVqVQ0YMKDIdWCXtGvXTh9++KEjJEdERKhRo0Z65513iv9AAMCNsUYKANyQh4eH4uPjtWrVKh05cqRUd3YLDQ3VsWPHCrUfPXpU0sUQV5QqVarIw8NDDz30kB5//PEi+9StW1eS5OnpqdGjR2v06NE6c+aM1q9fr7/97W/q2rWrDh8+fNkwcun933//fUVHR1/xeoq6D1NoaKi++OIL2bbtdDw9PV0XLlwo9hqLk5GRoQ0bNpTonlqhoaHavn17ofbLhYxLNm7cqKNHj2rz5s2OUShJhbaIvxSKLoVO0/cpyqVzFvezUalSJVWpUkXSxb+jOXPmaM6cOTp06JBWrFihp556Sunp6ZfdSfKee+7RPffco7y8PG3btk0zZsxQQkKC6tSpozZt2lxV3QDgKoxIAYCbmjBhgmzb1qOPPqpz584VOn7+/Hl99NFHxueNj493/IP9t9566y35+/vrD3/4Q5Gv8/f3V8eOHbV79241btxYLVu2LPQoakSscuXKuv/++/X444/r1KlTOnDggKTCIyKXdO3aVZ6entq3b1+R79GyZcsSXWN2drY+/PDDQtd46biJjz76SJZlleiGxx07dlRWVpZWrFjh1J6cnHzF114Kfb/fzOL//b//5/S8QYMGCg8P13vvvefUfujQIaWkpFzxfYrSoEED1a5dW8nJybJt29F+9uxZLVu2zLGT3+9FRUVpxIgR6ty5s3bt2lWi9/Lx8VH79u01c+ZMSSq0GyMAlAeMSAGAm2rTpo1eeeUVDR8+XC1atNC
2024-06-07 15:16:29 +02:00
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10, 6))\n",
"sns.boxplot(x='goal', y='chol', data=df)\n",
2024-06-07 20:52:07 +02:00
"plt.title('Cholesterol / diagnosis')\n",
"plt.xlabel('diagnosis')\n",
"plt.ylabel('Cholesterol in mg/dl')\n",
"plt.xticks([0, 1], ['healthy', 'sick'])\n",
2024-06-07 15:16:29 +02:00
"plt.show()"
]
},
2024-06-07 20:52:07 +02:00
{
"cell_type": "markdown",
"id": "96cd0dbf-5a76-47a5-8103-81dc3f5cf266",
"metadata": {},
"source": [
"Im folgenden wird ein t-Test durchgeführt, um zu analysieren, ob der Cholesterinwert bei erkrankten Personen höher ist als bei gesunden. \n",
"Hierfür wurden folgende Hypothesen aufgestellt: \n",
"- Nullhypothese (HO): Cholesterinwert bei erkrankten Personen ist gleich wie oder kleiner als bei gesunden.\n",
"- Alternativhypothese (H1): Cholesterinwert bei erkrankten Personen ist höher als bei gesunden."
]
},
2024-06-07 15:16:29 +02:00
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 21,
2024-06-07 15:16:29 +02:00
"id": "f5d1a57a-8d24-4a23-a035-3e6d7fd7eb89",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-06-07 20:52:07 +02:00
"t-Statistik: 1.3834015443480652\n",
"p-Wert: 0.08379388357371184\n"
2024-06-07 15:16:29 +02:00
]
}
],
"source": [
2024-06-07 20:52:07 +02:00
"# t-test\n",
2024-06-07 15:16:29 +02:00
"from scipy.stats import ttest_ind\n",
"\n",
"chol_healthy = df.loc[df['goal'] == 0, 'chol']\n",
"chol_sick = df.loc[df['goal'] == 1, 'chol']\n",
"\n",
"t_statistic, p_value = ttest_ind(chol_sick, chol_healthy, alternative='greater')\n",
"\n",
"print(\"t-Statistik:\", t_statistic)\n",
2024-06-07 20:52:07 +02:00
"print(\"p-Wert:\", p_value)"
]
},
{
"cell_type": "markdown",
"id": "9f6927e8-dec2-4b8e-a8fb-4d1e348306bd",
"metadata": {},
"source": [
"Die t-Statistik sagt aus, dass der Mittelwert des Cholesterinspiegels in der erkrankten Gruppe um ca. 1,38 Standardabweichungen höher ist, als der Mittelwert in der gesunden Gruppe. Der Wert ist allerdings kein Maß dafür, ob der Unterschied statistisch signifikant ist. Hierfür muss der p-Wert betrachtet werden, der aussagt, ob der beobachtete Unterschied zwischen den Gruppen auf rein zufällige Variationen zurückgeführt werden könnte. \n",
"Der p-Wert ist größer als 0.05, daher wird die Nullhypothese nicht abgelehnt. \n",
"Es gibt keine signifikanten Hinweise darauf, dass der Cholesterinwert bei kranken Personen höher ist als bei gesunden."
2024-06-07 15:16:29 +02:00
]
},
{
"cell_type": "markdown",
"id": "362223d0-efaf-426c-8bb7-81108c065ccf",
"metadata": {},
"source": [
2024-06-07 20:52:07 +02:00
"#### Systolischer Ruheblutdruck"
2024-06-07 15:16:29 +02:00
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 53,
2024-06-07 15:16:29 +02:00
"id": "1574b038-0941-4473-a968-adca7f5ec26e",
"metadata": {},
"outputs": [
{
"data": {
2024-06-07 20:52:07 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAArcAAAIhCAYAAABUopIpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABk6UlEQVR4nO3deXxMd////+fIHiKSIBEStJZSsRRVoZZaY1+u4hO1V1drqFK1tVqlailtXd2oqtLaWlr72jTVIhQXrZYQakltiS0Ryfn94Wt+nSaYk8wY4nG/3XK7Zd7nPWeek6Su1/We13kfi2EYhgAAAIA8IJ+rAwAAAACOQnELAACAPIPiFgAAAHkGxS0AAADyDIpbAAAA5BkUtwAAAMgzKG4BAACQZ1DcAgAAIM+guAUAAECeQXELwC5z5syRxWKx+SpSpIgaNGigFStWZJlvsVg0duzYO57z8OHDslgsmjNnzh1/7fvJu+++q6CgIF27ds3U87L7/YwdO1YWi8XBCe8OP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V199VfXq1VN6erp+++03nT9/3tT7+adly5bphx9+0OjRoxUSEqKiRYtq3759ioyMVHh4uN555x2FhIRo9erVGjBggE6fPq0xY8bc9ryLFy9Wq1at5OXlddM5uf39/PHHH2rRooUGDRqk/Pnz67ffftPEiRP1yy+/2PzcPvzwQz377LPq2LGjpk6dquTkZI0bN05paWnZnve9997TQw89pGnTpkm63jbQokULJSQkyN/fX5I0f/58de3aVU2bNtWXX36ptLQ0TZo0SQ0aNND69etVt25dSVK3bt0UHx+vN954Q+XKldP58+cVHx+vM2fO3PR92fO3ACCXDACww+zZsw1JWb68vLyM999/P8t8ScaYMWOsj7t06WJ4eXkZiYmJNvOioqIMX19f4/z584ZhGMbw4cMNScbPP/9sM+/55583LBaL8fvvvxuGYRgffPCBIcn45ptvbOb17dvXkGTMnj3brvfTvn17m/Eff/zRkGSMHz/eOla/fn1DkrF+/XqbuRMmTDDy5ctnbNu2zWZ80aJFhiTj+++/NwzDMCZPnmxIsr7H7LRq1cqoWrXqLTP36NHDKFmyZJbxMWPGGP/+51yS4e/vb5w9e9ZmvFmzZkaJEiWM5ORkm/F+/foZ3t7eWeb/2+nTpw13d3dj8eLFt5xn5veTXf5/yszMNNLT043Nmzcbkoxff/3VMAzDyMjIMEJCQoxatWrZzD9y5Ijh4eFh87NKSEgwJBkRERHGtWvXrOO//PKLIcn48ssvrecMDQ01IiIijIyMDOu8CxcuGEWLFjUiIyOtYwUKFDAGDRp0y5/Dv39n9vwtAMgd2hIAmDJ37lxt27ZN27Zt08qVK9WjRw+9+OKLmjlz5i2ft2HDBjVq1EhhYWE24z179tTly5etH/lu2LBBFStW1KOPPpplnmEY1hWujRs3ys/PT23atLGZd7sV5H/r2rWrzePIyEiVLFlSGzdutBkPCAjQE088YTO2YsUKVapUSVWrVtW1a9esX82aNZPFYtGmTZskSTVr1pQkderUSV999ZX++uuvLDkeffRR/frrr3rhhRe0evVqpaSkmHof2XniiScUEBBgfZyamqr169erffv28vX1tcncokULpaamZvsR/T9988038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WJJUqlQpJSUl2RRzV69e1erVq+16r76+vmrYsKF27typypUrZ5v53yub/7R8+XJZLBa1atXqtq+Vm9/PjaL83xes/fe//7V5XL58eYWEhOirr76yGU9MTFRcXNxtXyc75cuXV/HixTV//nwZhmEdv3TpkhYvXmzdQeHfwsPD1a9fPzV
2024-06-07 15:16:29 +02:00
"text/plain": [
"<Figure size 800x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(8, 6))\n",
2024-06-07 20:52:07 +02:00
"sns.boxplot(x='goal', y='trestbps', data=df)\n",
"plt.title('Blood pressure / diagnosis')\n",
"plt.xlabel('Diagnosis')\n",
"plt.ylabel('Systolic resting blood pressure (in mmHg on admission to hospital)')\n",
"plt.xticks([0, 1], ['healthy', 'sick'])\n",
2024-06-07 15:16:29 +02:00
"plt.show()"
]
},
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 57,
2024-06-07 15:16:29 +02:00
"id": "0a359020-86f6-4d8c-9144-d2977674e51d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-06-07 20:52:07 +02:00
" Diagnose Untere Grenze Obere Grenze\n",
"0 Gesund 126.618412 131.731588\n",
"1 Krank 131.442350 137.827723\n"
2024-06-07 15:16:29 +02:00
]
}
],
"source": [
2024-06-07 20:52:07 +02:00
"# confidence interval (95%) for blood pressure and diagnosis\n",
"\n",
"# filter by diagnosis and calculate interval\n",
2024-06-07 15:16:29 +02:00
"conf_level = 0.95\n",
"blutdruck_gesund = df.loc[df['goal'] == 0, 'trestbps']\n",
"blutdruck_krank = df.loc[df['goal'] == 1, 'trestbps']\n",
"conf_int_gesund = stats.t.interval(conf_level, len(blutdruck_gesund) - 1, loc=blutdruck_gesund.mean(), scale=stats.sem(blutdruck_gesund))\n",
"conf_int_krank = stats.t.interval(conf_level, len(blutdruck_krank) - 1, loc=blutdruck_krank.mean(), scale=stats.sem(blutdruck_krank))\n",
"\n",
"result_table_blutdruck = pd.DataFrame({\n",
" 'Diagnose': ['Gesund', 'Krank'],\n",
2024-06-07 20:52:07 +02:00
" 'Untere Grenze': [conf_int_gesund[0], conf_int_krank[0]],\n",
" 'Obere Grenze': [conf_int_gesund[1], conf_int_krank[1]]\n",
2024-06-07 15:16:29 +02:00
"})\n",
"\n",
"print(result_table_blutdruck)"
]
},
2024-06-07 20:52:07 +02:00
{
"cell_type": "markdown",
"id": "751dc52f-4675-4046-91c1-a00541ec172b",
"metadata": {},
"source": [
"Die Intervalle überlappen sich nur minimal, deshalb kann hier keine klare Aussage getroffen werden, ob es einen statistisch signifikanten Unterschied zwischen den beiden Gruppen gibt. Um eine klarere Aussage treffen zu können, wird zusätzlich ein t-Test durchgeführt. \n",
"Im Folgenden wird ein t-Test durchgeführt, um zu analysieren, ob der Cholesterinwert bei erkrankten Personen höher ist als bei gesunden.\n",
"Hierfür wurden folgende Hypothesen aufgestellt:\n",
"\n",
"Nullhypothese (HO): Der Blutdruck von erkrankten Personen ist niedriger oder gleich wie der von gesunden. \n",
"Alternativhypothese (H1): Der Blutdruck von erkrankten Personen ist höher als der von gesunden."
]
},
2024-06-07 15:16:29 +02:00
{
"cell_type": "code",
2024-06-07 20:52:07 +02:00
"execution_count": 64,
2024-06-07 15:16:29 +02:00
"id": "003e4148-8318-41f4-8e38-af74c5ad54fa",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-06-07 20:52:07 +02:00
"t-Statistik: 2.6678917570482685\n",
"p-Wert: 0.00402739817943764\n"
2024-06-07 15:16:29 +02:00
]
}
],
"source": [
"# t-Test\n",
"blutdruck_healthy = df.loc[df['goal'] == 0, 'trestbps']\n",
"blutdruck_sick = df.loc[df['goal'] == 1, 'trestbps']\n",
"\n",
"# Durchführung des t-Tests\n",
"t_statistic, p_value = ttest_ind(blutdruck_sick, blutdruck_healthy, alternative='greater')\n",
"\n",
"print(\"t-Statistik:\", t_statistic)\n",
2024-06-07 20:52:07 +02:00
"print(\"p-Wert:\", p_value)"
2024-06-07 15:16:29 +02:00
]
2024-06-07 20:52:07 +02:00
},
{
"cell_type": "markdown",
"id": "e281ae05-5f6f-40e0-9499-362d9cba5eea",
"metadata": {},
"source": [
"Die t-Statistik besagt, dass der Mittelwert der erkrankten Personen um ca. 2,67 Standardabweichung von dem der gesunden Personen abweicht. \n",
"Der p-Wert ist kleiner als 0.05, daher wird die Nullhypothese abgelehnt.\n",
"Es gibt signifikante Hinweise darauf, dass der Blutdruck bei kranken Personen höher ist als bei gesunden Personen."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ddfac31a-9a03-4b4a-900b-7afa98d4f3cb",
"metadata": {},
"outputs": [],
"source": []
2024-05-08 08:48:17 +02:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2024-06-07 20:52:07 +02:00
"version": "3.11.9"
2024-05-08 08:48:17 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}