AIM-PIbd-31-Razubaev-S-M/Lab1/lab1.ipynb

344 lines
166 KiB
Plaintext
Raw Normal View History

2024-09-27 22:48:08 +04:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Лабораторная 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Выгрузка данных из csv файла в датафрейм"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['Pregnancies', 'Glucose', 'BloodPressure', 'SkinThickness', 'Insulin',\n",
" 'BMI', 'DiabetesPedigreeFunction', 'Age', 'Outcome'],\n",
" dtype='object')\n"
]
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"df = pd.read_csv(\".//static//scv//diabetes.csv\")\n",
"print(df.columns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Посмотрим краткое содержание датасета. Видим, что датасет состоит из 768 строк и 9 столбцов"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 768 entries, 0 to 767\n",
"Data columns (total 9 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 Pregnancies 768 non-null int64 \n",
" 1 Glucose 768 non-null int64 \n",
" 2 BloodPressure 768 non-null int64 \n",
" 3 SkinThickness 768 non-null int64 \n",
" 4 Insulin 768 non-null int64 \n",
" 5 BMI 768 non-null float64\n",
" 6 DiabetesPedigreeFunction 768 non-null float64\n",
" 7 Age 768 non-null int64 \n",
" 8 Outcome 768 non-null int64 \n",
"dtypes: float64(2), int64(7)\n",
"memory usage: 54.1 KB\n"
]
},
{
"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>Pregnancies</th>\n",
" <th>Glucose</th>\n",
" <th>BloodPressure</th>\n",
" <th>SkinThickness</th>\n",
" <th>Insulin</th>\n",
" <th>BMI</th>\n",
" <th>DiabetesPedigreeFunction</th>\n",
" <th>Age</th>\n",
" <th>Outcome</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>6</td>\n",
" <td>148</td>\n",
" <td>72</td>\n",
" <td>35</td>\n",
" <td>0</td>\n",
" <td>33.6</td>\n",
" <td>0.627</td>\n",
" <td>50</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>85</td>\n",
" <td>66</td>\n",
" <td>29</td>\n",
" <td>0</td>\n",
" <td>26.6</td>\n",
" <td>0.351</td>\n",
" <td>31</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>8</td>\n",
" <td>183</td>\n",
" <td>64</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>23.3</td>\n",
" <td>0.672</td>\n",
" <td>32</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1</td>\n",
" <td>89</td>\n",
" <td>66</td>\n",
" <td>23</td>\n",
" <td>94</td>\n",
" <td>28.1</td>\n",
" <td>0.167</td>\n",
" <td>21</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>137</td>\n",
" <td>40</td>\n",
" <td>35</td>\n",
" <td>168</td>\n",
" <td>43.1</td>\n",
" <td>2.288</td>\n",
" <td>33</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Pregnancies Glucose BloodPressure SkinThickness Insulin BMI \\\n",
"0 6 148 72 35 0 33.6 \n",
"1 1 85 66 29 0 26.6 \n",
"2 8 183 64 0 0 23.3 \n",
"3 1 89 66 23 94 28.1 \n",
"4 0 137 40 35 168 43.1 \n",
"\n",
" DiabetesPedigreeFunction Age Outcome \n",
"0 0.627 50 1 \n",
"1 0.351 31 0 \n",
"2 0.672 32 1 \n",
"3 0.167 21 0 \n",
"4 2.288 33 1 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.info()\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Группируем данные по возрасту и вычисляем среднее значение глюкозы для каждой возрастной группы"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABH8AAAK9CAYAAAC928AHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABgWUlEQVR4nO3dd5RU9f0//tfQlo7SQZqKgr2gMaCxEkBRLHyjJvaGGrAmKsSusSaxd1TUWBK7JkT8WNEoFuwmiKioRAFBBQSkCO/fHx7mxwJbZnZX4PJ4nDPn7N6589rXlBez++R97+RSSikAAAAAyKRaK7sBAAAAAGqO8AcAAAAgw4Q/AAAAABkm/AEAAADIMOEPAAAAQIYJfwAAAAAyTPgDAAAAkGHCHwAAAIAME/4AAAAAZJjwBwAAACDDhD8AUA0uueSSyOVy8a9//Wu566ZOnRr16tWLvffeeyV0BgDAmk74AwDV4Igjjog6derErbfeutx1t99+eyxcuDAGDRq0EjoDAGBNl0sppZXdBABkwb777hv//Oc/Y9KkSdG2bduIiEgpRdeuXWPhwoXx6aefRq1a/t8FAICflt9AAaCaHHPMMfHDDz/EHXfckd/29NNPxyeffBJHHnlkPvi54447IpfLxQsvvBDHHntstGjRIpo2bRqHHnpofPvtt8vVveGGG2KTTTaJkpKSaN++fQwePDhmzJhRap+dd945crlc/tKyZcvo379/vP/++8vVu/vuu6NHjx7RoEGDaN68eRx44IExadKk5eptuummy932z3/+c+Ryufj000/z27p06RJ77rlnAY/U/69Lly6l+l5yOfroo0vtd955561wv8MPPzy/z5LHdenennzyyejVq1c0bNgwmjVrFnvuuedyj8mS2kt77rnnoqSkJI477rhS2996663Yfffdo2nTptG4cePYbbfd4pVXXim1z8MPPxw/+9nPonnz5tGgQYPo3r17XHbZZbH0/7ct+ZnTp08v97FZ+v6VZfHixXH11VfHZpttFvXr149WrVpFv379YuzYseXerrKvmR9++CEuvPDCWH/99aOkpCS6dOkSf/jDH2L+/Pml9tt7772jS5cuUb9+/WjdunUMGDAg3nvvvVL75HK5GDJkSNxzzz3RrVu3qF+/fvTo0SNeeOGFUvt99tln8dvf/ja6desWDRo0iBYtWsSvfvWrUs/tEjNmzIhTTjklunTpEiUlJdGhQ4c49NBDY/r06fH888+v8HWz9OW8887L16rM87vkdVavXr2YNm1aqevGjBmTr1vR4w8AP6U6K7sBAMiKfv36RceOHeO2226LM844I3K5XAwfPjxq1aoVRx111HL7DxkyJNZaa60477zzYvz48XHjjTfGZ599lv+DNeLHkOD888+P3r17x/HHH5/f7/XXX4+XXnop6tatm6/XvXv3OPPMMyOlFB9//HFcccUVsccee8Tnn3+e3+eiiy6Ks88+O/bff/84+uijY9q0aXHttdfGjjvuGG+99VastdZaNf44LWvLLbeM3/3ud6W2de3adYX7/vWvf81/fcopp5Rb98UXX4w99tgjOnfuHOeee24sXLgwbrjhhth+++3j9ddfjw033HCFt3vnnXdin332iT322COuv/76/Pb//Oc/8Ytf/CKaNm0ap59+etStWzduvvnm2HnnnWP06NGx3XbbRUTErFmzYrvttovDDjss6tatG6NGjYqhQ4dGnTp1lruf1eGoo46KO+64I3bfffc4+uij44cffogXX3wxXnnlldhmm23KvW1lXjNHH3103HnnnfH//t//i9/97nfx6quvxiWXXBLjxo2LRx55pFS9QYMGRdu2bePLL7+M6667Lnr37h0TJ06Mhg0b5vcZPXp0/P3vf48TTzwxSkpK4oYbboh+/frFa6+9lg8cX3/99Xj55ZfjwAMPjA4dOsSnn34aN954Y+y8887x3//+N19v9uzZ8Ytf/CLGjRsXRx55ZGy99dYxffr0ePzxx+N///tfbLTRRqVeM7fcckuMGzcurrzyyvy2zTffPCIq//wuUbt27bj77rtLvQ5HjBgR9evXj3nz5lXquQOAn0wCAKrNueeemyIiPfvss+mrr75K9erVS3vssUepfUaMGJEiIvXo0SMtWLAgv/3yyy9PEZEee+yxlFLK375Pnz5p0aJF+f2uu+66FBHp9ttvz2/baaed0k477VTq5/zhD39IEZG++uqrlFJKn376aapdu3a66KKLSu333nvvpTp16pTavtNOO6VNNtlkufv3pz/9KUVEmjhxYn5b586dU//+/Sv5CJVW2dueeeaZKZfLLXfbww47LP/9ksd1SW89evRIzZo1S1OmTMnv8+GHH6a6deumgQMH5rctec5S+vExateuXdphhx3S999/X+rn7bPPPqlevXrp448/zm/78ssvU5MmTdKOO+5Ybv8bb7xx2nPPPZf7mdOmTSvzNsvevxV59tlnU0SkE088cbnrFi9eXO5tK/Oaefvtt1NEpKOPPrrUfr///e/zr/Oy3H///Ski0tixY/PbImK5bZ999lmqX79+2nffffPb5s6du1y9MWPGpIhId911V37bOeeckyIiPfzww8vtv6L7f9hhh6XOnTuvsN/KPr9LXme//vWv02abbZbfPmfOnNS0adP0m9/8JkVEev3111f4cwBgZXDYFwBUo6OOOipq1aoVw4cPjxEjRsSCBQvKPNHzoEGDSq3cOf7446NOnTr5Twx7+umnY8GCBXHyySeXOlfQMcccE02bNo2RI0eWqrdw4cKYPn16TJs2LcaMGROPPPJIbL755tGyZcuI+PFwpMWLF8f+++8f06dPz1/atm0bG2ywQTz33HOl6i1atKjUftOnT4+5c+eu8L4s+dlff/11/PDDD4U/cBVYsGBBlJSUVGrfb7/9Nj788MN444034qCDDoo2bdrkr9tggw1iwIABMWrUqFi0aFGp23399dfRt2/faNKkSTz++ONRv379/HWLFi2K//u//4t99tkn1ltvvfz2du3axW9+85v497//HbNmzSpVb/r06fG///0v7rjjjvjoo49ixx13XK7Xb775JqZPnx5z5syp1H1b1kMPPRS5XC7OPffc5a5b9lC2FanoNbPktXjqqaeWut2SFUzLvgbnzp0b06dPj7fffjuGDx8ebdq0WW6FVc+ePaNHjx757zt16hR77713PPnkk/nnpEGDBqV6/Prrr6Nr166x1lprxZtvvlnq/m+xxRax7777FnX/lyjm+T3kkEPigw8+yB/e9dBDD0WzZs1it912q/TPBYCfisO+AKAadezYMfr16xcPP/xwvPzyy9G+ffvo37//CvfdYIMNSn3fuHHjaNeuXf68Jp999llERHTr1q3UfvXq1Yv11lsvf/0SL7/8crRq1apU/UcffTT/R/CECRMipbTcz11i6SAqIuKDDz4oVa88//d//5fft3bt2rH55pvHpZdeGn369KnU7SsyY8aMaNy4caX23XrrrfNfL/vYRURstNFG8dBDD8X06dNLBUN77rlnjB8/Plq3bl3q/DwREdOmTYu5c+eWWW/x4sUxadKk2GSTTSIiYt68efnHI5fLxR/+8Ic47bTTlrvt0vVat24dxxxzTJx//vlRu3btSt3Xjz/+ONq3bx/Nmzev1P7Lqug189lnn0WtWrWWOwyvbdu2sdZaay33Grzgggvisssuy9d6/vnno0mTJqX2WdHrb8MNN4y5c+fGtGnTom3btvH999/HJZdcEiNGjIgvvvii1PMxc+bMUvd/4MCBRd33pRX6/EZEtGrVKvr37x+33357bLPNNnH77bfHYYcd5qTuAKyShD8AUM2OOeaY+Ne//hWfffZZnHnmmVGnzk/zdrv55pvHX/7yl4j48Y/Za665Jnbeeed48803o23btrF48eLI5XLxxBNPrDBcWDZc6dKlSwwfPrzUtgceeCBuueWW5W673XbbxR//+MeIiPjyyy/jsssui3333Tf+85//RJcuXap836ZMmZL/BLWK3H333TF37twyV1yV5YMPPognnngi9t9///jd734XI0aMKKb
"text/plain": [
"<Figure size 1400x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"glucose_by_age = df.groupby(['Age'])['BloodPressure'].mean()\n",
"\n",
"glucose_by_age.plot(kind='bar', figsize=(14, 8), width=0.6)\n",
"plt.title('Уровень глюкозы с возрастом')\n",
"plt.xlabel('Возраст')\n",
"plt.ylabel('Уровень глюкозы')\n",
"plt.xticks(rotation=0)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Данная диаграмма отображает среднее количество глюкозы для каждой возрастной группы, что позволяет сделать вывод о том, как уровень глюкозы изменяется с возрастом."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1IAAAIjCAYAAAAJLyrXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADnIUlEQVR4nOy9d3wc1bn//5myvahYVrVsuduxAQcIXGxqIAZCQkkjhNBCyU3ge38QEgIJhJIQX0ogIbSQQg1cCAkkIRRTTCDgUGJM4l7lIluSVXe1bXZmzu+P1Yx2dlfSnpVG2pWe9+vll6zdo7PPPOfM7J6dc95HYIwxEARBEARBEARBEHkjjncABEEQBEEQBEEQpQYNpAiCIAiCIAiCIDihgRRBEARBEARBEAQnNJAiCIIgCIIgCILghAZSBEEQBEEQBEEQnNBAiiAIgiAIgiAIghMaSBEEQRAEQRAEQXBCAymCIAiCIAiCIAhOaCBFEARBEARBEATBCQ2kCIIgCIIgCIIgOKGBFEEQebFixQoIgoAXX3wx67m2tjY4nU6cccYZ4xAZQRAEQRDE2EMDKYIg8uKiiy6CLMv4zW9+k/Xc7373OySTSVx22WXjEBlBEARBEMTYIzDG2HgHQRBEaXDWWWfhhRdewJ49e1BbWwsAYIxhzpw5SCaTaG5uhijS9zMEQRAEQUx86BMPQRB5c+mll0JVVTz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HBBRfg5JNPxm233YZoNIoHHngARx99ND766CPLB7WR8P3vfz/n49/73vfw4IMP4uKLL8ayZcvgcDjwpz/9Cc8999ywdT7yyCO46KKL8KlPfQorVqxAW1sbfvGLX+Cdd94x2/yb3/wmTjrpJPNvzjvvPJx11ln4whe+YD42depU7uO55JJL8Oijj+JLX/oSrr76arz33ntYsWIFNm7caIn9kUcewTe+8Q0sWrQI1113HcrLy/HRRx/h5Zdfxte+9rVB68+Vr8cff9z8/9tvv42HHnoId999N6qqqgAANTU1AABd13H66afjH//4By677DIsXLgQ//nPf3D33Xdjy5YteP7553O+Znpdt956K3dOeMmn/YbDiDkUCuF3v/sdLr30UjQ1NZlt/tprr+HUU0/FrFmzcNNNNyEWi+GXv/wlli1bhjVr1pj9OxwOY/ny5Zg9ezYYY3jmmWdwySWXoLy8HF/84hfN19M0Daeccgr+67/+C7fffjtefvll3HjjjVBVFbfccotZ7he/+AVOP/10nHvuuVAUBf/3f/+HL3/5y3jhhRdw2mmnmeVuvvlm3HTTTVi6dCluueUWOJ1OvPfee3jjjTewfPly/PznP0dfXx+AgfPXOP8BWAat+b4mQRCjACMIguDgxhtvZADYG2+8wdrb25nT6WSf/exnLWUefvhhBoAddthhTFEU8/Hbb7+dAWB//vOfGWPM/Pvly5czTdPMcvfeey8DwH73u9+Zjx133HHsuOOOs7zOD37wAwaAtbe3M8YYa25uZpIksVtvvdVS7j//+Q+TZdny+HHHHccWLVqUdXx33HEHA8B27txpPjZjxgx22mmn5ZmhbLZs2cIAsDvvvHPI14nH45Y8MMbYzp07mcvlYrfccov52KpVqxgAtmrVKsvfiqLIvv3tb2e9fkNDA7vooosG/ftwOMzKy8vZpZdeavm71tZWVlZWZnn8ggsuYD6fL+s1/vCHP2TFlNlmL774IgPATjnlFJb59lNXV8dOPvlky2NGXztw4EDW6xkoisKqq6vZ4sWLWSwWMx9/4YUXGAD2ox/9KOffAWA33nhjzucGa+/LL7/cEvfatWsZAHbJJZdYyn33u981zxHGGOvp6WGBQ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f
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(df['Age'], df['BloodPressure'], alpha=0.5)\n",
"plt.title('Уровень давления относительно возраста')\n",
"plt.xlabel('Возраст')\n",
"plt.ylabel('Уровень давления')\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Данная диаграмма отображает уровень давления относительно возраста, что позволяет сделать вывод о том, как уровень давления изменяется с возрастом."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Figure size 1000x600 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAj0AAAHHCAYAAABUcOnjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACK50lEQVR4nO3dd3xT1fvA8U+apuluaaEDKKMUKVMQECqiyJYlyNfxFQSUrxNUxAX+RIYLNzgRUVABB+JAUAFZDqYgGxllj7ZA906T+/sjzaWhLW3atFnP+/XKq+3Nzb3n5KbJk3Oec45GURQFIYQQQgg35+XoAgghhBBC1AYJeoQQQgjhESToEUIIIYRHkKBHCCGEEB5Bgh4hhBBCeAQJeoQQQgjhESToEUIIIYRHkKBHCCGEEB5Bgh4hhBBCeAQJeoQQQgjhESToKSExMZEHHniA2NhYfH19CQ4Oplu3bsyePZu8vDxHF08IIYQQ1eDt6AI4ixUrVnDbbbeh1+sZNWoUbdq0obCwkD///JOnnnqKffv2MXfuXEcXUwghhBBVpJEFR+HYsWO0a9eOhg0bsnbtWqKjo63uP3LkCCtWrOCxxx5zUAmFEEIIUV3SvQW89tprZGdn88knn5QKeADi4uKsAh6NRsP48eNZtGgRLVq0wNfXl44dO/L777+XeuyZM2e49957iYyMRK/X07p1az799NMyyzFt2jQ0Gk2pW48ePaz269GjB23atCn1+DfeeAONRsPx48ettv/yyy90796dgIAAgoKCGDhwIPv27Sv1+H///Zf//Oc/hIWF4evrS6dOnVi2bFmZZS3p4MGD9OzZk6ioKPR6PTExMTz44IOkpqaq+6xfvx6NRsO3335b6vGBgYGMGTNG/Ts1NZUnn3yStm3bEhgYSHBwMDfffDO7du0q8/m6XJMmTayOB5Cens6ECROIiYlBr9cTFxfHq6++islkUvc5fvw4Go2GN954o9Qx27RpY3UdLPVZv3691X4DBw5Eo9Ewbdo0q+22vA4uV9bxXn/99VKvDVueYzA/J48//jhNmjRBr9fTsGFDRo0axYULF8jOziYgIKDMQP/06dNotVpeeeUVq+09evQo8/W7YMECq30ufz1v27ZN3ffyeo8fP77U+QcNGkSTJk2str3xxhtcd911hIeH4+fnR8eOHct8HspiS5mq+3hb6gSwYMGCMp/TsvatzP+v5Xgl3yP27dtHnTp1GDRoEEVFRer2K70+AAoLC3n++efp2LEjISEhBAQE0L17d9atW1fBM2b+Hy2rXmXVz2QyMWvWLFq3bo2vry+RkZE88MADpKWllTqu5X/gSserTrkrU/aSioqKeOGFF2jWrBl6vZ4mTZrw7LPPUlBQUOF5xowZY3XcOnXq0KNHD/74449S+37wwQe0bt0avV5P/fr1GTduHOnp6Vb7PPjggzRv3hx/f3/CwsLo2bNnqWM1adKEQYMGsWrVKtq3b4+vry+tWrXiu+++s9qvsu/RAPn5+UybNo2rrroKX19foqOjufXWW0lMTFTfc690GzNmDEePHkWj0fD222+XOv7GjRvRaDR8+eWXFT6nIN1bAPz000/ExsZy3XXXVfoxGzZs4Ouvv+bRRx9Fr9fzwQcf0L9/f7Zu3aoGJMnJyXTt2lV9o6tXrx6//PILY8eOJTMzkwkTJpR57A8//JDAwEAAJk+eXK26ffHFF4wePZp+/frx6quvkpuby4cffsj111/PP//8o74Z7Nu3j27dutGgQQMmTZpEQEAA33zzDUOHDmXp0qUMGzas3HPk5OTQsGFDBg8eTHBwMHv37uX999/nzJkz/PTTTzaX+ejRo/zwww/cdtttNG3alOTkZD766CNuvPFG9u/fT/369W06Xm5uLjfeeCNnzpzhgQceoFGjRmzcuJHJkydz7tw5Zs2aZXMZy/L777/z888/l9pe1ddBedLT00sFHLbKzs6me/fuHDhwgHvvvZdrrrmGCxcusGzZMk6fPk379u0ZNmwYX3/9NW+99RZarVZ97JdffomiKIwYMaLUcePj4/m///s/AC5cuMDjjz9eYVmeeeaZatUFYPbs2QwZMoQRI0ZQWFjIV199xW233cby5csZOHCgzcerbpnsUaeSZsyYQdOmTQF48803S33gV/X/99SpU/Tv35/4+Hi++eYbvL3NHwkVvT7q1q1LZmYm8+bN47///S/33XcfWVlZfPLJJ/Tr14+tW7fSvn37cusza9YssrOzAThw4AAvv/wyzz77LC1btgRQ3/8AHnjgARYsWMA999zDo48+yrFjx3jvvff4559/+Ouvv9DpdKWOX/JYc+fO5eTJk+p91Sm3Rfv27XniiSestn3++eesXr3aatv//vc/PvvsM/7zn//wxBNPsGXLFl555RUOHDjA999/X+F56tatq37Qnz59mtmzZzNgwABOnTpFaGgoYP7yN336dHr37s1DDz3EwYMH+fDDD9m2bZvV81NYWMjIkSNp2LAhqampfPTRR/Tv358DBw7QqFEj9ZyHDx/mjjvu4MEHH2T06NHMnz+f2267jV9//ZU+ffoAlX+PNhqNDBo0iDVr1nDnnXfy2GOPkZWVxerVq9m7dy+9e/fmiy++UM/93Xff8f3331tta9asGbGxsXTr1o1FixaVek9ZtGgRQUFB3HLLLRU+nwAoHi4jI0MBlFtuuaXSjwEUQPn777/VbSdOnFB8fX2VYcOGqdvGjh2rREdHKxcuXLB6/J133qmEhIQoubm5VtufffZZBbDav3Xr1sqNN95otd+NN96otG7dulS5Xn/9dQVQjh07piiKomRlZSmhoaHKfffdZ7VfUlKSEhISYrW9V69eStu2bZX8/Hx1m8lkUq677jqlefPmFTwjpT388MNKYGCg+ve6desUQFmyZEmpfQMCApTRo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peuiKAqTJ09m+PDhdOnSpcx98vPzS9XFYDCU2s/Pz0/9PS0tjYyMDLp
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"subset_df = df.iloc[0:30]\n",
"insulin = subset_df.groupby('Age')['Insulin'].mean()\n",
"bmi = subset_df.groupby('Age')['BMI'].mean()\n",
"\n",
"average_df = pd.DataFrame({\n",
" 'Insulin': insulin,\n",
" 'BMI': bmi\n",
"})\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"average_df.plot.line()\n",
"plt.title('Среднее значение инсулина и индекса тела по возрасту')\n",
"plt.xlabel('Возраст')\n",
"plt.ylabel('Среднее значение')\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Данный график отображает среднее значение инсулина и индекса тела по возрасту, что позволяет сделать вывод о том, как эти показатели изменяются с возрастом."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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",
"version": "3.12.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}