1899 lines
1.2 MiB
Plaintext
1899 lines
1.2 MiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"### **1. Car Price Prediction Challenge**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"##### **Проблемная область**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Проблемная область этого набора данных связана с анализом рынка автомобилей. Данные могут быть использованы для анализа ценовых тенденций, определения характеристик автомобилей, влияющих на их стоимость, а также для изучения предпочтений потребителей в отношении моделей, производителей и других характеристик. Объектами наблюдения являются автомобили, представленные в наборе данных.\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 82,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"<bound method DataFrame.info of ID Price Levy Manufacturer Model Prod. year Category \\\n",
|
|||
|
"0 45654403 13328 1399 LEXUS RX 450 2010 Jeep \n",
|
|||
|
"1 44731507 16621 1018 CHEVROLET Equinox 2011 Jeep \n",
|
|||
|
"2 45774419 8467 - HONDA FIT 2006 Hatchback \n",
|
|||
|
"3 45769185 3607 862 FORD Escape 2011 Jeep \n",
|
|||
|
"4 45809263 11726 446 HONDA FIT 2014 Hatchback \n",
|
|||
|
"... ... ... ... ... ... ... ... \n",
|
|||
|
"19232 45798355 8467 - MERCEDES-BENZ CLK 200 1999 Coupe \n",
|
|||
|
"19233 45778856 15681 831 HYUNDAI Sonata 2011 Sedan \n",
|
|||
|
"19234 45804997 26108 836 HYUNDAI Tucson 2010 Jeep \n",
|
|||
|
"19235 45793526 5331 1288 CHEVROLET Captiva 2007 Jeep \n",
|
|||
|
"19236 45813273 470 753 HYUNDAI Sonata 2012 Sedan \n",
|
|||
|
"\n",
|
|||
|
" Leather interior Fuel type Engine volume Mileage Cylinders \\\n",
|
|||
|
"0 Yes Hybrid 3.5 186005 km 6.0 \n",
|
|||
|
"1 No Petrol 3 192000 km 6.0 \n",
|
|||
|
"2 No Petrol 1.3 200000 km 4.0 \n",
|
|||
|
"3 Yes Hybrid 2.5 168966 km 4.0 \n",
|
|||
|
"4 Yes Petrol 1.3 91901 km 4.0 \n",
|
|||
|
"... ... ... ... ... ... \n",
|
|||
|
"19232 Yes CNG 2.0 Turbo 300000 km 4.0 \n",
|
|||
|
"19233 Yes Petrol 2.4 161600 km 4.0 \n",
|
|||
|
"19234 Yes Diesel 2 116365 km 4.0 \n",
|
|||
|
"19235 Yes Diesel 2 51258 km 4.0 \n",
|
|||
|
"19236 Yes Hybrid 2.4 186923 km 4.0 \n",
|
|||
|
"\n",
|
|||
|
" Gear box type Drive wheels Doors Wheel Color Airbags \n",
|
|||
|
"0 Automatic 4x4 04-May Left wheel Silver 12 \n",
|
|||
|
"1 Tiptronic 4x4 04-May Left wheel Black 8 \n",
|
|||
|
"2 Variator Front 04-May Right-hand drive Black 2 \n",
|
|||
|
"3 Automatic 4x4 04-May Left wheel White 0 \n",
|
|||
|
"4 Automatic Front 04-May Left wheel Silver 4 \n",
|
|||
|
"... ... ... ... ... ... ... \n",
|
|||
|
"19232 Manual Rear 02-Mar Left wheel Silver 5 \n",
|
|||
|
"19233 Tiptronic Front 04-May Left wheel Red 8 \n",
|
|||
|
"19234 Automatic Front 04-May Left wheel Grey 4 \n",
|
|||
|
"19235 Automatic Front 04-May Left wheel Black 4 \n",
|
|||
|
"19236 Automatic Front 04-May Left wheel White 12 \n",
|
|||
|
"\n",
|
|||
|
"[19237 rows x 18 columns]> \n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"df = pd.read_csv(\".//static//csv//car_price_prediction.csv\")\n",
|
|||
|
"print(df.info, \"\\n\")"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Объекты наблюдения**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Объектами наблюдения являются автомобили, представленные в наборе данных."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Атрибуты объектов**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 87,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"ID\n",
|
|||
|
"Price\n",
|
|||
|
"Levy\n",
|
|||
|
"Manufacturer\n",
|
|||
|
"Model\n",
|
|||
|
"Prod. year\n",
|
|||
|
"Category\n",
|
|||
|
"Leather interior\n",
|
|||
|
"Fuel type\n",
|
|||
|
"Engine volume\n",
|
|||
|
"Mileage\n",
|
|||
|
"Cylinders\n",
|
|||
|
"Gear box type\n",
|
|||
|
"Drive wheels\n",
|
|||
|
"Doors\n",
|
|||
|
"Wheel\n",
|
|||
|
"Color\n",
|
|||
|
"Airbags\n",
|
|||
|
"price_log\n",
|
|||
|
"price_category\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"attributes = df.columns\n",
|
|||
|
"for attribute in attributes:\n",
|
|||
|
" print(attribute)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Связи между объектами**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 16,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABAcAAAIlCAYAAACpcJFFAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADtPElEQVR4nOzdeXhTdfYG8DdJs7SlCy20TQVLBWQrgoIiigqCFFAEFxRERWVEURQGBxEH2cRBUBQQBHEBVPi5i+JSqcimVPYdQYGyaJsWKN1pkib390dyb5smaZM0bbb38zydoTffJCcxaXtPzvccmSAIAoiIiIiIiIgoZMl9HQARERERERER+RaTA0REREREREQhjskBIiIiIiIiohDH5AARERERERFRiGNygIiIiIiIiCjEMTlAREREREREFOKYHCAiIiIiIiIKcUwOEBEREREREYU4JgeIiIiIiIiIQlyYrwMgIiIi4NSpU/j999+Rn5+PCxcuIC8vD/Pnz0dkZKSvQyMiIqIQIBMEQfB1EERERKFqx44dGD9+PH7//Xeb42FhYVi/fj369Onjo8iIiIgolHBbARFJdu/ejdGjR6Nt27aIjIxEeHg4WrdujYceegiZmZm+Do8o6Pz666+45ZZbcPDgQbz22ms4c+YMBEGAIAgwGo1MDBAREVGjYeUAEcFsNuM///kP3nzzTYSFheHWW29FWloalEolTp48iZ9//hkXL17ErFmz8NJLL/k6XKKgYDAY0KFDB1y4cAEbN27E1Vdf7euQiIiIKISx5wARYerUqXjzzTfRtWtXfPHFF2jdurXN5ZcuXcLixYtx4cIFH0VIFHx++uknnDx5Em+99RYTA0RERORz3FZAFOKOHz+OefPmIT4+HhkZGXaJAQAIDw/HpEmTMHPmTOnYI488AplMhpMnT2LevHlo27YtNBoNUlNTMWvWLBiNRof3t2XLFgwePBjNmjWDWq1G27ZtMXXqVJSXlztcf+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t2rVDfn4+tm/fjvfffx+DBw92Gtf+/fsxcOBAREdHY8OGDWjZsqV0mbd+VxL5HYGIQlrv3r0FAMLPP//s1vVGjRolABCaN28unD17Vjqu1+uFm2++WQAgfPHFF9Lxw4cPC2FhYUKXLl2E8+fP29zWnDlzBADC66+/bnc/x48fFwAIjzzyiM3xW265RXD0IywlJUVISUlxGPOKFSsEAMKKFSukY8XFxYJcLheSk5OF0tJSh48xOztbOrZkyRIBgPDss8/a3T4A4ZZbbnF43zU5um1Rdna2AEAYNWqUzfH169cLAIT09HSbWM1ms/Dkk0/aPeeOHm91jp6rv//+W9Dr9XZrZ86cKQAQPv74Y5ceX15enlBSUmJ3fNWqVQIAYfbs2TbHnT0fkyZNEgAIa9eudXpfdT3vjz76qABAmDJlis3x77//XgAgtGnTRjCZTHaxDBkyRGjevLnN85Gfny+oVCph6NChAgBh+vTp0mVFRUVCTEyMoFarhf3790vHTSaTcP/99wsAhFmzZtndj0qlEvbs2WMT2zPPPCMAEMaNG1fnY33yyScFuVwudO3a1elr6r///a8AQNi0aVOdt3fttdcKAOxiquv1VJOj27506ZLQsmVLITY21qXbcMRgMAitW7cWIiMjbY6fPHnSbq3RaBRuu+02QaFQCKdPn/Y4vunTpwsAhI0bN0rHsrOzBY1GI3Tr1s3h+7V79+4CAGH58uV2cVX/mens/T5gwAAhMjJSaNeund3POjGeIUOGCEqlUtDpdNJler1eSEhIkF6j1W/XZDIJrVu3FgAIGRkZNrcpvtcee+wxjx5HTXW9Lx2957O
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1200x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"df['Price'] = pd.to_numeric(df['Price'], errors='coerce')\n",
|
|||
|
"df['Prod. year'] = pd.to_numeric(df['Prod. year'], errors='coerce')\n",
|
|||
|
"\n",
|
|||
|
"df.dropna(subset=['Price', 'Prod. year'], inplace=True)\n",
|
|||
|
"\n",
|
|||
|
"avg_price_per_year = df.groupby('Prod. year')['Price'].mean().reset_index()\n",
|
|||
|
"\n",
|
|||
|
"plt.figure(figsize=(12, 6))\n",
|
|||
|
"plt.plot(avg_price_per_year['Prod. year'], avg_price_per_year['Price'], marker='o')\n",
|
|||
|
"plt.title('Средняя цена автомобиля в зависимости от года выпуска', fontsize=14)\n",
|
|||
|
"plt.xlabel('Год выпуска')\n",
|
|||
|
"plt.ylabel('Средняя цена ($)')\n",
|
|||
|
"plt.grid(True)\n",
|
|||
|
"\n",
|
|||
|
"plt.xticks(avg_price_per_year['Prod. year'][::4])\n",
|
|||
|
"\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"**Вывод:** наличие корреляции между такими атрибутами, как цена, год производства, пробег, тип топливаnи и объем двигателя. Например, более новые автомобили с меньшим пробегом могут иметь более высокую цену.\n",
|
|||
|
"Категория автомобиля и его производитель также могут иметь связь с ценой и популярностью модели среди потребителей. Например, на графике показана зависимоость цены от года выпуска. По графику можно заметить: чем новее автомобиль, тем дороже его цена, за ислючением некоторых автомобилей.\n",
|
|||
|
"\n",
|
|||
|
" "
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"#### **Бизнес-цели:**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"**Ценообразование**\n",
|
|||
|
"Построение моделей для прогнозирования цен на автомобили на основе их характеристик. Эффект для бизнеса: Оптимизация стратегии продаж и увеличение прибыли.\n",
|
|||
|
"\n",
|
|||
|
"**Анализ спроса**\n",
|
|||
|
"Определение популярных моделей и типов автомобилей. Эффект для бизнеса: Более точное управление запасами и увеличение удовлетворенности клиентов.\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Цели технического проекта**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"**Для ценообразования:**\n",
|
|||
|
"\n",
|
|||
|
"Цель: Разработка модели для прогнозирования цен.\n",
|
|||
|
"Входные данные: Данные о характеристиках автомобилей (год выпуска, тип топлива, пробег и др.).\n",
|
|||
|
"Целевой признак: Цена автомобиля.\n",
|
|||
|
"\n",
|
|||
|
"**Для анализа спроса:**\n",
|
|||
|
"\n",
|
|||
|
"Цель: Анализ спроса на различные модели автомобилей.\n",
|
|||
|
"Входные данные: Данные о продажах, характеристиках и моделях автомобилей.\n",
|
|||
|
"Целевой признак: Частота продаж конкретных моделей и типов."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Проблемы данных**\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 45,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Пропущенные значения в данных:\n",
|
|||
|
" ID 0\n",
|
|||
|
"Price 0\n",
|
|||
|
"Levy 5819\n",
|
|||
|
"Manufacturer 0\n",
|
|||
|
"Model 0\n",
|
|||
|
"Prod. year 0\n",
|
|||
|
"Category 0\n",
|
|||
|
"Leather interior 0\n",
|
|||
|
"Fuel type 0\n",
|
|||
|
"Engine volume 0\n",
|
|||
|
"Mileage 0\n",
|
|||
|
"Cylinders 0\n",
|
|||
|
"Gear box type 0\n",
|
|||
|
"Drive wheels 0\n",
|
|||
|
"Doors 0\n",
|
|||
|
"Wheel 0\n",
|
|||
|
"Color 0\n",
|
|||
|
"Airbags 0\n",
|
|||
|
"dtype: int64\n",
|
|||
|
"\n",
|
|||
|
"Выбросы в числовых столбцах:\n",
|
|||
|
" ID 2531\n",
|
|||
|
"Price 627\n",
|
|||
|
"Prod. year 829\n",
|
|||
|
"Cylinders 0\n",
|
|||
|
"Airbags 0\n",
|
|||
|
"dtype: int64\n",
|
|||
|
"\n",
|
|||
|
"Распределение автомобилей по производителям:\n",
|
|||
|
" Manufacturer\n",
|
|||
|
"HYUNDAI 3769\n",
|
|||
|
"TOYOTA 3662\n",
|
|||
|
"MERCEDES-BENZ 2076\n",
|
|||
|
"FORD 1111\n",
|
|||
|
"CHEVROLET 1069\n",
|
|||
|
" ... \n",
|
|||
|
"LAMBORGHINI 1\n",
|
|||
|
"PONTIAC 1\n",
|
|||
|
"SATURN 1\n",
|
|||
|
"ASTON MARTIN 1\n",
|
|||
|
"GREATWALL 1\n",
|
|||
|
"Name: count, Length: 65, dtype: int64\n",
|
|||
|
"\n",
|
|||
|
"Последний год производства в данных: 2020.0\n",
|
|||
|
"\n",
|
|||
|
"начальный год: 2000.0\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import numpy as np\n",
|
|||
|
"\n",
|
|||
|
"# Заменяем \"-\" на NaN только в числовых столбцах\n",
|
|||
|
"numeric_columns = ['Price', 'Levy', 'Engine volume', 'Mileage', 'Cylinders', 'Airbags']\n",
|
|||
|
"df[numeric_columns] = df[numeric_columns].replace(\"-\", np.nan)\n",
|
|||
|
"\n",
|
|||
|
"# Проверяем пропущенные значения снова\n",
|
|||
|
"missing_values = df.isnull().sum()\n",
|
|||
|
"print(\"Пропущенные значения в данных:\\n\", missing_values)\n",
|
|||
|
"\n",
|
|||
|
"# Фильтрация только числовых столбцов для анализа выбросов\n",
|
|||
|
"numerical_data = df.select_dtypes(include=[np.number])\n",
|
|||
|
"\n",
|
|||
|
"# 2. Анализ выбросов\n",
|
|||
|
"Q1 = numerical_data.quantile(0.25)\n",
|
|||
|
"Q3 = numerical_data.quantile(0.75)\n",
|
|||
|
"IQR = Q3 - Q1\n",
|
|||
|
"outliers = ((numerical_data < (Q1 - 1.5 * IQR)) | (numerical_data > (Q3 + 1.5 * IQR))).sum()\n",
|
|||
|
"print(\"\\nВыбросы в числовых столбцах:\\n\", outliers)\n",
|
|||
|
"\n",
|
|||
|
"# 3. Анализ смещения данных\n",
|
|||
|
"category_counts = df['Manufacturer'].value_counts()\n",
|
|||
|
"print(\"\\nРаспределение автомобилей по производителям:\\n\", category_counts)\n",
|
|||
|
"\n",
|
|||
|
"# 4. Анализ актуальности данных\n",
|
|||
|
"max_production_year = df['Prod. year'].max()\n",
|
|||
|
"min_year_from_car = df['Prod. year'].min()\n",
|
|||
|
"\n",
|
|||
|
"print(\"\\nПоследний год производства в данных:\", max_production_year)\n",
|
|||
|
"print(\"\\nначальный год:\", min_year_from_car)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"В наборе данных есть пропущенные значения в столбце Levy. Выбросы встречаются с столбцах Price, Prod. year, Cylinders. Набор данных сильно смещён в сторону нескольких производителей, таких как Hyundai, Toyota, и Mercedes-Benz, которые составляют большую часть данных.\n",
|
|||
|
"В то же время, такие бренды, как Lamborghini, Pontiac, Saturn, и Aston Martin, представлены всего одной записью. Последний год выпуска в наборе данных — 2020: Данные устарели на несколько лет. Это может означать, что новые модели автомобилей, выпущенные после 2020 года, не учтены, что снижает актуальность данных для анализа современного рынка автомобилей."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Примеры решения обнаруженных проблем**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"В столбце Levy имеется 5819 пропущенных значений. Заполним пропуски, подставив 0."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 53,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"df['Levy'] = df['Levy'].fillna(0) "
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Заменим выбрасы на медиану"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 111,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"for col in ['Price', 'Prod. year', 'Cylinders']:\n",
|
|||
|
" Q1 = df[col].quantile(0.25) # 1-й квартиль\n",
|
|||
|
" Q3 = df[col].quantile(0.75) # 3-й квартиль\n",
|
|||
|
" IQR = Q3 - Q1 # Интерквартильный размах\n",
|
|||
|
" median = df[col].median() # Медиана\n",
|
|||
|
"\n",
|
|||
|
" # Определение выбросов\n",
|
|||
|
" condition = (df[col] < (Q1 - 1.5 * IQR)) | (df[col] > (Q3 + 1.5 * IQR))\n",
|
|||
|
"\n",
|
|||
|
" # Замена выбросов на медиану\n",
|
|||
|
" df[col] = np.where(condition, median, df[col])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Если нужно использовать для анализа машины определенных лет выпуска, можем отфильтровать данные следующим образом:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": null,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"df = df[df['Prod. year'] >= 2015]"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Оценка качества данных**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Для каждой категориальной переменной, такой как Manufacturer, Model, Category, можно подсчитать количество уникальных значений. Это даст представление о разнообразии и информативности данных.\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 109,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"ID 18924\n",
|
|||
|
"Price 2315\n",
|
|||
|
"Levy 559\n",
|
|||
|
"Manufacturer 65\n",
|
|||
|
"Model 1590\n",
|
|||
|
"Prod. year 54\n",
|
|||
|
"Category 11\n",
|
|||
|
"Leather interior 2\n",
|
|||
|
"Fuel type 7\n",
|
|||
|
"Engine volume 107\n",
|
|||
|
"Mileage 7687\n",
|
|||
|
"Cylinders 13\n",
|
|||
|
"Gear box type 4\n",
|
|||
|
"Drive wheels 3\n",
|
|||
|
"Doors 3\n",
|
|||
|
"Wheel 2\n",
|
|||
|
"Color 16\n",
|
|||
|
"Airbags 17\n",
|
|||
|
"price_log 2315\n",
|
|||
|
"price_category 5\n",
|
|||
|
"dtype: int64\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"unique_counts = df.nunique()\n",
|
|||
|
"print(unique_counts)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Мы видим здесь 65 брендов машин и 1590 различных моделей, что говорит а разнообразии данных."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Проверим на соответствие реальным данным"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 110,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA04AAAIVCAYAAADmnq8BAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACNm0lEQVR4nOzdd1gUV9sG8GcpYkFQVMCCiA1FBVFs2LCBii3WqLF3TexdrFFJokaNJfZeYu+9Y0uMsXeNBRsoqIBUYe/vD76dlxVwxSAL7P27Lq6Emdn12WGn3HPOnFEBgBAREREREVGyjPRdABERERERUXrH4ERERERERKQDgxMREREREZEODE5EREREREQ6MDgRERERERHpwOBERERERESkA4MTERERERGRDgxOREREREREOpjouwAiIiKipMTExMibN29ErVZLgQIF9F0OERk4tjgRERFRunHx4kXp0KGD5M2bV8zMzCR//vzSqlUrfZeVyPTp00WtVouIiFqtFl9fXz1XRERfG4MTEWUIq1atEpVKJRcvXkxyvoeHh5QtWzaNqyKi1LRr1y6pUaOG3Lp1S6ZNmyZHjhyRI0eOyOLFi/VdWiKrV6+WmTNnyrNnz2TWrFmyevVqfZdERF8Zu+oRERGR3r1580Z69uwpXl5esmXLFsmSJYu+S/qkKVOmSOfOnWXUqFFiZmYm69at03dJRPSVMTgRERGR3q1cuVKioqJk1apV6T40iYi0a9dO6tSpIw8ePJASJUpIvnz59F0SEX1l7KpHRJnanTt3pHXr1mJlZSVZs2YVNzc32b17t9YyyXUDDAoKEpVKJZMmTVKmTZo0SVQqlQQFBSX7bxYpUkS6du36yboeP34sKpUq2R8PDw+t5V+9eiU9evQQGxsbyZo1q7i4uHx216Ck6undu7dkzZpVTp48qUzbtWuXeHt7S4ECBcTMzEyKFSsmP/74o8TFxSnLeHh4fLJulUql9e+sW7dOKlasKNmyZR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hQ8uTJI6tXr5ZmzZrJ1q1ble0wODhYzpw5I2fOnJHu3btLxYoV5dixYzJmzBh5/PixLFq0KNl19u7dO52DMyRcVyIinTp10pr/X/YXyX13iCiTARFRBrBy5UqICP7+++8k59euXRtlypTRmlavXj2UK1cOUVFRyjS1Wg13d3eUKFFC53u/fv0aIoKJEycq0yZOnAgRwevXr5Ot1d7eHl26dPnk53n06BFEBDNmzEg0r0yZMqhdu7by+5w5cyAiWLdunTItJiYG1apVg7m5OUJDQz/5byWsZ/HixRARzJs3L9FyERERiab16dMH2bNn11qHH3+GlStXJpr3+PFjGBsbY9q0aVrTr1+/DhMTE63pSf3tErpy5QpEBD179tSaPnz4cIgIjh8/rvVZRQTbtm1TpoWEhCB//vxwdXVVpmn+5o8ePQIAREVFoXDhwmjUqFGizzRmzBiICF6+fJnosyf8+3Xp0gU5cuRA06ZN8f333yvTT58+jWzZsqFFixbIkSNHsp9TI6m/g6+vL1QqFZ48eaL179nb22stt2TJEogILly4kOg9Tpw4ARHBiRMnEs3buXMnRARTp07Vmt66dWuoVCo8ePBAmSYiaN26NUxMTHDx4kVleo8ePdChQweICAYMGKBMHzx4MEQEp0+fVqaFhYXBwcEBRYoUQVxcHID474GIYNKkSVo1dO3aFSKC69eva9WQcLscOXIkrK2tUbFiRa1tR6Njx45wcHDQmvbxe6R0f/E53x0iylzYVY+IMqU3b97I8ePHpW3bthIWFiZBQUESFBQkwcHB4uXlJffv35fnz59rvSYkJERZLigoSN68efPJ9w8KCpLw8PCv/VFk//79YmtrK+3bt1emmZqaysCBA+X9+/dy6tSpz3qfXbt2Sf/+/WXEiBGJulKJiGTLlk35f806q1mzpkRERMidO3dSVPP27dtFrVZL27Zttdapra2tlChRQk6cOPHZ77V//34RERk6dKjW9GHDhomIJOryVaBAAa3WAQsLC+ncubNcvnxZAgICkvw3FixYIMHBwTJx4sRE88LCwsTIyEirhexTunfvLhs2bFC6Ea5cuVJatmwplpaWn/X6hH+H8PBwCQoKEnd3dwEgly9f1lpWrVYr6/bKlSuyZs0ayZ8/v9Ki9Ln2798vxsbGMnDgQK3pw4YNEwBy4MABrek2Njbi7e0tK1euFBGRiIgI2bx5s3Tr1i3J965cubLUqFFDmWZubi69e/eWx48fy61bt5TpxsbGiVrykvs7azx//lzmzZsn48ePT7YrZExMjJiZmSX38b9of6Hxqe8OEWUuBh2c/Pz8pGnTplKgQAFRqVSyc+fOFL1ec6/Dxz85cuT4OgUT0Wd78OCBAJDx48dLvnz5tH40JzivXr3Sek39+vW1lnN0dEz2/R0dHSVfvnxibm4uNjY24uPjo3UvUGp68uSJlChRQoyMtHfZmpPjpLpHfezKlSvSvn17iYuLSzYQ3rx5U7755huxtLQUCwsLyZcvn3z33XciEh8qU+L+/fsCQLlpPuHP7du3E637T3ny5IkYGRlJ8eLFtabb2tpKrly5En3+4sWLJ7rXqmTJkiIiWvc0aYSEhMj06dNl6NChYmNjk2h+tWrVRK1Wy6BBg+Tff/+VoKAgefv2bbL1ent7i4mJiezatUvCw8OTDRTJ8ff3l65du4qVlZWYm5tLvnz5pHbt2kqtCT19+lRZr66urvLvv//Ktm3bPuteqoSePHkiBQoUkJw5c2pN/9R3rFu3bkpA3LJli+TOnVvq1q2b5HsntS19/N4qlUoKFCggFhYWWss5OjqKkZFRkn87kfiupwUKFJA+ffok+/nevXv3yXXyJfsLEd3fHSLKXAz6Hqfw8HBxcXGR7t27S8uWLVP8+uHDh0vfvn21ptWrV08qVaqUWiUS0RfS3Ew+fPhw8fLySnKZj0/EFyxYoJxgi4iEhoY
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x500 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"plt.figure(figsize=(10, 5))\n",
|
|||
|
"sns.boxplot(x='Category', y='Price', data=df)\n",
|
|||
|
"plt.title('Цены по категориям автомобилей')\n",
|
|||
|
"plt.xlabel('Категория')\n",
|
|||
|
"plt.ylabel('Цена')\n",
|
|||
|
"plt.xticks(rotation=45)\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"данная диаграмма была получина до устранения выбрасов."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 112,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2QAAAIVCAYAAAC+4TwYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC7JElEQVR4nOzdeVhUZfsH8O8wsrgBksqSgrgrimsqomhFkrvlmmTuuGCZlJaJEgba26a+Bi6ZZmmLW5pJKm6RipqmYuZWImTKmBKgIAzO3L8//M15GUFFQw7MfD/X5SVzzs2cew4zZ859nuc8j0ZEBERERERERFTqbNROgIiIiIiIyFqxICMiIiIiIlIJCzIiIiIiIiKVsCAjIiIiIiJSCQsyIiIiIiIilbAgIyIiIiIiUgkLMiIiIiIiIpWwICMiIiIiIlJJBbUTICIiIipNer0e6enpMBqN8PDwUDsdIrJybCEjIiIii3f48GEMHToU1atXh729Pdzd3dG/f3+10ypkzpw5MBqNAACj0Yi5c+eqnBERPWosyIjIqn322WfQaDQ4fPhwkeu7du2KZs2alXJWRFSSNm3ahE6dOuG3335DdHQ04uPjER8fjyVLlqidWiErV67EBx98gIsXL+LDDz/EypUr1U6JiB4xdlkkIiIii5Weno4xY8YgKCgIa9euhZ2dndop3dPs2bPx0ksv4Y033oC9vT1WrVqldkpE9IixICMiIiKLtWLFCuTm5uKzzz4r88UYAAwePBhPPvkkfv/9dzRo0AA1atRQOyUiesTYZZG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
|
|||
|
"<Figure size 1000x500 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"plt.figure(figsize=(10, 5))\n",
|
|||
|
"sns.boxplot(x='Category', y='Price', data=df)\n",
|
|||
|
"plt.title('Цены по категориям автомобилей')\n",
|
|||
|
"plt.xlabel('Категория')\n",
|
|||
|
"plt.ylabel('Цена')\n",
|
|||
|
"plt.xticks(rotation=45)\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"После устранения выбрасов, диаграмма выглядит лучше, хотя здесь все равно присутствуют очень маленькие значения, что не соответсвуем реальным ценам на машины. Из этого можем сделать вывод, что цены в наборе данных не особо соответствуют реальности. "
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Данный датасет содержит все ключевые аспекты, которые могут повлиять на цены автомобилей, поэтому его можно считать информативными."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Разбиение данных на выборки и Приращение данных**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 126,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnIAAAIwCAYAAAACvobyAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1gUV9sG8HuXjnQVAUXsX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K2PHjh2oXr26zjpYW1sjJCQETZo0UYatX78eiYmJRrfRggULYGdnp3yPiorCmDFjjKZv2rQpmjVrBgA4dOgQFi1alM4vYPxa9T401cS0ubi4AADCw8Px119/ITAwEG5ubrh48SIWLVqEixcv4ujRo3o3FF9++eW7P+2QTyAkJEQAyO7du+XRo0dy584dWblypWTNmlVsbGzk7t27IiKSmJgoKSkpOtNGRUWJlZWVTJgwQRkWHBwsAGTGjBl6y0pNTVWmAyBTp07VS1O8eHGpXr268n3fvn0CQHLmzCnx8fHK8NWrVwsAmT17tjLvggULip+fn7IcEZGXL19K3rx5pW7dunrLqlSpkpQoUUL5/ujRIwEgY8eOVYbdvHlTzMzMZNKkSTrTnj9/XszNzfWGX7t2TQBIWFiYMmzs2LGi/fMeOnRIAMiyZct0pt2xY4fecC8vLwkICNDLe58+fSTtLpM270OHDhVXV1fx9vbW2aa//fabqNVqOXTokM70CxcuFABy+PBhveVpq169ujK/bdu2ibm5uQwePNhg2sxsD5G3v5O2pKQkKVGihNSqVUtnXmq
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoEAAAIwCAYAAAD5xbFoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1gUV9sG8HuX3hGRpqjYezRYgr2g2HvBgr0llqgx1lhjNPYWayLF3ks0iYq9oUYUsUeN2MEKKIIIPN8ffjsvy+4CEo2+796/69pLmTk7c2Z25swzM6eoRERAREREREZF/bEzQERERET/PgaBREREREaIQSARERGREWIQSERERGSEGAQSERERGSEGgURERERGiEEgERERkRFiEEhERERkh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WXbRoUfHz81PWIyLy6tUr8fLykvr16+usq2rVqlKmTBnl78ePHwsAmTBhgjItKipKTExM5IcfftD67oULF8TU1FRn+vXr1wWAhISEKNMmTJgg6X+io0ePCgBZs2aN1nd3796tM71AgQLSpEkTnbwPGDBAMv7sGfM+YsQIcXFxEW9vb619umrVKlGr1XL06FGt7y9dulQAyPHjx3XWl16tWrWU5f32229iamoq33zzjd602dkfIm9/p/SSk5OlTJkyUrduXa1lqdVqadWqlc6xqPnNY2Njxc7OTqpUqSKJiYl60yQnJ4uLi4uUKVNGK82uXbsEgIwfP16Z1q1bNylQoIDWcpYvXy4A5PT
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAooAAAIwCAYAAAABJUqfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAD9SElEQVR4nOzdd1gU1/s28HuX3rECVmwoVhRL7A1716hYEXtvMXYlloQYey8JRey9JcYaNRox9l6iUewiioCiiMLz/sG7891lZxFMIuGX+3Nde10w9ezszJlnzpx5RiMiAiIiIiKiVLSZXQAiIiIi+ndioEhEREREqhgoEhEREZEqBopEREREpIqBIhERERGpYqBIRERERKoYKBIRERGRKgaKRERERKSKgSLRf1h8fDzu37+PFy9eZHZR6G/28uVLREREID4+PrOLQkRZGANFov+YTZs2oX79+nBwcIC9vT0KFCiA7777LrOLlSW8evUK8+bNU/6PiYnB4sWLM69AekQEK1aswGeffQZbW1s4OjqiUKFCWL16dWYX7W9z8uRJWFpa4u7du5ldFKIsZdmyZShQoADevn2b4Xk1GXmFX2hoKPz9/ZX/raysUKBAATRs2BCTJ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AVq5cqQwLCAgQ/Z/l6NGjAkDWrFljMO+ePXuMhhcsWFCaNWtmVPZBgwZJ6p86ddlHjx4tuXPnFm9vb4NtumrVKtFqtXL06FGD+ZctWyYA5LfffjNan77atWsry/vpp5/E3NxcvvjiC9Vp07M9RFJ+J32JiYlSunRpqVevnsGytFqttGn
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"from sklearn.model_selection import train_test_split\n",
|
|||
|
"from imblearn.over_sampling import RandomOverSampler\n",
|
|||
|
"from imblearn.under_sampling import RandomUnderSampler\n",
|
|||
|
"\n",
|
|||
|
"# Загрузка данных\n",
|
|||
|
"new1 = pd.read_csv(\".//static//csv//car_price_prediction.csv\")\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение на обучающую и временную выборки\n",
|
|||
|
"train_data, temp_data = train_test_split(new1, test_size=0.3, random_state=42)\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение временной выборки на контрольную и тестовую\n",
|
|||
|
"val_data, test_data = train_test_split(temp_data, test_size=0.5, random_state=42)\n",
|
|||
|
"\n",
|
|||
|
"# Определяем целевую переменную и признаки\n",
|
|||
|
"X = train_data.drop(columns=['Manufacturer']) # Признаки\n",
|
|||
|
"y = train_data['Manufacturer'] # Целевая переменная\n",
|
|||
|
"\n",
|
|||
|
"# Функция для визуализации распределения\n",
|
|||
|
"def plot_class_distribution(data, title):\n",
|
|||
|
" data['Manufacturer'].value_counts().plot(kind='bar', title=title)\n",
|
|||
|
" plt.xlabel('Manufacturer')\n",
|
|||
|
" plt.ylabel('Count')\n",
|
|||
|
" plt.show()\n",
|
|||
|
"\n",
|
|||
|
"# Визуализация распределения классов до оверсэмплинга\n",
|
|||
|
"plot_class_distribution(train_data, 'Распределение классов в обучающей выборке (до оверсэмплинга)')\n",
|
|||
|
"\n",
|
|||
|
"# Применение оверсэмплинга\n",
|
|||
|
"ros = RandomOverSampler(random_state=42)\n",
|
|||
|
"X_resampled, y_resampled = ros.fit_resample(X, y)\n",
|
|||
|
"\n",
|
|||
|
"# Создание нового DataFrame для оверсэмплинга\n",
|
|||
|
"train_resampled_over = pd.DataFrame(X_resampled, columns=X.columns)\n",
|
|||
|
"train_resampled_over['Manufacturer'] = y_resampled\n",
|
|||
|
"\n",
|
|||
|
"# Визуализация распределения классов после оверсэмплинга\n",
|
|||
|
"plot_class_distribution(train_resampled_over, 'Распределение классов в обучающей выборке (после оверсэмплинга)')\n",
|
|||
|
"\n",
|
|||
|
"# Применение андерсэмплинга\n",
|
|||
|
"rus = RandomUnderSampler(random_state=42)\n",
|
|||
|
"X_resampled, y_resampled = rus.fit_resample(X, y)\n",
|
|||
|
"\n",
|
|||
|
"# Создание нового DataFrame для андерсэмплинга\n",
|
|||
|
"train_resampled_under = pd.DataFrame(X_resampled, columns=X.columns)\n",
|
|||
|
"train_resampled_under['Manufacturer'] = y_resampled\n",
|
|||
|
"\n",
|
|||
|
"# Визуализация распределения классов после андерсэмплинга\n",
|
|||
|
"plot_class_distribution(train_resampled_under, 'Распределение классов в обучающей выборке (после андерсэмплинга)')"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"По графикам можно увидить, что изначалльно выборки были сбалансированы плохо, но после приращения ситуация кординально изменилась."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **2. Forbes 2022 Billionaires data**\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Проблемная область**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Проблемная область данного набора данных связана с анализом состояния, возраста и источников богатства самых богатых людей в мире. Это может быть полезно для понимания, какие факторы влияют на накопление богатства и как эти факторы могут варьироваться в зависимости от региона и индустрии."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 63,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"<bound method DataFrame.info of Rank Name Networth Age Country \\\n",
|
|||
|
"0 1 Elon Musk 219.0 50 United States \n",
|
|||
|
"1 2 Jeff Bezos 171.0 58 United States \n",
|
|||
|
"2 3 Bernard Arnault & family 158.0 73 France \n",
|
|||
|
"3 4 Bill Gates 129.0 66 United States \n",
|
|||
|
"4 5 Warren Buffett 118.0 91 United States \n",
|
|||
|
"... ... ... ... ... ... \n",
|
|||
|
"2595 2578 Jorge Gallardo Ballart 1.0 80 Spain \n",
|
|||
|
"2596 2578 Nari Genomal 1.0 82 Philippines \n",
|
|||
|
"2597 2578 Ramesh Genomal 1.0 71 Philippines \n",
|
|||
|
"2598 2578 Sunder Genomal 1.0 68 Philippines \n",
|
|||
|
"2599 2578 Horst-Otto Gerberding 1.0 69 Germany \n",
|
|||
|
"\n",
|
|||
|
" Source Industry \n",
|
|||
|
"0 Tesla, SpaceX Automotive \n",
|
|||
|
"1 Amazon Technology \n",
|
|||
|
"2 LVMH Fashion & Retail \n",
|
|||
|
"3 Microsoft Technology \n",
|
|||
|
"4 Berkshire Hathaway Finance & Investments \n",
|
|||
|
"... ... ... \n",
|
|||
|
"2595 pharmaceuticals Healthcare \n",
|
|||
|
"2596 apparel Fashion & Retail \n",
|
|||
|
"2597 apparel Fashion & Retail \n",
|
|||
|
"2598 garments Fashion & Retail \n",
|
|||
|
"2599 flavors and fragrances Food & Beverage \n",
|
|||
|
"\n",
|
|||
|
"[2600 rows x 7 columns]> \n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"df2 = pd.read_csv(\".//static//csv//Forbes Billionaires.csv\")\n",
|
|||
|
"print(df2.info, \"\\n\")"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Объекты наблюдения**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Объектами наблюдения являются богатейшие люди мира, представленные в наборе данных."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Атрибуты объектов**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 89,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"ID\n",
|
|||
|
"Price\n",
|
|||
|
"Levy\n",
|
|||
|
"Manufacturer\n",
|
|||
|
"Model\n",
|
|||
|
"Prod. year\n",
|
|||
|
"Category\n",
|
|||
|
"Leather interior\n",
|
|||
|
"Fuel type\n",
|
|||
|
"Engine volume\n",
|
|||
|
"Mileage\n",
|
|||
|
"Cylinders\n",
|
|||
|
"Gear box type\n",
|
|||
|
"Drive wheels\n",
|
|||
|
"Doors\n",
|
|||
|
"Wheel\n",
|
|||
|
"Color\n",
|
|||
|
"Airbags\n",
|
|||
|
"price_log\n",
|
|||
|
"price_category\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"attributes = df.columns\n",
|
|||
|
"for attribute in attributes:\n",
|
|||
|
" print(attribute)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Связи между объектами**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Можно выявить связи между возрастом и состоянием, страной проживания и источником дохода, а также отраслью и уровнем благосостояния."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 128,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAEnCAYAAAAXY2zOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABnb0lEQVR4nO2dd3hUxfrHv9tLkt30BgESQidABEFIgIsgRUDaRQUuVcFCUxABlSZSBCuIFyt6LwJeRFHEn0oVwYAISFFEQm8JpG42m2yd3x+bPezZvmGTbMj7eZ48sGfmzHnPe+bMe2bmnXcEjDEGgiAIgghihDUtAEEQBEF4g4wVQRAEEfSQsSIIgiCCHjJWBEEQRNBDxoogCIIIeshYEQRBEEEPGSuCIAgi6CFjRRAEQQQ9ZKwIgiCIoIeMFUEQBBH0kLGqBOfOncMTTzyBlJQUyOVyqFQqZGRk4O2330ZZWVlNi0cQBHHXIa5pAWob27dvx/DhwyGTyTBmzBi0bt0aBoMB+/fvx6xZs/DHH3/g/fffr2kxCYIg7ioEFMjWdy5cuIA2bdqgfv362L17NxISEnjp2dnZ2L59O6ZPn15DEhIEQdyd0DCgH6xYsQJarRYfffSRk6ECgNTUVJ6hEggE3J9IJEK9evUwadIkFBUV8c47f/48hg8fjsTERAiFQu6c1q1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926BY1GwxsCrSy2+2jWrJlTWosWLbiGzJ527dqhdevW+M9//gPGGD755BOMHz++Utffv38/tm3bhld
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcAAAAFNCAYAAACXC791AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB4a0lEQVR4nO3dd1iT19sH8G/C3kORJSK4EVHcOHCL4NY6qeKoG6WOVq0I4q62zqLWVa1i3btWxYkD3AouFERxAA5kC0Jy3j948/wICUpCYiC5P9fFpXmew8lJQnLnnOec+/AYYwyEEEKIhuGrugGEEEKIKlAAJIQQopEoABJCCNFIFAAJIYRoJAqAhBBCNBIFQEIIIRqJAiAhhBCNRAGQEEKIRqIASAghRCNRACQab/HixRAKhQAAoVCIJUuWqLhFhJBvQa4AGB8fj3HjxsHZ2Rn6+vowNTVF69atsXr1anz69EnRbSREqbZv347ffvsNr169wu+//47t27erukmEkG+AJ2su0H///RcDBgyAnp4ehg8fDldXV3z+/BmXL1/GgQMHMGLECGzcuFFZ7SVE4fbs2YPhw4fj8+fP0NPTw86dO/Hdd9+pulmEECWTKQAmJCTAzc0NVatWxblz52Brayt2Pi4uDv/++y8CAgIU3lBClOnt27eIi4tDrVq1YGVlpermEEK+BSaD8ePHMwDsypUrpSoPgPvh8/nMzs6OjRkzhn38+FGsXHx8PPvuu++Yra0t4/F43O/Ur1+fK3Pp0iXWunVrVqlSJaanp8ecnJzYzz//zD59+sSV+euvvxgAduPGDVkeltjv6ujosLdv34qdu3r1Ktem4nVHRUUxLy8vZmpqygwMDJinpye7fPmyWJlZs2YxPT09sePn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svj4eO7YmzdvmImJCfP09JSoU/TNPzc3l1WrVo15e3vL1AMsTZtEPcBevXqJlZ04cSIDwO7du8cYY+zu3bsMAPvhhx/Eys2YMYMBYOfOnRM7funSJaanp8fmzJnDGBPvAf73339MS0tL6jf24j3AdevWMT09PdahQwepPcDiz4WdnR3z8fHhbufm5jKBQCBWJiEhgenp6bH58+dzx8rSA/zS6zN79mwGgCUlJUm0XdYeoKx/B0FBQQwAO3jwoMQ50Xtn1apVDADbuXMnd+7z58/Mw8ODGRsbs4yMDMYYY+fOnWMA2JQpU0qs60ttL6q09/np0yfG5/PZuHHjxH7fz89PoT3AFi1acM9p0ffG6NGjma2tLXv//r1YnYMHD2ZmZmbcZ4SoziFDhrBKlSqJjUDUqlWL+4yWpQdY6lmgGRkZAAATExOZAmxOTg7ev3+P5ORkHDhwAPfu3UOnTp2485mZmQCASpUqlaq+1NRUJCUl4fDhw4iMjISnp6dEmfT0dLx//56rWxbDhg3D48ePcfPmTQDAgQMHYGZmJtZmALh79y6ePn2KoUOH4sOHD3j//j3ev3+P7OxsdOrUCREREdzUegAwNDTEsWPHkJqaioEDB0IgEAAo7AEPGjQIHz9+xNGjR2FgYCC1Xbm5udDX1/9i283MzNC7d2/8888/YP9/aVcgEGDPnj3o06cPjIyMSvzd8PBwZGZmYtasWRL3I61nURoeHh5o0qQJd7tatWro3bs3Tp06xT3+oo83Pz8fHz58QM2aNWFubi7126fotRX9pKamip0XCAQ4ffo0+vTpA2dnZ+64ra0thg4disuXL3N/y8WFhobiw4cPCA4OluvxlsakSZPEbk+ePBkAuG/Gon+nTZsmVm769OkACiehFdWmTRv8+eefWLRoEXbu3Mkdf/DgAQYNGoRhw4ZhxowZX2xTTk4O5s+fD39/f1SrVk1qmaysLLx//x6vX7/Gxo0bkZycLPa
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|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v3zVLliwhDRs2JG3btuX6/B07dozIyMiQsLAwrsfv3buXACD379/nKvOPP/4gcnJyJDIyktk+efJk5vt29uzZPPFVptpNjtnZ2QAANTW1GiXMvLw8pKenIzU1FUFBQXj27Bl69uzJ7M/JyQEANGjQoFrlZWRk4PPnzzh//jzCw8Ph6OjIc0xWVhbS09OZsmti3LhxeP36NVM1DwoKgoaGBlfMABAdHY24uDiMGTMG3759Q3p6OtLT0/Hjxw/07NkToaGhKC0tZY5XVlbGpUuXkJGRgREjRqCkpARAWQ115MiR+P79Oy5evAglJSW+ceXn54PNZlcau4aGBgYPHox//vmHafIpKSnBqVOnMGTIEKioqFT7dcjLy8PatWsxZ84cGBsbc+0LCgoCi8WCh4cHz+N+baqoypUrV6Cvr4/Ro0cz2+Tl5TF37lzk5ubi7t27AICGDRsCAD58+FCtcnNycpi/CedWFV9fX3z79o3v8+JITExE//79YWNjg2PHjkFG5n8foc+fPyM6OhoTJkyAtrY2s93a2hq9evXiaqrjmDRpEq5du4bU1FQAgL+/P+zt7dGiRYtqPU+O6rw/rly5AllZWcydO5dr+8KFC0EIwdWrV5lt+vr68PX1xc2bN9GlSxdER0fj8OHDUFdXF6g8TowAqoyz/GegqKgI3759Q7NmzaCpqYmoqKhKH/urJ0+eIDAwEN7e3lx/q4pU573N+Tu6u7tz7efUji9fvgwAuHnzJnJycrBs2TKe5yzI56Q65wTK3vtaWlrVOkdRURHP56SqloGPHz9i586dWLVqFVRVVbn
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAGVCAYAAADAPivmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXB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Lx5k/khLVu2DE+ePIGGhgYKCwsrlJWeno7GjRtXqf+4ceNw9uxZ3Lt3D25ubrh9+zY+ffpU5eN3cnIygLK/By8qKiqwsbFh9ouLMJ1tbW2Rn5+PL1++wNjYGN+/f8emTZtw+PBhfPz4kbl5AGXnkEt8fDyGDBki0nEzMzOhpaVV5bi8vDzUq1ePed+gQQMsWLBAYCH54cOHfOPKnyddXV2YmJggKSlJJP0A4P79+wgMDERQUBDevXtX5fiEhAQA4HMvlefLly/Iz88X0A8AmjZtitLSUrx//x4ODg5inc/KEOeYrVq1grKyMtasWQNDQ0PGBVHe8HHhvZZFITExEXv37sXu3bsFJiySXLPOzs5o1qwZjh07hkWLFuHIkSP49ddf8f79e7H0AmRggE1NTfHy5UuxPjd27FiMGzcOpaWlSEhIwLp169C3b1/cvn0bLBYLWlpaOHv2LCZOnIiOHTvyfdbBwUFA3vnz55GdnY1nz55h8+bNMDMzw/r16/nG+Pv7w9bWFoWFhbh79y7++OMPAMCuXbtE0nnixIkYN24cZs+ejZCQEBw4cAD37t3jG8P9wfz+++9wdnYWKqe8AfDx8YGJiQk2bNgAT09PAMCzZ89w5swZLFu2DD4+Prh8+bKAnKKiIqSmpqJ
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import seaborn as sns\n",
|
|||
|
"\n",
|
|||
|
"plt.figure(figsize=(10, 6))\n",
|
|||
|
"\n",
|
|||
|
"# Связь между возрастом и состоянием\n",
|
|||
|
"plt.subplot(2, 2, 1)\n",
|
|||
|
"sns.scatterplot(data=df2, x='Age', y='Networth')\n",
|
|||
|
"plt.title('Связь между возрастом и состоянием')\n",
|
|||
|
"plt.xlabel('Возраст')\n",
|
|||
|
"plt.ylabel('Состояние (млрд)')\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"# Связь между страной проживания и состоянием (топ-10 стран)\n",
|
|||
|
"plt.subplot(2, 2, 2)\n",
|
|||
|
"top_countries = df2['Country'].value_counts().index[:10]\n",
|
|||
|
"sns.boxplot(data=df2[df2['Country'].isin(top_countries)], x='Country', y='Networth')\n",
|
|||
|
"plt.title('Связь между страной проживания и состоянием')\n",
|
|||
|
"plt.xticks(rotation=90)\n",
|
|||
|
"plt.xlabel('Страна')\n",
|
|||
|
"plt.ylabel('Состояние (млрд)')\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"# Связь между источником дохода и состоянием (топ-10 источников дохода)\n",
|
|||
|
"plt.subplot(2, 2, 3)\n",
|
|||
|
"top_sources = df2['Source'].value_counts().index[:10]\n",
|
|||
|
"sns.boxplot(data=df2[df2['Source'].isin(top_sources)], x='Source', y='Networth')\n",
|
|||
|
"plt.title('Связь между источником дохода и состоянием')\n",
|
|||
|
"plt.xticks(rotation=90)\n",
|
|||
|
"plt.xlabel('Источник дохода')\n",
|
|||
|
"plt.ylabel('Состояние (млрд)')\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n",
|
|||
|
"# Связь между отраслью и состоянием (топ-10 отраслей)\n",
|
|||
|
"plt.subplot(2, 2, 4)\n",
|
|||
|
"top_industries = df2['Industry'].value_counts().index[:10]\n",
|
|||
|
"sns.boxplot(data=df2[df2['Industry'].isin(top_industries)], x='Industry', y='Networth')\n",
|
|||
|
"plt.title('Связь между отраслью и состоянием')\n",
|
|||
|
"plt.xticks(rotation=90)\n",
|
|||
|
"plt.xlabel('Отрасль')\n",
|
|||
|
"plt.ylabel('Состояние (млрд)')\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"#### **Бизнес-цели:**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Понять факторы успеха:\n",
|
|||
|
"\n",
|
|||
|
"Бизнес-цель: Исследовать, какие факторы (возраст, страна, источник дохода) коррелируют с высоким состоянием.\n",
|
|||
|
"Эффект для бизнеса: Это может помочь новым предпринимателям и стартапам учиться на опыте успешных людей.\n",
|
|||
|
"\n",
|
|||
|
"Анализ тенденций богатства:\n",
|
|||
|
"\n",
|
|||
|
"Бизнес-цель: Изучить, как источники богатства меняются со временем и как это связано с экономическими условиями в разных странах.\n",
|
|||
|
"Эффект для бизнеса: Поможет инвесторам и аналитикам определить, какие секторы могут быть наиболее перспективными для инвестиций в будущем."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Цели технического проекта**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Цель 1: Анализ тенденций богатства.\n",
|
|||
|
"\n",
|
|||
|
"Входные данные: Данные о богатейших людях (возраст, страна, источник богатства).\n",
|
|||
|
"Целевой признак: Наличие зависимости между источником богатства и страной.\n",
|
|||
|
"\n",
|
|||
|
"Цель 2: Исследование факторов успеха.\n",
|
|||
|
"\n",
|
|||
|
"Входные данные: Данные о богатейших людях (возраст, чистая стоимость, индустрия).\n",
|
|||
|
"Целевой признак: Выявление факторов, способствующих накоплению состояния."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Проблемы данных**\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 129,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw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nTJvLy8jJ11atXL1NmW4+3Aw88MOu8kydP3uIYDxo0KHJycuLyyy/PbNvSfD777LNx2GGHRZ06daJhw4Zx/PHHx5tvvrm14QeAKs068P+paOvAkvaU/NSpUye6du0at99+e6myzz//fBxxxBFRt27daNSoUQwePDjeeeedrDK33nprdO/ePRo2bBh169aN7t27x7hx40r1rV69ejF37tw49thjo27dutGqVau44oorIkmSrLJ//OMf47DDDos999wzateuHQcffHA8/PDDW+zL+PHj49BDD406derEHnvsEUceeWRMnDgxIiLatWu3zfFs165dJEkS7dq1i8GDB5eqe926ddGwYcMYNmzYdscUKhNXRlHlLF++PBYvXhxJksSiRYvixhtvjFWrVsXpp5/+jer96quvYt26dXHuuefGt7/97fjZz34WH374Ydx8880xY8aMmDFjRhQUFGTKL126NI477rg4+eST47TTTosHH3wwzj333MjPz4+zzjorIiLWrl0b/fr1iw8++CDOP//8aN++fTz00EMxdOjQWLZsWVx44YWZ+n7yk5/EXXfdFQMHDoyzzz47Nm7cGC+88EJMnz496x3AXaWgoKDUYmDmzJlxww03ZG0ruUfDIYccEqNHj46FCxfG9ddfHy+99FK89tpr0ahRo62eY9WqVXHEEUfEO++8E2eddVYcdNBBsXjx4njiiSfis88+iyZNmuzSMbrnnnsyZV944YW47bbb4s9//nM0adIkIiKaN28eETs2L2eeeWY899xz8fOf/zy6d+8eeXl5cdttt8Wrr76602O/ualTp8ZTTz213XIvvPBCHHfccdG2bdsYNWpUbNiwIW655ZY4/PDDY+bMmbHvvvvusjYBQEVkHbhrpLEOLFGyFluxYkXccccd8dOf/jTatWsX/fv3j4iI5557LgYOHBgdOnSIyy+/PNauXRs33nhjHH744fHqq69Gu3btIiJi5cqVccwxx0THjh0jSZJ48MEH4+yzz45GjRrFiSeemDlfUVFRDBgwIL71rW/FNddcE88880yMGjUqNm7cGFdccUWm3PXXXx/f+973YsiQIVFYWBj3339/nHTSSTFhwoQYNGhQptzvfve7uPzyy+Owww6LK664IvLz82PGjBnx/PPPxzHHHBN/+ctfYtWqVRER8c4778Qf/vCH+M1vfhP7779/RETUq1cvcnJy4vTTT49rrrkmlixZEo0bN87U/+STT8aKFSu+8WMYKpwEqog777wziYhSPwUFBcldd92VVXbevHlJRCTXXnvtVusbNWpUsulTpOT3o48+Otm4cWOp8954442ZbX379k0iIrnuuusy29avX5/06NEjadasWVJYWJgkSZL85S9/SSIiGT9+fKZcYWFh0qdPn6RevXrJihUrkiRJkueffz6JiOSCCy4o1c7i4uLMvyMiGT58+HbHaN68eVstkyRJcuaZZyZ169Yttf2hhx5KIiL517/+lWlrs2bNkgMPPDBZu3ZtptyECROSiEhGjhy5zfOMHDkyiYjk0Ucf3Wq/dvUYldjWWJT1nGvXrk1yc3OTYcOGZR2/+fht6/F2wAEHJH379s38/q9//StrjJMkSXr37p0MHDgwiYhk1KhRW+3DwQcfnDRs2DBZsGBBpsx7772X1KxZMznxxBNLnRsAqgrrwMq3DtxSe957770kIpJrrrkms61k3L766qvMtv/85z9Jbm5u8qMf/Wir9W/cuDFp0KBBcv7552f1LSKSn//855ltxcXFyaBBg5L8/Pzkyy+/zGxfs2ZNVn2FhYXJgQcemHz729/ObHv//feT3Nzc5IQTTkiKioqyym9p/bmldV6JOXPmJBGR3HrrrVnbv/e97yXt2rXbYn1QmfmYHlXOzTffHJMmTYpJkybF+PHj46ijjoqzzz47Hn300VJl16xZE4sXL46lS5eWujR3ay655JLIy8vL/H7GGWdE8+bN4x//+EdWuRo1amRdTpufnx/Dhg2LRYsWxaxZsyIi4qmnnooWLVrEaaedlilXs2bNuOCCC2LVqlUxZcqUiIh45JFHIicnJ0aNGlWqPZteQh7x9aW8ixcvjq+++iqKi4vL1Ked9corr8SiRYvivPPOi1q1amW2Dxo0KDp37lxqTDb3yCOPRPfu3eOEE04ota+kX7tjjLanrOdcvXp1FBcXx5577lmmekseb5v+FBUVbfOYRx99NGbOnBlXXXXVVsssXbo03nvvvZg1a1YMGTIkc4VXRESnTp3ie9/7XjzzzDPbPRcAVHbWgZVnHVhi6dKlsXjx4pg7d278+c9/jry8vOjbt29ERHzxxRcxe/bsGDp0aNbVQt26dYvvfOc7pa4cLyoqisWLF8fHH38cf/7zn2PFihVxxBFHlDrnph9nLPl4Y2FhYTz33HOZ7bVr185q4/Lly+OII47Iuvr9sccei+Li4hg5cmTk5ma/tN7R9ee+++4bvXv3jnvvvTezbcmSJfH000/HkCFDdrg+qOiEUVQ5hx56aPTv3z/69+8fQ4YMiX/84x/RpUuXzH8ymxo1alQ0bdo0GjduHHXq1IlBgwbF+++/v8V6S/4D6Ny5c9b2vLy86NSpU6nP37dq1arU1/yWfEyqpOzHH38cnTp1KvWfV8llux9//HFERHz44YfRqlWrrP+Et2bcuHHRtGnTaNKkSdSuXTuOPPLIrPsJ7Eol7dtvv/1K7evcuXNm/9Z8+OGHceCBB273HLt6jLanrOfcc889o1OnTnH77bfHxIkTY9GiRbF48eJYv379Fustebxt+vPuu+9utR1FRUXxm9/8JoYMGRLdunXbarmDDjooMwdbmov9998/Vq9enXUfLgCoiqwDK886sMRBBx0UTZs2jY4dO8Ydd9wRN910Uxx66KHbPcf+++8fixcvjtWrV2e2vf/++9G0adNo165djBgxIm655ZY4+eSTs47
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1500x500 with 2 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Размер данных до удаления выбросов: (2600, 7)\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"fig, axs = plt.subplots(1, 2, figsize=(15, 5))\n",
|
|||
|
"\n",
|
|||
|
"sns.boxplot(data=df2, x='Networth', ax=axs[0])\n",
|
|||
|
"axs[0].set_title(\"Выбросы по состоянию\")\n",
|
|||
|
"\n",
|
|||
|
"sns.boxplot(data=df2, x='Age', ax=axs[1])\n",
|
|||
|
"axs[1].set_title(\"Выбросы по возрасту\")\n",
|
|||
|
"\n",
|
|||
|
"plt.show()\n",
|
|||
|
"print(\"Размер данных до удаления выбросов: \", df2.shape)\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"В данном случае выбросов нет, все данные находятся в пределах допустимых значений"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 69,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA/YAAAIjCAYAAACpnIB8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB8/0lEQVR4nO3deVxU9f7H8fcMzAw7roDkRmou5VJaSuWSqWjWbfHXbbEyNbsZ1lXLylu5dcuyW2Zletu0zRYru6WlYq4ZmpmWaZmZRqXgCijrwJzfHzhHRhYRwZmB1/Px4BGc850znzPMl3zP93u+x2IYhiEAAAAAAOCXrN4uAAAAAAAAVB7BHgAAAAAAP0awBwAAAADAjxHsAQAAAADwYwR7AAAAAAD8GMEeAAAAAAA/RrAHAAAAAMCPEewBAAAAAPBjBHsAAAAAAPwYwR4AAKAWe/vtt7V7927z57lz5+qvv/7yXkEAgFNGsAeACpg7d64sFkuZX3/++ae3SwSASlmzZo0eeOAB7d69W0uWLFFiYqKsVv6JCAD+JNDbBQCAP5kyZYri4uJKbK9Xr54XqgGA0zdmzBj16tXL/Ns2duxYNWrUyMtVAQBOBcEeAE7BgAED1KVLF2+XAQBVpk2bNtq5c6d+/PFHNWjQQC1atPB2SQCAU8Q8KwCoQu4p+8WvV3W5XOrQoYMsFovmzp3r0f7nn3/W3//+dzVs2FDBwcFq3bq1Hn74YUnS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d98tl8ulxMTEEu1PVFhYqP79+6tbt26aNm2aFi9erIkTJ6qgoEBTpkwx282YMUN/+9vfNHjwYOXn5+u9997T9ddfr4ULF2rgwIFmu8mTJ2vSpEm6+OKLNWXKFNntdq1fv17Lly9Xv379zHadOnXSfffd51HLm2++qaSkpBI1rlq1Su+//77uvfdeORwOvfTSS+rfv7+++eYbnXfeeZKktLQ0devWzfwgoGHDhvriiy80fPhwZWZmavTo0aWe/6xZs8zwPH78+BL7ly9frgEDBqhz586aOHGirFar+WHKmjVrdNFFF5V4TPfu3c33608//aQnnnjCY/9bb72lIUOGKCEhQU899ZSys7M1a9YsXXrppdq0aVOJ4FtZDz74YKnbx40bp9mzZ2v48OG65JJLZLPZ9PHHH2vBggVV8rylKSgoMMPfiYYPH665c+dqwIABuuOOO1RQUKA1a9Zo3bp16tKli9566y2z7Zo1a/Tyyy9r+vTpatCggSQpOjpakpSTk6NevXrp119/1ahRoxQXF6f58+fr9ttvV3p6uv75z3+WWd+vv/6qV155pcLn4w81BwQE6O2339aYMWPMbXPmzFFQUFCJvz0V/VtalX+/S1PWexYAymQAAE5qzpw5hiRjw4YNFWq3a9cuwzAMIzc312jatKkxYMAAQ5IxZ84cs22PHj2M8PBw4/fff/c4hsvlKvXYzZo1M4YMGVJie35+vhEVFWWcd955Rk5Ojrl94cKFhiRjwoQJ5rYhQ4YYoaGh5Z5Ds2bNDEnGRx99ZG7LyMgwGjVqZJx//vnmttzcXKOwsNDjsbt27TIcDocxZcoUc9uKFSsMScZNN91k1K9f38jLyzP3tWrVyrj55psNScb8+fNL1HnVVVcZo0aNMrevWbPGCA4ONq655poS55GdnV3iXBISEoyzzz673PN1P58k45577jG3uVwuY+DAgYbdbjf2799f5vPk5+cb5513ntG7d29z244dOwyr1Wpce+21JV6j4r/fZs2aGQMHDixRT2JionHi/6IlGZKMb7/91tz2+++/G0FBQca1115rbhs+fLjRqFEj48CBAx6Pv/HGG43IyMgS9f/rX/8yJHm0P/fcc42ePXt61NyqVSs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
"<Figure size 1200x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Гистограмма распределения чистой стоимости\n",
|
|||
|
"plt.figure(figsize=(12, 6))\n",
|
|||
|
"sns.histplot(df2['Networth'], bins=10, kde=True)\n",
|
|||
|
"plt.title('Гистограмма распределения чистой стоимости')\n",
|
|||
|
"plt.xlabel('Чистая стоимость (в миллиардах долларов)')\n",
|
|||
|
"plt.ylabel('Частота')\n",
|
|||
|
"plt.grid(True)\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Распределение чистой стоимости показало сильно смещённый характер. Основная масса значений сосредоточена в нижней части диапазона, с небольшим количеством высоких значений. Это указывает на наличие значительного количества людей с относительно низкой чистой стоимостью, в то время как несколько индивидуумов (например, миллиардеры) имеют очень высокую чистую стоимость. "
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Оценка качества данных**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Для оценки покрытия мы смотрим на то, насколько разнообразны данные по странам, отраслям и возрастам."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 73,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABAwAAAKICAYAAAD0EmiCAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACX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zp2l4w4YNJW/evMmep8VikalTp5rGFS5c+KFtAgCeT/QwAAAky6lTp6Ru3bri7OwsGzZskOzZs5ummT9/vnTq1EnKlSsn48ePl8uXL8vHH38sv/76qxw4cEA8PDxMz2nWrJk0b95cRER+/vln+fTTTx9Zx61bt2T8+PHJXo579+5J9erV5cKFC/LGG29I7ty5ZceOHTJkyBC5dOmSzYFRly5dZP78+VKvXj15/fXXJTY2Vn7++WfZtWuXlC1bVr766itjWmvtU6ZMkWzZsomIiI+Pj03b7777rhQpUkTu378v3377rbz77rvi7e0tXbp0ERGRI0eOSNWqVcXNzU0GDhwojo6OMmfOHKlRo4b89NNPUqFChSQvZ8La+vbt+8hpf/75Z6lfv77kyZNHRowYITExMTJz5kypXLmy7NmzRwoWLGh6Ts6cOY3X4c6dO9K9e3fTNGPHjpVhw4ZJq1at5PXXX5erV6/KJ598ItWqVXvo9mA1aNCgJC6puR6rtWvXyuLFi22GjRw5Ut5//30JCQmR7t27y4kTJ2TWrFmyZ88e+fXXX8XR0fGhbVy8eFHKly8vt27dkm7duknhwoXlwoULsnTpUrl3755Uq1bNZr2PHTtWRETee+89Y1ilSpWMv+Pi4qRu3bpSsWJFmTRpkqxfv15GjBghsbGxMmrUKGO6jz/+WBo3bixt27aV6Oho+eabb6Rly5ayZs0aadCgwROtp+TMM0OGDDJv3jzp06ePMWzHjh1y9uzZZLUNAEjHFACAJJo3b56KiK5Zs0bz58+vIqJ16tRJdNro6Gj19vbWYsWK6f37943ha9asURHR4cOH20wfExOjIqLvv/++qb3Tp08bw0RER4wYYfw/cOBA9fb21qCgIK1evbox/P3331cR0fj4eJt28uTJox06dDD+Hz16tLq4uOiff/5pM93gwYPV3t5ez507p6qqW7duVRHRt99+27Ss/27jYbVbbdu2TUVEt23bZgyLjIxUOzs7feutt4xhTZs2VScnJz116pQx7OLFi+rq6qrVqlUzzTcx7733nlosFpth/14H/641KChI3d3dNSwszJjmzz//VEdHR23RooWpjUqVKmmxYsWM/69evWp6nc6cOaP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r+L1y4UI4cOSLfffedLFq0KCmLkWQP20adnJzE39//kV3sr169KhEREVKsWLEUq8fOzs4mHBIR4/KPhPddWLNmjYwZM0YOHjwoUVFRxvDEQoq5c+fK3LlzTcPz5Mlj8/+TzFNEpFOnTtKpUyf58MMPZcmSJZIlSxYj7AIAvDgIDAAAT2zy5MnSsmVLERH59NNPpWLFijJkyBCZOXNmsucZFhYmIiK+vr5Jmv7YsWMyf/58+frrrxM92CxZsqSMGDFC3n//fVm4cOFD5xMfHy8vvfSSDBw4MNHxiV2vn1I++OADKVmypMTExMiePXtkzJgx4uDgkGgvhuQKCwtL8jr9+uuv5d69e9KtW7ckzz86OlouXbokL7300iOni4+PF4vFIuvWrUv0ZzcTCzWio6Nl2LBh0qVLl2f6OjxPfv75Z2ncuLFUq1ZNZs6cKdmzZxdHR0eZN29eooFKkyZNTDchHDp0qPF+S848RR70FHJycpKVK1fKvHnzpEOHDja9NAAALwYCAwDAE6tWrZrxd7ly5aRHjx4yY8YMad++vVSsWFFE/ncG88SJE6YzjydOnDCd4Tx69KiIPDiLnRRDhgyRUqV
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1200x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABAsAAAKpCAYAAADaPqVoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3QU5fv38WspCSUFQkmhhNAJndBCLyGU0ItKERCkSUeKEekiUgTpWCgq8EWpItJBQWlCAGlKR2roJKElhL2eP3h2fhkSiiFkk/h+nbPnJDOzM9fszpb57D33bVFVFQAAAAAAgP8vlb0LAAAAAAAASQthAQAAAAAAMCEsAA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FD6IiHHZR8y+FtasWSMff/yxHDx4UCIjI43pMUOA06dPS6pUqcTX1/eF232Z11+hQoUkc+bM8tlnn4mvr69xGcKjR4/iXD5t2rTSrl07mTdvnrRs2VLmzZsnLVq0EBcXlxfWAwBImggLAADPNXHiRGnVqpWIPLmuuWLFihIcHCyzZs2K9zpDQ0NFRMTDw+Ollv/rr79kwYIFsnDhwjhPNEuWLCkjRoyQUaNGyaJFi565HqvVKnXq1JHBgwfHOT+u6/MTyqRJk6RkyZLy6NEj2bt3r3z88ceSJk2aOFsvxFdoaOhLP6YLFy6U+/fvS9euXV96/VFRUXLlyhWpU6fOc5ezWq1isVhk3bp1cQ6tGddJalRUlAwbNkw6d+78Wp+H5Oa3336Txo0bS7Vq1WTWrFni6ek
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1200x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1IAAAHWCAYAAAB9mLjgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB8xElEQVR4nOzdd3wUdeLG8c/upvfeCxAghI4gGLGLAqKiYIFDxe6d4Nl+Fs6zn/3O3nvD3lA8QAQBkV5CDS2UAOm9t935/RHJGakJm0zK83699iWZnf3Os+NC8mRmvmMxDMNAREREREREjpnV7AAiIiIiIiLtjYqUiIiIiIhIE6lIiYiIiIiINJGKlIiIiIiISBOpSImIiIiIiDSRipSIiIiIiEgTqUiJiIiIiIg0kYqUiIiIiIhIE6lIiYiIiIiINJGKlIiIiIiISBOpSImItKD3338fi8XS8PDw8KBnz55MnTqV7Oxss+OJiIhIM7mYHUBEpDN45JFH6Nq1K1VVVSxevJjXXnuN//73v2zcuBEvLy+z44mIiEgTqUiJiLSC0aNHM2TIEACuv/56goODefbZZ5kxYwYTJ040OZ2IiIg0lU7tExExwVlnnQXArl27ACgoKOD//u//6NevHz4+Pvj5+TF69GjWrVt30Gurqqp46KGH6NmzJx4eHkRGRjJu3DjS0tIA2L17d6PTCf/8OOOMMxrGWrBgARaLhc8//5x//OMfRERE4O3tzYUXXsjevXsP2vby5csZNWoU/v7+eHl5cfrpp/Pbb78d8j2eccYZh9z+Qw89dNC6H3/8MYMHD8bT05OgoCAmTJhwyO0f6b39kcPh4Pnnn6dPnz54eHgQHh7OTTfdRGFhYaP1unTpwvnnn3/QdqZOnXrQmIfK/swzzxy0TwGqq6t58MEH6d69O+7u7sTGxnL33XdTXV19yH31R3/ebyEhIYwZM4aNGzc2Wq+uro5HH32UhIQE3N3d6dKlC//4xz8O2sbYsWPp0qULHh4ehIWFceGFF7Jhw4aD3tvUqVOZPn06iYmJeHh4MHjwYBYtWtRovT179nDzzTeTmJiIp6cnwcHBXHrppezevfug91FUVMTtt99Oly5dcHd3JyYmhquuuoq8vLyGz92RHgf2dVO2KSLSmnRESkTEBAdKT3BwMAA7d+7ku+++49JLL6Vr165kZ2fzxhtvcPrpp7N582aioqIAsNvtnH/++cybN48JEyZw6623Ulpayty5c9m4cSMJCQkN25g4cSLnnXdeo+1OmzbtkHkee+wxLBYL99xzDzk5OTz//POMGDGClJQUPD09AZg/fz6jR49m8ODBPPjgg1itVt577z3OOussfv31V4YOHXrQuDExMTzxxBMAlJWV8be//e2Q277//vu57LLLuP7668nNzeWll17itNNOY+3atQQEBBz0mhtvvJFTTz0VgG+++YZvv/220fM33XQT77//Ptdccw1///vf2bVrFy+//DJr167lt99+w9XV9ZD7oSmKiooa3tsfORwOLrzwQhYvXsyNN95IUlISGzZs4LnnnmPbtm189913Rx27V69e3HfffRiGQVpaGs8++yznnXce6enpDetcf/31fPDBB1xyySXceeedLF++nCeeeILU1NSD9seNN95IREQEGRkZvPzyy4wYMYJdu3Y1Oq104cKFfP755/z973/H3d2dV199lVGjRrFixQr69u0LwMqVK1myZAkTJkwgJiaG3bt389prr3HGGWewefPmhvHKyso49dRTSU1N5dprr+WEE04gLy+P77//nn379pGUlMRHH33UsO0333yT1NRUnnvuuYZl/fv3b9I2RURanSEiIi3mvffeMwDj559/NnJzc429e/can332mREcHGx4enoa+/btMwzDMKqqqgy73d7otbt27TLc3d2NRx55pGHZu+++awDGs88+e9C2HA5Hw+sA45lnnjlonT59+hinn356w9e//PKLARjR0dFGSUlJw/IvvvjCAIwXXnihYewePXoYI0eObNiOYRhGRUWF0bVrV+Occ845aFsnn3yy0bdv34avc3NzDcB48MEHG5bt3r3bsNlsxmOPPdbotRs2bDBcXFwOWr59+3YDMD744IOGZQ8++KDxx29nv/76qwEY06dPb/Ta2bNnH7Q8Pj7eGDNmzEHZp0yZYvz5W+Sfs999991GWFiYMXjw4Eb79KOPPjKsVqvx66+/Nnr966+/bgDGb7/9dtD2/uj0009vNJ5hGMY//vEPAzBycnIMwzCMlJQUAzCuv/76Ruv93//9nwEY8+fPP+z4B/7frlq1qtF7+/OyPXv2GB4eHsbFF1/csKyiouKg8ZYuXWoAxocfftiw7IEHHjAA45tvvjlo/T9+fg6YPHmyER8ff8i8x7pNEZHWplP7RERawYgRIwgNDSU2NpYJEybg4+PDt99+S3R0NADu7u5YrfX/JNvtdvLz8/Hx8SExMZE1a9Y0jPP1118TEhLCLbfcctA2/nwqWlNcddVV+Pr6Nnx9ySWXEBkZyX//+18AUlJS2L59O3/5y1/Iz88nLy+PvLw8ysvLOfvss1m0aBEOh6PRmFVVVXh4eBxxu9988w0Oh4PLLrusYcy8vDwiIiLo0aMHv/zyS6P1a2pqgPr9dThffvkl/v7+nHPOOY3GHDx4MD4+PgeNWVtb22i9vLw8qqqqjph7//79vPTSS9x///34+PgctP2kpCR69erVaMwDp3P+efuHciBTbm4uS5cu5dtvv6V///6EhIQANPx/ueOOOxq97s477wTgxx9/bLS8oqKCvLw8UlJSeOuttwgPD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Xl4N5fOrr75i8uTJDSUP6k/hPHCk8I/74M+zDDbXsW5TRKS16RopEZE2wGazNTplCeqvtdm/f3+jZePHjycvL4+XX375oDH+/Pqm+PDDDyktLW34+quvviIzM5PRo0cDMHjwYBISEvj3v/9
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x500 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# 1. Столбчатая диаграмма по странам\n",
|
|||
|
"plt.figure(figsize=(12, 6))\n",
|
|||
|
"sns.countplot(data=df2, x='Country', order=df2['Country'].value_counts().index)\n",
|
|||
|
"plt.title('Количество людей по странам')\n",
|
|||
|
"plt.xlabel('Страна')\n",
|
|||
|
"plt.ylabel('Количество')\n",
|
|||
|
"plt.xticks(rotation=45)\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n",
|
|||
|
"# 2. Столбчатая диаграмма по отраслям\n",
|
|||
|
"plt.figure(figsize=(12, 6))\n",
|
|||
|
"sns.countplot(data=df2, x='Industry', order=df2['Industry'].value_counts().index)\n",
|
|||
|
"plt.title('Количество людей по отраслям')\n",
|
|||
|
"plt.xlabel('Отрасль')\n",
|
|||
|
"plt.ylabel('Количество')\n",
|
|||
|
"plt.xticks(rotation=45)\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n",
|
|||
|
"# 3. Гистограмма для анализа возраста\n",
|
|||
|
"plt.figure(figsize=(10, 5))\n",
|
|||
|
"sns.histplot(df2['Age'], bins=30, kde=True)\n",
|
|||
|
"plt.title('Распределение возраста')\n",
|
|||
|
"plt.xlabel('Возраст')\n",
|
|||
|
"plt.ylabel('Частота')\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Графики показывают широкий спектр стран и отраслей, представленных в наборе данных. Это свидетельствует о том, что данные охватывают множество регионов и различных сфер деятельности.\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Устранение проблемы пропущенных данных**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 76,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Пропущенные значения в данных:\n",
|
|||
|
" Rank 0\n",
|
|||
|
"Name 0\n",
|
|||
|
"Networth 0\n",
|
|||
|
"Age 0\n",
|
|||
|
"Country 0\n",
|
|||
|
"Source 0\n",
|
|||
|
"Industry 0\n",
|
|||
|
"dtype: int64\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"missing_values = df2.isnull().sum()\n",
|
|||
|
"print(\"Пропущенные значения в данных:\\n\", missing_values)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Пропущенных данных не найдено."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Разбиение набора данных на обучающую, контрольную и тестовую выборки**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 78,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"((1560, 6), (520, 6), (520, 6))"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 78,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"from sklearn.model_selection import train_test_split\n",
|
|||
|
"\n",
|
|||
|
"# Разделим набор данных на признаки (X) и целевой признак (y)\n",
|
|||
|
"X = df2.drop(columns=['Networth'])\n",
|
|||
|
"y = df2['Networth']\n",
|
|||
|
"\n",
|
|||
|
"# Разделение на обучающую, контрольную и тестовую выборки\n",
|
|||
|
"X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.4, random_state=42)\n",
|
|||
|
"X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5, random_state=42)\n",
|
|||
|
"\n",
|
|||
|
"# Проверка размера выборок\n",
|
|||
|
"(X_train.shape, X_val.shape, X_test.shape)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Оценка сбалансированности выборок**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 79,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"(count 1560.000000\n",
|
|||
|
" mean 5.208173\n",
|
|||
|
" std 12.653032\n",
|
|||
|
" min 1.000000\n",
|
|||
|
" 25% 1.500000\n",
|
|||
|
" 50% 2.400000\n",
|
|||
|
" 75% 4.300000\n",
|
|||
|
" max 219.000000\n",
|
|||
|
" Name: Networth, dtype: float64,\n",
|
|||
|
" count 520.000000\n",
|
|||
|
" mean 4.443654\n",
|
|||
|
" std 7.267615\n",
|
|||
|
" min 1.000000\n",
|
|||
|
" 25% 1.500000\n",
|
|||
|
" 50% 2.400000\n",
|
|||
|
" 75% 4.825000\n",
|
|||
|
" max 91.400000\n",
|
|||
|
" Name: Networth, dtype: float64,\n",
|
|||
|
" count 520.000000\n",
|
|||
|
" mean 4.235577\n",
|
|||
|
" std 5.861496\n",
|
|||
|
" min 1.000000\n",
|
|||
|
" 25% 1.600000\n",
|
|||
|
" 50% 2.500000\n",
|
|||
|
" 75% 4.500000\n",
|
|||
|
" max 60.000000\n",
|
|||
|
" Name: Networth, dtype: float64)"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 79,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Проверка распределения целевого признака по выборкам\n",
|
|||
|
"train_dist = y_train.describe()\n",
|
|||
|
"val_dist = y_val.describe()\n",
|
|||
|
"test_dist = y_test.describe()\n",
|
|||
|
"\n",
|
|||
|
"train_dist, val_dist, test_dist"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 85,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Размеры после oversampling: (13910, 10047) (13910,)\n",
|
|||
|
"Размеры после undersampling: (13065, 10047) (13065,)\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"from imblearn.over_sampling import RandomOverSampler\n",
|
|||
|
"oversampler = RandomOverSampler(random_state=12)\n",
|
|||
|
"X_train_over, y_train_over = oversampler.fit_resample(X_train, y_train)\n",
|
|||
|
"\n",
|
|||
|
"undersampler = RandomUnderSampler(random_state=12)\n",
|
|||
|
"X_train_under, y_train_under = undersampler.fit_resample(X_train, y_train)\n",
|
|||
|
"\n",
|
|||
|
"print(\"Размеры после oversampling:\", X_train_over.shape, y_train_over.shape)\n",
|
|||
|
"print(\"Размеры после undersampling:\", X_train_under.shape, y_train_under.shape)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **3. Pima Indians Diabetes Database**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"##### **Проблемная область**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Проблемная область: Набор данных касается предсказания наличия диабета у пациентов на основе различных медицинских измерений, таких как уровень глюкозы, артериальное давление, толщина кожи, уровень инсулина и другие параметры."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 86,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"<bound method DataFrame.info of 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",
|
|||
|
"763 10 101 76 48 180 32.9 \n",
|
|||
|
"764 2 122 70 27 0 36.8 \n",
|
|||
|
"765 5 121 72 23 112 26.2 \n",
|
|||
|
"766 1 126 60 0 0 30.1 \n",
|
|||
|
"767 1 93 70 31 0 30.4 \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 \n",
|
|||
|
".. ... ... ... \n",
|
|||
|
"763 0.171 63 0 \n",
|
|||
|
"764 0.340 27 0 \n",
|
|||
|
"765 0.245 30 0 \n",
|
|||
|
"766 0.349 47 1 \n",
|
|||
|
"767 0.315 23 0 \n",
|
|||
|
"\n",
|
|||
|
"[768 rows x 9 columns]> \n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"df3 = pd.read_csv(\".//static//csv//diabetes.csv\")\n",
|
|||
|
"print(df3.info, \"\\n\")"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Объекты наблюдения**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Объектами наблюдения являются пациенты"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Атрибуты объектов**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 88,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Pregnancies\n",
|
|||
|
"Glucose\n",
|
|||
|
"BloodPressure\n",
|
|||
|
"SkinThickness\n",
|
|||
|
"Insulin\n",
|
|||
|
"BMI\n",
|
|||
|
"DiabetesPedigreeFunction\n",
|
|||
|
"Age\n",
|
|||
|
"Outcome\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"attributes = df3.columns\n",
|
|||
|
"for attribute in attributes:\n",
|
|||
|
" print(attribute)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Связи между объектами**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 108,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|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WyZzvc4XnGTx4MNOgQQNJemZmJqOvr88MGTKEAcDcuXNHUlZOTk6Mt7c3IxaLJfmzsrIYBwcHplOnTlLHz8zMZNzd3Zn69eszqampknK5fPkyk5KSwtSrV49p2rQpk5WVJTe+li1bMi4uLpLn8fHxDAAmICBAkpaSksLw+Xzm559/ltp32rRpjI6ODpORkVFiGcg794QJExhtbW2p10khea+BzwFgADB3796VpL17947h8/lMnz59JGkBAQHM5x8DcXFxjJ6enuRvfPnyZYZhil5LJiYmTEJCgiT/y5cvGS6Xy/Tt21eS5u/vz/B4PCYlJUXquBoaGlJl9mW8xW1TtGwKX9uurq7M8uXLJel79uxhbGxsmDZt2ki99uWV4YABAxgXFxfG1taWGTlypNx4ynt/ee+P+vXrM56enpLn+fn5jFAolMqTnJzMmJubM6NHj5bZf86cOQyLxZJKs7Ozk4pJ0b89wzAMi8WS+lxkGNnPB3nn+Ouvvxgej8e0b9+esbOzk6Rfv36dAcDs27dP6phnz56VSbezs2M6derEmJiYMEeOHJGkL1q0iGnZsiVjZ2fHdOvWTaYM5Dl//jwDQOo4kydPliqHspaNvNdnYGAgw2KxmHfv3jEMU/S31tTUZF6+fCnJFx8fzxgbGzNNmjSRui4dHR2pfAzDMLNnz2Y4HA7z/v17mfN9Ge/ncnJyGJFIJJUWGRnJ8Hg8ZuHChXL3IeqjynWnjho1ClFRURgyZAjOnz8v+SX0ubt37yIuLg6TJk2S+hXXrVs3ODs7IygoSGafKVOmSP5f2FWVm5uLixcvSuXr3bs3rK2tJc+bNWuG5s2
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 800x600 with 2 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Создаем матрицу корреляций\n",
|
|||
|
"correlation_matrix = df3[['Glucose', 'Insulin', 'BMI', 'SkinThickness','Age', 'Outcome']].corr()\n",
|
|||
|
"\n",
|
|||
|
"# Строим тепловую карту для визуализации корреляций\n",
|
|||
|
"plt.figure(figsize=(8, 6))\n",
|
|||
|
"sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', fmt=\".2f\")\n",
|
|||
|
"plt.title('Корреляция между атрибутами и наличием диабета')\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Тепловая карта показывает, что существует значительная положительная корреляция между уровнем глюкозы и наличием диабета, что свидетельствует о важности уровня глюкозы в определении риска заболевания. Также наблюдается положительная связь между индексом массы тела (BMI) и наличием диабета, что подтверждает влияние лишнего веса на вероятность развития диабета. Корреляция между инсулином и наличием диабета также присутствует, но менее выражена, что указывает на необходимость более глубокого анализа этих данных для определения их значимости."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"#### **Бизнес-цели:**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Улучшение ранней диагностики диабета:\n",
|
|||
|
"\n",
|
|||
|
"Эффект для бизнеса: Помогает медицинским учреждениям выявлять пациентов с риском диабета, что позволяет быстрее начинать лечение и снижать затраты на позднюю диагностику.\n",
|
|||
|
"Разработка персонализированных планов лечения:\n",
|
|||
|
"\n",
|
|||
|
"Эффект для бизнеса: Медицинские компании могут предлагать персонализированные планы лечения и диеты для пациентов на основе их предрасположенности к диабету."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Цели технического проекта**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Ранняя диагностика диабета\n",
|
|||
|
"\n",
|
|||
|
"Входные данные: Параметры здоровья пациента, такие как уровень глюкозы, артериальное давление, BMI и другие.\n",
|
|||
|
"Целевой признак: Outcome (наличие диабета).\n",
|
|||
|
"Персонализированные рекомендации\n",
|
|||
|
"\n",
|
|||
|
"Входные данные: Исторические данные пациента, его возраст, индекс массы тела, уровень инсулина и т.д.\n",
|
|||
|
"Целевой признак: Разработанные рекомендации или предсказание необходимости изменений в лечении."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Проблемы данных**\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 92,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Пропущенные значения в данных:\n",
|
|||
|
" Pregnancies 0\n",
|
|||
|
"Glucose 0\n",
|
|||
|
"BloodPressure 0\n",
|
|||
|
"SkinThickness 0\n",
|
|||
|
"Insulin 0\n",
|
|||
|
"BMI 0\n",
|
|||
|
"DiabetesPedigreeFunction 0\n",
|
|||
|
"Age 0\n",
|
|||
|
"Outcome 0\n",
|
|||
|
"dtype: int64\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Проверяем пропущенные значения снова\n",
|
|||
|
"missing_values = df3.isnull().sum()\n",
|
|||
|
"print(\"Пропущенные значения в данных:\\n\", missing_values)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"пропущенные данные отсутсвуют"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 95,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Количество выбросов в столбце 'Pregnancies': 4\n",
|
|||
|
"Количество выбросов в столбце 'Glucose': 5\n",
|
|||
|
"Количество выбросов в столбце 'BloodPressure': 45\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABdIAAAISCAYAAADIuT2dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAD2s0lEQVR4nOzdeXxU9fX/8ffMJJnsCdkTCBC2sC8CIqKIiiKIlYq1tC5oVdqKti61La24oBV3Ub9Ua9uf0lZqa6tUUUFAcUUQFGTfZM2+kH2dmfv7YzIjEQghZHJnMq/n4zEPzb137pyZSfjce+6552MxDMMQAAAAAAAAAAA4LqvZAQAAAAAAAAAA4M9IpAMAAAAAAAAA0AIS6QAAAAAAAAAAtIBEOgAAAAAAAAAALSCRDgAAAAAAAABAC0ikAwAAAAAAAADQAhLpAAAAAAAAAAC0gEQ6AAAAAAAAAAAtIJEOAAAAAAAAAEALSKSjU+rZs6euv/56s8Po9B5//HH16tVLNptNw4cPNzucTmX16tWyWCxavXq12aEAQEDiWKBj+PJYYMKECZowYUK77hMAcHoYXzuGL8ZXM88x77//flkslg5/XaC9kUiH33v55ZdlsVi0fv36466fMGGCBg8efNqv88477+j+++8/7f0Ei/fee0+//vWvNW7cOL300kt6+OGHT7jt9ddfL4vF4n3ExsZq2LBhevLJJ1VfX9+BUQMAAhHHAv7pVI4FPD7++GNdddVV6tq1q8LCwhQXF6cxY8Zo3rx5Kigo6ICoAQAejK/+6XTOtUNCQpSZmakZM2Zo27ZtHRj1qevZs2ez2FNSUnTuuefqjTfeMDs04IRCzA4A8IWdO3fKaj2160TvvPOOFi5cyADfSu+//76sVqv++te/Kiws7KTb2+12/eUvf5EklZWV6b///a9+9atf6YsvvtCrr77q63ADzvjx41VbW9uqzxYAcCyOBXzvVI8F7r33Xj344IPq1auXrr/+evXq1Ut1dXXasGGDnnzySS1atEh79+7tgMgBAG3F+Op7p3Ou7XA4tHfvXr3wwgtatmyZtm3bpoyMDF+H3GbDhw/XXXfdJUnKzc3Vn/70J11xxRV6/vnn9bOf/czk6IBjkUhHp2S3280O4ZRVV1crKirK7DBarbCwUBEREa1O9IaEhOiaa67x/nzLLbdozJgx+te//qWnnnrquIO7YRiqq6tTREREu8UdKKxWq8LDw80OAwACFscCvncqxwL/+te/9OCDD+qqq67S3//+92Oe8/TTT+vpp5/2VagAgHbC+Op7p3uuLUlnnXWWpk6dqrfffls333yzL8JsF127dm0W+3XXXac+ffro6aefPmEi3eFwyOVyBVTRWaD9DuLEaO2CTum7fdsaGxv1wAMPqG/fvgoPD1diYqLOOeccrVixQpL7dqiFCxdKUrNbizyqq6t11113KTMzU3a7XdnZ2XriiSdkGEaz162trdUvfvELJSUlKSYmRt/73veUk5Mji8XS7Oq7pz/Ytm3b9OMf/1hdunTROeecI0n6+uuvvVVa4eHhSktL009+8hOVlJQ0ey3PPnbt2qVrrrlGcXFxSk5O1ty5c2UYhg4dOqTLL79csbGxSktL05NPPtmqz87hcOjBBx9U7969Zbfb1bNnT/3ud79r1oLFYrHopZdeUnV1tfezevnll1u1fw+r1erte7p//35J7u9t6tSpWr58uUaNGqWIiAj96U9/kuSuYr/99tu930GfPn306KOPyuVyNdtvSUmJrr32WsXGxio+Pl4zZ87Upk2bjonx+uuvV3R0tHJycjRt2jRFR0crOTlZv/rVr+R0Opvt84knntDZZ5+txMRERUREaOTIkfrPf/5zzHuyWCy69dZbtWTJEg0ePFh2u12DBg3SsmXLjtk2JydHN954ozIyMmS325WVlaWf//znamhokHTi/nVr167VJZdcori4OEVGRuq8887Tp59+2mybyspK3X777erZs6fsdrtSUlJ00UUX6csvvzzp9wIAnQXHAv51LHDvvfcqKSnphNV1cXFxJ61U9LQg8Bw3eLQ0Zk6ZMkVdunRRVFSUhg4dqmeeeabZNu+//77OPfdcRUVFKT4+Xpdffrm2b9/ebJvWjqutGaMBINAxvvrX+HoiaWlpktxJ9pN57bXXNHLkSEVERCgpKUnXXHONcnJyjtmuNWOmJH3yyScaPXq0wsPD1bt3b+85fWvjHjBggPbt2yfJnSuwWCx64okntGDBAu9n52lbs2PHDl155ZVKSEhQeHi4Ro0apTfffLPZPk/2OypJ+fn5uuGGG9StWzfZ7Xalp6fr8ssvb3bM8d3fNY/v/k14jlc+/PBD3XLLLUpJSVG3bt286999913v5xgTE6NLL71UW7dubfVnBHNRkY6AUV5eruLi4mOWNzY2nvS5999/v+bPn6+bbrpJZ555pioqKrR+/Xp9+eWXuuiii/TTn/5Uubm5WrFihf7+9783e65hGPre976nDz74QDfeeKOGDx+u5cuX6+6771ZOTk6z6qnrr79e//73v3XttdfqrLPO0ocffqhLL730hHH94Ac/UN++ffXwww97DxRWrFihb775RjfccIPS0tK0detWvfjii9q6das+//zzYybo+OEPf6gBAwbokUce0dtvv62HHnpICQkJ+tOf/qQLLrhAjz76qF555RX96le/0ujRozV+/PgWP6ubbrpJixYt0pVXXqm77rpLa9eu1fz587V9+3Zvr7K///3vevHFF7Vu3TrvLWRnn332Sb+H7/Lcvp2YmOhdtnPnTv3oRz/ST3/6U918883Kzs5WTU2NzjvvPOXk5OinP/2punfvrs8++0xz5sxRXl6eFixYIElyuVy67LLLtG7dOv385z9X//799b///U8zZ8487us7nU5NmjRJY8aM0RNPPKGVK1fqySefVO/evfXzn//cu90zzzyj733ve7r66qvV0NCgV199VT/4wQ+0dOnSY77fTz75RK+//rpuueUWxcTE6Nlnn9X06dN18OBB7/vMzc3VmWeeqbKyMs2aNUv9+/dXTk6O/vOf/6impuaEV9bff/99TZ48WSNHjtR9990nq9Wql156SRdccIE+/vhjnXnmmZKkn/3sZ/rPf/6jW2+9VQMHDlRJSYk++eQTbd++XWecccYpf08A4C84FgjMY4Fdu3Zp165duummmxQdHd3ia7eXFStWaOrUqUpPT9cvf/lLpaWlafv27Vq6dKl++ctfSpJWrlypyZMnq1evXrr//vtVW1ur5557TuPGjdOXX36pnj17SmrduNraMRoA/BHja2COr0fzfH9Op1PffPONfvOb3ygxMVFTp05t8Xkvv/yybrjhBo0ePVrz589XQUGBnnnmGX366af66quvFB8fL6n1Y+bmzZt18cUXKzk5Wffff78cDofuu+8+paamnvQ9SO7fuUOHDjXLEUjSSy+9pLq6Os2aNUt2u10JCQnaunWrxo0bp65du+q3v/2toqKi9O9//1vTpk3Tf//7X33/+9+XdPLfUUmaPn26tm7dqttuu009e/ZUYWGhVqxYoYMHD3rf26m65ZZblJycrHvvvVfV1dWS3N/vzJkzNWnSJD366KOqqanR888/r3POOUdfffVVm18LHcgA/NxLL71kSGrxMWjQoGbP6dGjhzFz5kzvz8OGDTMuvfTSFl9n9uzZxvH+JJYsWWJIMh566KFmy6+88krDYrEYe/bsMQzDMDZs2GBIMm6//fZm211//fWGJOO+++7zLrvvvvsMScaPfvSjY16vpqbmmGX//Oc/DUnGRx99dMw+Zs2a5V3mcDiMbt26GRaLxXjkkUe8y48cOWJEREQ0+0yOZ+PGjYYk46abbmq2/Fe/+pUhyXj//fe9y2bOnGlERUW1uL/vbltUVGQUFRUZe/bsMR5++GHDYrEYQ4cO9W7Xo0cPQ5KxbNmyZs9/8MEHjaioKGPXrl3Nlv/2t781bDabcfDgQcMwDOO///2vIclYsGCBdxun02lccMEFhiTjpZdeahaTJGPevHnN9jlixAhj5MiRzZZ99ztpaGgwBg8ebFxwwQX
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1500x1000 with 3 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"\n",
|
|||
|
"# Выбираем числовые столбцы\n",
|
|||
|
"numeric_columns = ['Pregnancies', 'Glucose', 'BloodPressure']\n",
|
|||
|
"\n",
|
|||
|
"# Выбираем столбцы для анализа\n",
|
|||
|
"columns_to_check = ['Pregnancies', 'Glucose', 'BloodPressure']\n",
|
|||
|
"\n",
|
|||
|
"# Функция для подсчета выбросов\n",
|
|||
|
"def count_outliers(df3, columns):\n",
|
|||
|
" outliers_count = {}\n",
|
|||
|
" for col in columns:\n",
|
|||
|
" Q1 = df3[col].quantile(0.25)\n",
|
|||
|
" Q3 = df3[col].quantile(0.75)\n",
|
|||
|
" IQR = Q3 - Q1\n",
|
|||
|
" lower_bound = Q1 - 1.5 * IQR\n",
|
|||
|
" upper_bound = Q3 + 1.5 * IQR\n",
|
|||
|
" \n",
|
|||
|
" # Считаем количество выбросов\n",
|
|||
|
" outliers = df3[(df3[col] < lower_bound) | (df3[col] > upper_bound)]\n",
|
|||
|
" outliers_count[col] = len(outliers)\n",
|
|||
|
" \n",
|
|||
|
" return outliers_count\n",
|
|||
|
"\n",
|
|||
|
"# Подсчитываем выбросы\n",
|
|||
|
"outliers_count = count_outliers(df3, columns_to_check)\n",
|
|||
|
"\n",
|
|||
|
"# Выводим количество выбросов для каждого столбца\n",
|
|||
|
"for col, count in outliers_count.items():\n",
|
|||
|
" print(f\"Количество выбросов в столбце '{col}': {count}\")\n",
|
|||
|
" \n",
|
|||
|
"# Создаем гистограммы\n",
|
|||
|
"plt.figure(figsize=(15, 10))\n",
|
|||
|
"for i, col in enumerate(numeric_columns, 1):\n",
|
|||
|
" plt.subplot(2, 3, i)\n",
|
|||
|
" sns.histplot(df3[col], kde=True)\n",
|
|||
|
" plt.title(f'Histogram of {col}')\n",
|
|||
|
"plt.tight_layout()\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Устраним выбрасы в столбце BloodPressure"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 98,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Количество удаленных строк: 45\n",
|
|||
|
"Количество выбросов в столбце 'BloodPressure': 4\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABdEAAAJOCAYAAABYwk4SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACuhUlEQVR4nOzdd3hUdd7+8XtaJr33Sgu9hiaCoqIiTRAsKKyI9Xl0167PuuraC7bFXnZd7BURdRUsgB3pndBLeu89mTm/P7LkZ4QohJCT8n5dVy6dM2fO3JNMSObOdz7HYhiGIQAAAAAAAAAAcBir2QEAAAAAAAAAAGirKNEBAAAAAAAAAGgCJToAAAAAAAAAAE2gRAcAAAAAAAAAoAmU6AAAAAAAAAAANIESHQAAAAAAAACAJlCiAwAAAAAAAADQBEp0AAAAAAAAAACaQIkOAAAAAAAAAEATKNEBAADaqS5duuiyyy4zO0aH9/jjj6tbt26y2WwaPHhwixzz22+/lcVi0bffftsixzsW9957rywWS6vfb2eRmpoqT09P/fTTT826/YEDB2SxWPTaa6+1bDCT/Pb5Vltbq7i4OL3wwgsmpgIAADg2lOgAAABtwGuvvSaLxaK1a9ce8frTTjtN/fv3P+77+eKLL3Tvvfce93E6i6+++kq33367Ro8erQULFujhhx9uct/LLrtMFoul4cNutysuLk4zZ87U9u3bWzF1y/jt4/H399egQYP05JNPqrq62ux4bdb999+vkSNHavTo0Ydd9+2332r69OmKjIyUh4eHwsPDNWXKFC1atMiEpOZwOBy6+eab9dBDD6mqqsrsOAAAAEfFbnYAAAAANM/OnTtltR7bmogvvvhCzz//PEX6UVq+fLmsVqteffVVeXh4/OH+TqdT//rXvyR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IceekixsbHy9PTUuHHjtGfPnsPue9WqVTrnnHMUEBAgb29vjR079ogz34/l+XbWWWfpxx9/VEFBwe8+bgAAgLaAlegAAABtSHFxsfLy8g7bfjSrVO+991498sgjuvLKKzVixAiVlJRo7dq1Wr9+vc466yxdc801ysjI0Ndff60333yz0W0Nw9C5556rFStW6IorrtDgwYP15Zdf6rbbblN6err+8Y9/NOx72WWX6YMPPtCf/vQnnXTSSfruu+80adKkJnNdcMEFSkxM1MMPP9xQyH/99dfat2+f5s6dq8jISG3btk2vvPKKtm3bpl9++eWwE19edNFF6tOnjx599FF9/vnnevDBBxUcHKyXX35ZZ5xxhubNm6e3335bt956q4YPH65TTz31dz9XV155pV5//XWdf/75uuWWW7Rq1So98sgjSk5O1scffyxJevPNN/XKK69o9erVDSNNTj755D/8Ohz6+rlcLu3bt0//93//p5CQkD8sSV977TXNnTtXw4cP1yOPPKLs7Gw9/fTT+umnn7RhwwYFBgZKkr755htNmDBB3bp107333qvKyko9++yzGj16tNavX99QGG/ZskVnn322wsLCdO+996qurk733HOPIiIi/vAx/J69e/dKkkJCQhq27dy5UxdffLGuueYaXXXVVerVq5cqKio0duxYpaen65prrlF8fLx+/vln3XHHHcrMzNT8+fMl1T8XLr74Yo0bN07z5s2TJCUnJ+unn37SDTfcIOmPn9vNsWDBAlVVVenqq6+W0+lUcHCwtm3bptGjRysmJkZ//etf5ePjow8++EDTpk3TRx99pPPOO6/J49XW1mrNmjX63//930bbd+/erR07dujyyy+Xn59fs7Ieba59+/Zp8eLFuuCCC9S1a1dlZ2fr5Zdf1tixY484TujRRx+V1WrVrbfequLiYj322GOaNWuWVq1a1bDP8uXLNWHCBA0dOlT33HOPrFarFixYoDPOOEM//PCDRowYIenYn29Dhw6VYRj6+eef//B7AwAAwHQGAAAATLdgwQJD0u9+9OvXr9FtEhISjDlz5jRcHjRokDFp0qTfvZ/rrrvOONKvgIsXLzYkGQ8++GCj7eeff75hsViMPXv2GIZhGOvWrTMkGTfeeGOj/S677DJDknHPPfc0bLvnnnsMScbFF1982P1VVFQctu3dd981JBnff//9Yce4+uqrG7bV1dUZsbGxhsViMR599NGG7YWFhYaXl1ejz8mRbNy40ZBkXHnllY2233rrrYYkY/ny5Q3b5syZY/j4+Pzu8X6975G+bjExMca6desa7btixQpDkrFixQrDMAyjpqbGCA8PN/r3729UVlY27Pef//zHkGT8/e9/b9g2ePBgIzw83MjPz2/YtmnTJsNqtRqXXnppw7Zp06YZnp6exsGDBxu2bd++3bDZbEd8Dhzp8fj4+Bi5ublGbm6usWfPHuPhhx82LBaLMXDgwIb9EhISDEnG0qVLG93+gQceMHx8fIxdu3Y12v7Xv/7VsNlsRkpKimEYhnHDDTcY/v7+Rl1dXZNZjua5PXbsWGPs2LFHfBwJCQkNl/fv329IMvz9/Y2cnJxG+44bN84YMGCAUVVV1bDN7XYbJ598spGYmPi7979nzx5DkvHss8822v7JJ58Ykox//OMfv3v73+ZbsGDBMeeqqqoyXC7XYcdzOp3G/fff37Dt0POvT58+RnV1dcP2p59+2pBkbNmypeE+EhMTjfHjxxtut7thv4qKCqNr167GWWed1bDtWJ9vGRkZhiRj3rx5R/V5AQAAMBPjXAAAANqQ559/Xl9//fVhHwMHDvzD2wYGBmrbtm3avXv3Md/vF198IZvNpuuvv77R9ltuuUWGYWjJkiWSpKVLl0qqn439a3/5y1+aPPb//M//HLbt1/Oyq6qqlJeXp5NOOkmStH79+sP2v/LKKxv+32azadiwYTIMQ1dccUXD9sDAQPXq1Uv79u1rMotU/1gl6eabb260/ZZbbpEkff755797+9/j6enZ8DX78ssv9fL
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1500x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"import seaborn as sns\n",
|
|||
|
"\n",
|
|||
|
"# Выбираем столбцы для очистки\n",
|
|||
|
"columns_to_clean = ['BloodPressure']\n",
|
|||
|
"\n",
|
|||
|
"# Функция для удаления выбросов\n",
|
|||
|
"def remove_outliers(df3, columns):\n",
|
|||
|
" for col in columns:\n",
|
|||
|
" Q1 = df3[col].quantile(0.25)\n",
|
|||
|
" Q3 = df3[col].quantile(0.75)\n",
|
|||
|
" IQR = Q3 - Q1\n",
|
|||
|
" lower_bound = Q1 - 1.5 * IQR\n",
|
|||
|
" upper_bound = Q3 + 1.5 * IQR\n",
|
|||
|
" \n",
|
|||
|
" # Удаляем строки, содержащие выбросы\n",
|
|||
|
" df3 = df3[(df3[col] >= lower_bound) & (df3[col] <= upper_bound)]\n",
|
|||
|
" \n",
|
|||
|
" return df3\n",
|
|||
|
"\n",
|
|||
|
"# Удаляем выбросы\n",
|
|||
|
"df3_cleaned = remove_outliers(df3, columns_to_clean)\n",
|
|||
|
"\n",
|
|||
|
"# Выводим количество удаленных строк\n",
|
|||
|
"print(f\"Количество удаленных строк: {len(df3) - len(df3_cleaned)}\")\n",
|
|||
|
"\n",
|
|||
|
"df3 = df3_cleaned\n",
|
|||
|
"\n",
|
|||
|
"# Выбираем столбцы для анализа\n",
|
|||
|
"columns_to_check = ['BloodPressure']\n",
|
|||
|
"\n",
|
|||
|
"# Функция для подсчета выбросов\n",
|
|||
|
"def count_outliers(df3, columns):\n",
|
|||
|
" outliers_count = {}\n",
|
|||
|
" for col in columns:\n",
|
|||
|
" Q1 = df3[col].quantile(0.25)\n",
|
|||
|
" Q3 = df3[col].quantile(0.75)\n",
|
|||
|
" IQR = Q3 - Q1\n",
|
|||
|
" lower_bound = Q1 - 1.5 * IQR\n",
|
|||
|
" upper_bound = Q3 + 1.5 * IQR\n",
|
|||
|
" \n",
|
|||
|
" # Считаем количество выбросов\n",
|
|||
|
" outliers = df3[(df3[col] < lower_bound) | (df3[col] > upper_bound)]\n",
|
|||
|
" outliers_count[col] = len(outliers)\n",
|
|||
|
" \n",
|
|||
|
" return outliers_count\n",
|
|||
|
"\n",
|
|||
|
"# Подсчитываем выбросы\n",
|
|||
|
"outliers_count = count_outliers(df3, columns_to_check)\n",
|
|||
|
"\n",
|
|||
|
"# Выводим количество выбросов для каждого столбца\n",
|
|||
|
"for col, count in outliers_count.items():\n",
|
|||
|
" print(f\"Количество выбросов в столбце '{col}': {count}\")\n",
|
|||
|
"\n",
|
|||
|
"# Создаем гистограммы для очищенных данных\n",
|
|||
|
"plt.figure(figsize=(15, 6))\n",
|
|||
|
"\n",
|
|||
|
"# Гистограмма для BloodPressure\n",
|
|||
|
"sns.histplot(df3_cleaned['BloodPressure'], kde=True)\n",
|
|||
|
"plt.title('Histogram of Blood Pressure (Cleaned)')\n",
|
|||
|
"plt.xlabel('Blood Pressure')\n",
|
|||
|
"plt.ylabel('Frequency')\n",
|
|||
|
"\n",
|
|||
|
"plt.tight_layout()\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"видно, что количество выбросов сократилось."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Оценка качества данных**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Все атрибуты (например, уровень глюкозы, индекс массы тела, уровень инсулина) являются важными показателями, которые могут существенно влиять на наличие диабета. Набор данных содержит достаточное количество релевантных признаков для анализа. Чтобы определить соответствие реальным данным, необходимо провести анализ статистики для проверки, соответствуют ли значения разумным медицинским стандартам."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### **Разбиение данных на выборки**"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 104,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Размер обучающей выборки: 433\n",
|
|||
|
"Размер контрольной выборки: 145\n",
|
|||
|
"Размер тестовой выборки: 145\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"from sklearn.model_selection import train_test_split\n",
|
|||
|
"\n",
|
|||
|
"# Разделение на признаки (X) и целевую переменную (y)\n",
|
|||
|
"X = df3.drop('Outcome', axis=1) # Признаки\n",
|
|||
|
"y = df3['Outcome'] # Целевая переменная\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение на обучающую и оставшуюся часть (контрольная + тестовая)\n",
|
|||
|
"X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.4, random_state=42)\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение оставшейся части на контрольную и тестовую выборки\n",
|
|||
|
"X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5, random_state=42)\n",
|
|||
|
"\n",
|
|||
|
"# Вывод размеров выборок\n",
|
|||
|
"print(\"Размер обучающей выборки:\", X_train.shape[0])\n",
|
|||
|
"print(\"Размер контрольной выборки:\", X_val.shape[0])\n",
|
|||
|
"print(\"Размер тестовой выборки:\", X_test.shape[0])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 105,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Сбалансированность обучающей выборки:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.658199\n",
|
|||
|
"1 0.341801\n",
|
|||
|
"Name: proportion, dtype: float64\n",
|
|||
|
"\n",
|
|||
|
"Сбалансированность контрольной выборки:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.655172\n",
|
|||
|
"1 0.344828\n",
|
|||
|
"Name: proportion, dtype: float64\n",
|
|||
|
"\n",
|
|||
|
"Сбалансированность тестовой выборки:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.662069\n",
|
|||
|
"1 0.337931\n",
|
|||
|
"Name: proportion, dtype: float64\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"from sklearn.model_selection import train_test_split\n",
|
|||
|
"\n",
|
|||
|
"# Разделение на признаки (X) и целевую переменную (y)\n",
|
|||
|
"X = df3.drop('Outcome', axis=1) # Признаки\n",
|
|||
|
"y = df3['Outcome'] # Целевая переменная\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение на обучающую и оставшуюся часть (контрольная + тестовая)\n",
|
|||
|
"X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.4, random_state=42, stratify=y)\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение оставшейся части на контрольную и тестовую выборки\n",
|
|||
|
"X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5, random_state=42, stratify=y_temp)\n",
|
|||
|
"\n",
|
|||
|
"# Функция для проверки сбалансированности выборок\n",
|
|||
|
"def check_balance(y_train, y_val, y_test):\n",
|
|||
|
" print(\"Сбалансированность обучающей выборки:\")\n",
|
|||
|
" print(y_train.value_counts(normalize=True))\n",
|
|||
|
" \n",
|
|||
|
" print(\"\\nСбалансированность контрольной выборки:\")\n",
|
|||
|
" print(y_val.value_counts(normalize=True))\n",
|
|||
|
" \n",
|
|||
|
" print(\"\\nСбалансированность тестовой выборки:\")\n",
|
|||
|
" print(y_test.value_counts(normalize=True))\n",
|
|||
|
"\n",
|
|||
|
"# Проверка сбалансированности\n",
|
|||
|
"check_balance(y_train, y_val, y_test)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"В обучающей выборке наблюдается незначительный дисбаланс между классами, где количество случаев отсутствия диабета превышает количество случаев наличия диабета. Это может привести к смещению модели в сторону предсказания класса 0."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 106,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Сбалансированность обучающей выборки после SMOTE:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.5\n",
|
|||
|
"1 0.5\n",
|
|||
|
"Name: proportion, dtype: float64\n",
|
|||
|
"Сбалансированность обучающей выборки:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.5\n",
|
|||
|
"1 0.5\n",
|
|||
|
"Name: proportion, dtype: float64\n",
|
|||
|
"\n",
|
|||
|
"Сбалансированность контрольной выборки:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.655172\n",
|
|||
|
"1 0.344828\n",
|
|||
|
"Name: proportion, dtype: float64\n",
|
|||
|
"\n",
|
|||
|
"Сбалансированность тестовой выборки:\n",
|
|||
|
"Outcome\n",
|
|||
|
"0 0.662069\n",
|
|||
|
"1 0.337931\n",
|
|||
|
"Name: proportion, dtype: float64\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"from sklearn.model_selection import train_test_split\n",
|
|||
|
"from imblearn.over_sampling import SMOTE\n",
|
|||
|
"\n",
|
|||
|
"# Разделение на признаки (X) и целевую переменную (y)\n",
|
|||
|
"X = df3.drop('Outcome', axis=1) # Признаки\n",
|
|||
|
"y = df3['Outcome'] # Целевая переменная\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение на обучающую и оставшуюся часть (контрольная + тестовая)\n",
|
|||
|
"X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.4, random_state=42, stratify=y)\n",
|
|||
|
"\n",
|
|||
|
"# Разбиение оставшейся части на контрольную и тестовую выборки\n",
|
|||
|
"X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5, random_state=42, stratify=y_temp)\n",
|
|||
|
"\n",
|
|||
|
"# Применение SMOTE для балансировки обучающей выборки\n",
|
|||
|
"smote = SMOTE(random_state=42)\n",
|
|||
|
"X_train_resampled, y_train_resampled = smote.fit_resample(X_train, y_train)\n",
|
|||
|
"\n",
|
|||
|
"# Функция для проверки сбалансированности выборок\n",
|
|||
|
"def check_balance(y_train, y_val, y_test):\n",
|
|||
|
" print(\"Сбалансированность обучающей выборки:\")\n",
|
|||
|
" print(y_train.value_counts(normalize=True))\n",
|
|||
|
" \n",
|
|||
|
" print(\"\\nСбалансированность контрольной выборки:\")\n",
|
|||
|
" print(y_val.value_counts(normalize=True))\n",
|
|||
|
" \n",
|
|||
|
" print(\"\\nСбалансированность тестовой выборки:\")\n",
|
|||
|
" print(y_test.value_counts(normalize=True))\n",
|
|||
|
"\n",
|
|||
|
"# Проверка сбалансированности после SMOTE\n",
|
|||
|
"print(\"Сбалансированность обучающей выборки после SMOTE:\")\n",
|
|||
|
"print(y_train_resampled.value_counts(normalize=True))\n",
|
|||
|
"\n",
|
|||
|
"# Проверка сбалансированности контрольной и тестовой выборок\n",
|
|||
|
"check_balance(y_train_resampled, y_val, y_test)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Выборка сбалансирована"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"display_name": "aimenv",
|
|||
|
"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
|
|||
|
}
|