MAI_PIbd-33_Volkov_N.A./lab2/lab2.ipynb

2124 lines
1.1 MiB
Plaintext
Raw Normal View History

2024-10-26 01:15:17 +04:00
{
2024-11-09 10:04:05 +04:00
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Лабораторная работа №2\n",
"## Были выбраны следующие датасеты:\n",
" - ### 11. Цены на бриллианты.\n",
" - ### 18. Цены на мобильные устройства.\n",
" - ### 19. Данные о миллионерах."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Начнем анализировать датасет №11.\n",
"\n",
"Ссылка на исходные данные: https://www.kaggle.com/datasets/nancyalaswad90/diamonds-prices\n",
"\n",
"**Общее описание**: Данный датасет содержит цены и атрибуты для 53940 алмазов круглой огранки. Имеются 10 характеристик (карат, огранка, цвет, чистота, глубина, таблица, цена, x, y и z). Большинство переменных являются числовыми по своей природе, но переменные cut, color и clearity являются упорядоченными факторными переменными.\n",
"\n",
"**Проблемная область**: Финансовый анализ и прогнозирование цен акций.\n",
"\n",
"**Объекты наблюдения**: Данные о алмазах, включающие атрибуты: _Carat, Cut, Color, Clarity, Depth, Table, Price_.\n",
"\n",
"**Бизнес цели**:\n",
"- ***Прогнозирование цен на алмазы***: Позволяет покупателям и продавцам лучше ориентироваться в рыночных ценах, а также помогает в принятии решений о покупке или продаже алмазов,\n",
"- ***Анализ факторов, влияющих на стоимость***: Понимание, какие характеристики алмаза (например, качество огранки или цвет) оказывают наибольшее влияние на его цену, может помочь в разработке стратегий ценообразования и улучшении ассортимента.\n",
"\n",
"**Цели технического проекта**:\n",
"1. ***Прогнозирование цен на алмазы***: Входные данные - атрибуты алмазов; целевой признак - _цена_,\n",
"2. ***Анализ факторов влияния***: Входные данные - атрибуты, описывающие качество и характеристики алмаза; целевой признак - влияние каждого атрибута на конечную цену, что может быть проанализировано с помощью методов регрессии и визуализации данных."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[1], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpd\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m../data/Diamonds-Prices.csv\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(df\u001b[38;5;241m.\u001b[39mcolumns)\n",
"File \u001b[1;32mc:\\Users\\bocchanskyy\\source\\repos\\MAI_PIbd-33_Volkov_NA\\.venv\\Lib\\site-packages\\pandas\\io\\parsers\\readers.py:1026\u001b[0m, in \u001b[0;36mread_csv\u001b[1;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[0m\n\u001b[0;32m 1013\u001b[0m kwds_defaults \u001b[38;5;241m=\u001b[39m _refine_defaults_read(\n\u001b[0;32m 1014\u001b[0m dialect,\n\u001b[0;32m 1015\u001b[0m delimiter,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1022\u001b[0m dtype_backend\u001b[38;5;241m=\u001b[39mdtype_backend,\n\u001b[0;32m 1023\u001b[0m )\n\u001b[0;32m 1024\u001b[0m kwds\u001b[38;5;241m.\u001b[39mupdate(kwds_defaults)\n\u001b[1;32m-> 1026\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32mc:\\Users\\bocchanskyy\\source\\repos\\MAI_PIbd-33_Volkov_NA\\.venv\\Lib\\site-packages\\pandas\\io\\parsers\\readers.py:620\u001b[0m, in \u001b[0;36m_read\u001b[1;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[0;32m 617\u001b[0m _validate_names(kwds\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnames\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))\n\u001b[0;32m 619\u001b[0m \u001b[38;5;66;03m# Create the parser.\u001b[39;00m\n\u001b[1;32m--> 620\u001b[0m parser \u001b[38;5;241m=\u001b[39m \u001b[43mTextFileReader\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 622\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m chunksize \u001b[38;5;129;01mor\u001b[39;00m iterator:\n\u001b[0;32m 623\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m parser\n",
"File \u001b[1;32mc:\\Users\\bocchanskyy\\source\\repos\\MAI_PIbd-33_Volkov_NA\\.venv\\Lib\\site-packages\\pandas\\io\\parsers\\readers.py:1620\u001b[0m, in \u001b[0;36mTextFileReader.__init__\u001b[1;34m(self, f, engine, **kwds)\u001b[0m\n\u001b[0;32m 1617\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moptions[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhas_index_names\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m kwds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhas_index_names\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m 1619\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles: IOHandles \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m-> 1620\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_engine\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mengine\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32mc:\\Users\\bocchanskyy\\source\\repos\\MAI_PIbd-33_Volkov_NA\\.venv\\Lib\\site-packages\\pandas\\io\\parsers\\readers.py:1898\u001b[0m, in \u001b[0;36mTextFileReader._make_engine\u001b[1;34m(self, f, engine)\u001b[0m\n\u001b[0;32m 1895\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg)\n\u001b[0;32m 1897\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1898\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mmapping\u001b[49m\u001b[43m[\u001b[49m\u001b[43mengine\u001b[49m\u001b[43m]\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptions\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1899\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[0;32m 1900\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhandles \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n",
"File \u001b[1;32mc:\\Users\\bocchanskyy\\source\\repos\\MAI_PIbd-33_Volkov_NA\\.venv\\Lib\\site-packages\\pandas\\io\\parsers\\c_parser_wrapper.py:93\u001b[0m, in \u001b[0;36mCParserWrapper.__init__\u001b[1;34m(self, src, **kwds)\u001b[0m\n\u001b[0;32m 90\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwds[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdtype_backend\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpyarrow\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m 91\u001b[0m \u001b[38;5;66;03m# Fail here loudly instead of in cython after reading\u001b[39;00m\n\u001b[0;32m 92\u001b[0m import_optional_dependency(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpyarrow\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 93\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_reader \u001b[38;5;241m=\u001b[39m \u001b[43mparsers\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mTextReader\u001b[49m\u001b[43m(\u001b[49m\u001b[43msrc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 95\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39munnamed_cols \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_reader\u001b[38;5;241m.\u001b[39munnamed_cols\n\u001b[0;32m 97\u001b[0m \u001b[38;5;66;03m# error: Cannot determine type of 'names'\u001b[39;00m\n",
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv(\"../data/Diamonds-Prices.csv\")\n",
"print(df.columns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Атрибуты: \n",
"- Неизвестный: 0, \n",
"- Караты (carat), \n",
"- Огранка (cut), \n",
"- Цвет (color), \n",
"- Чистота (clarity), \n",
"- Глубина (depth), \n",
"- Площадь огранки (table), \n",
"- Цена (price), \n",
"- Ширина (координата X), \n",
"- Длина (координата Y), \n",
"- Высота (координата Z). "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Проверяем на выбросы"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0EAAAIjCAYAAADFthA8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACu9klEQ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DnIzMxEamoqfve73zmdUzmf3QsuuMDj6xO99tprmDhxIrKzs6HT6VBQUIDly5d7PMdEpC5mgojISgyCdDqdV89ftWoVDhw44PT4pk2b8P333+Pmm2+G0WjE119/jZdeeglff/01du7c6dS5Wb58OZKTk60/OwZlJ0+exNSpU3HNNddg5syZ+M9//oO5c+ciPj4et9xyCwCgsbERL7/8MmbOnInZs2ejqakJr7zyCi655BLs2rULI0aMsNunXq/Ha6+9hiuuuML62DvvvIP29naXr7epqQnvv/8+rrzySutjr732GvR6vdPzVq5cieTkZPzxj39EcnIytmzZgkceeQSNjY148sknXR5DPM7FF1+MgQMHQhAE/Oc//8Hvf/97pKWl4de//rVX53jVqlUAgLq6Ojz//PO4+uqrUVZWhjPOOMNlO+6//37JxxcvXoxFixbhvPPOw6OPPor4+Hh88cUX2LJlCy6++GLJ53R3d+Ohhx5yeSwl78fXX3+N8ePHIzU1Fffddx/i4uLw4osv4oILLsCnn36KX/3qVwB6gpTx48fj4MGDuOWWWzBy5EjU1dVh/fr1+PHHHzF06FDreQGAl156CQcPHsTTTz9tfWzYsGEu2/yPf/wDx44dc/l7X8yZMwcrV67EzTffjP/7v/9DZWUlli1bhj179mDHjh2Ii4vzy3Hl2Lx5My699FIMGDAAixYtQltbG/75z39i7NixKC0tRV5eHq666ioMGjTI+pz58+dj6NChuO2226yP2Q7B9WTfvn244oorMHXqVDz33HPWx7/88kt8/vnnuPbaa3HaaaehqqoKy5cvxwUXXIDy8nIkJiba7WfevHlIS0vDokWL8O2332L58uWorq62BsSAvM/uQw89hN///vcAej5T8+fPx2233Ybx48c7tX358uU488wzcfnllyM2NhYbNmzAHXfcAYvFgjvvvFP2OSAiHwlERD975plnBADCvn377B4///zzhTPPPNPusddee00AIFRWVgqCIAjt7e1C//79hUsvvVQAILz22mvWbVtbW52OtXbtWgGAsG3bNutjCxcuFAAIJ06ccNnG888/XwAg/OMf/7A+1tHRIYwYMULIzs4WOjs7BUEQhO7ubqGjo8PuuSdPnhR69+4t3HLLLdbHKisrBQDCzJkzhdjYWKG2ttb6u4suuki47rrrBADCk08+6dTOmTNnCpdddpn18erqakGr1QozZ850eh1S52DOnDlCYmKi0N7e7vL1Sunu7hZSU1OFefPmud2/u3Ns66OPPhIACP/5z3+sj51//vnC+eefb/1548aNAgBhypQpds8/dOiQoNVqhSuvvFIwm812+7VYLNb/5+bmCjfeeKP15+eff17Q6XTChRdeKOTm5lof9+b9uOKKK4T4+HihoqLC+tjRo0eFlJQUYcKECdbHHnnkEQGA8M477zidK9u2im688Ua7ttlyPI/Hjx8XUlJSrNf/1q1bJZ/n+HzHa/3LL790+vx89tlnAgDhjTfesNu2uLjY6fHc3Fxh2rRpTse78847nd53AMKdd97pso2On3FXxM9efX299bF9+/YJWq1W+N3vfif5HMfrwRPb811VVSXk5OQI48aNE9ra2uy2k/oclJSUCACE119/3fqY+NpGjRpl/c4QBEH429/+JgAQ1q1b53af7j674jVs+x56auMll1wiDBgwQHJ7IvIPDocjIitx6FSvXr0UP/e5555DfX09Fi5c6PS7hIQE6//b29tRV1eHMWPGAABKS0sVHys2NhZz5syx/hwfH485c+bg+PHj2L17NwAgJiYG8fHxAHqGEjU0NKC7uxvnnHOO5DFHjhyJM88805oJqK6uxtatW52GcNm65ZZbUFxcjNraWgDAv/71LxQVFeH000932tb2HDQ1NaGurg7jx49Ha2srvvnmG4+v2Ww2o66uDtXV1Xj66afR2Nhod5dZ6Tmuq6tDXV0dDh48iBdeeAFJSUnW7R0JgoAFCxbg17/+tTWrInrvvfdgsVjwyCOPOGXspIbNAUBrayseffRRzJs3D/3795fcRu77YTab8dFHH+GKK67AgAEDrI/n5OTguuuuw/bt29HY2AgAePvttzF8+HC7zJ2ntsq1ZMkSGAwG/N///Z9P+5Hy3//+FwaDAZMnT7a+b3V1dRg1ahSSk5Odhnh2dXXZbVdXV+cyoyleK/X19bBYLIrbVlNTg7179+Kmm25CRkaG9fFhw4Zh8uTJ2Lhxo+J9ulNfX49LLrkEKSkpWL9+PfR6vd3vbT8HXV1dqK+vx6BBg5CWlib5Objtttvssmhz585FbGysXbt9/ew6st2fyWRCXV0dzj//fHz//fcwmUyK90dE3mEQRERW1dXViI2NVRwEmUwmPP744/jjH/+I3r17O/2+oaEBd911F3r37o2EhAT06tUL+fn51ucq1adPHyQlJdk9JgYetmP///Wvf2HYsGHQ6/XIzMxEr1698MEHH7g85s0334zXXnsNQM8QmPPOOw+DBw922Y4RI0agsLAQr7/+OgRBsA5XkvL111/jyiuvhMFgQGpqKnr16oVZs2YBkHcODh06hF69eiEvLw8PPfQQnn/+eVxzzTXW3ys9x7169UKvXr1QUFCAzZs344033kC/fv0kj/3GG2/g66+/xuOPP+70u4qKCmi1WhQUFHh8DaKnnnoK7e3tePDBB91uJ+f9OHHiBFpbWyWH8Q0dOhQWiwVHjhyxttUfpd4rKyvx4osvYvHixU6dcjUcOnQIJpMJ2dnZ1
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Загрузка данных\n",
"df = pd.read_csv(\"../data/Diamonds-Prices.csv\")\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(df[\"price\"], df[\"carat\"])\n",
"plt.xlabel(\"Цена\")\n",
"plt.ylabel(\"Карат\")\n",
"plt.title(\"Диаграмма зависимости цены от карата\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Выброс с наибольшим значением был замечен при ~175000\n",
"Начнем использовать метод межквантильного размаха для удаления выбросов."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Пустые значения по столбцам:\n",
"Unnamed: 0 0\n",
"carat 0\n",
"cut 0\n",
"color 0\n",
"clarity 0\n",
"depth 0\n",
"table 0\n",
"price 0\n",
"x 0\n",
"y 0\n",
"z 0\n",
"dtype: int64\n",
"\n",
"Количество дубликатов: 0\n",
"\n",
"Статистический обзор данных:\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Unnamed: 0</th>\n",
" <th>carat</th>\n",
" <th>depth</th>\n",
" <th>table</th>\n",
" <th>price</th>\n",
" <th>x</th>\n",
" <th>y</th>\n",
" <th>z</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" <td>53943.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>26972.000000</td>\n",
" <td>0.797935</td>\n",
" <td>61.749322</td>\n",
" <td>57.457251</td>\n",
" <td>3932.734294</td>\n",
" <td>5.731158</td>\n",
" <td>5.734526</td>\n",
" <td>3.538730</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>15572.147122</td>\n",
" <td>0.473999</td>\n",
" <td>1.432626</td>\n",
" <td>2.234549</td>\n",
" <td>3989.338447</td>\n",
" <td>1.121730</td>\n",
" <td>1.142103</td>\n",
" <td>0.705679</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>1.000000</td>\n",
" <td>0.200000</td>\n",
" <td>43.000000</td>\n",
" <td>43.000000</td>\n",
" <td>326.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>13486.500000</td>\n",
" <td>0.400000</td>\n",
" <td>61.000000</td>\n",
" <td>56.000000</td>\n",
" <td>950.000000</td>\n",
" <td>4.710000</td>\n",
" <td>4.720000</td>\n",
" <td>2.910000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>26972.000000</td>\n",
" <td>0.700000</td>\n",
" <td>61.800000</td>\n",
" <td>57.000000</td>\n",
" <td>2401.000000</td>\n",
" <td>5.700000</td>\n",
" <td>5.710000</td>\n",
" <td>3.530000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>40457.500000</td>\n",
" <td>1.040000</td>\n",
" <td>62.500000</td>\n",
" <td>59.000000</td>\n",
" <td>5324.000000</td>\n",
" <td>6.540000</td>\n",
" <td>6.540000</td>\n",
" <td>4.040000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>53943.000000</td>\n",
" <td>5.010000</td>\n",
" <td>79.000000</td>\n",
" <td>95.000000</td>\n",
" <td>18823.000000</td>\n",
" <td>10.740000</td>\n",
" <td>58.900000</td>\n",
" <td>31.800000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Unnamed: 0 carat depth table price \\\n",
"count 53943.000000 53943.000000 53943.000000 53943.000000 53943.000000 \n",
"mean 26972.000000 0.797935 61.749322 57.457251 3932.734294 \n",
"std 15572.147122 0.473999 1.432626 2.234549 3989.338447 \n",
"min 1.000000 0.200000 43.000000 43.000000 326.000000 \n",
"25% 13486.500000 0.400000 61.000000 56.000000 950.000000 \n",
"50% 26972.000000 0.700000 61.800000 57.000000 2401.000000 \n",
"75% 40457.500000 1.040000 62.500000 59.000000 5324.000000 \n",
"max 53943.000000 5.010000 79.000000 95.000000 18823.000000 \n",
"\n",
" x y z \n",
"count 53943.000000 53943.000000 53943.000000 \n",
"mean 5.731158 5.734526 3.538730 \n",
"std 1.121730 1.142103 0.705679 \n",
"min 0.000000 0.000000 0.000000 \n",
"25% 4.710000 4.720000 2.910000 \n",
"50% 5.700000 5.710000 3.530000 \n",
"75% 6.540000 6.540000 4.040000 \n",
"max 10.740000 58.900000 31.800000 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"null_values_diamond = df.isnull().sum()\n",
"print(\"Пустые значения по столбцам:\")\n",
"print(null_values_diamond)\n",
"\n",
"duplicates = df.duplicated().sum()\n",
"print(f\"\\nКоличество дубликатов: {duplicates}\")\n",
"\n",
"print(\"\\nСтатистический обзор данных:\")\n",
"df.describe()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Коэффициент асимметрии для столбца 'Unnamed: 0': 0.0\n",
"\n",
"Коэффициент асимметрии для столбца 'carat': 1.1167052359880187\n",
"\n",
"Коэффициент асимметрии для столбца 'depth': -0.08218721424717913\n",
"\n",
"Коэффициент асимметрии для столбца 'table': 0.7968359775412807\n",
"\n",
"Коэффициент асимметрии для столбца 'price': 1.6184763222032386\n",
"\n",
"Коэффициент асимметрии для столбца 'x': 0.37868453466912216\n",
"\n",
"Коэффициент асимметрии для столбца 'y': 2.4342330799873775\n",
"\n",
"Коэффициент асимметрии для столбца 'z': 1.5224810204974413\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"for column in df.select_dtypes(include=[np.number]).columns:\n",
" asymmetry = df[column].skew()\n",
" print(f\"\\nКоэффициент асимметрии для столбца '{column}': {asymmetry}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Видим выбросы. Очистим данные от шумов."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0EAAAI+CAYAAAB6/gF5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA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//jqysrIc7uCrOaednZ22/Yn/mpqaJI8tampqwuOPP4558+ahb9++Dr9rbGyE1WpF9+7d3e7DV++99x6sViuuu+46h7abzWYMHDjQZXqnks/Gf/7zHwwePBiDBg1y2OeECRMAwGWf4iiG87WiRGZmJoCu0Tw15K6PU6dOYevWrbj11ltd3hMl0/Pk7Nq1C9dddx3+3//7fy6jiN988w1OnjyJu+66y+EcTJ06FYMGDcLHH38su9/58+ejoKAAv/nNb7xuGxFpg9PhiEhWRUUFYmJiVAdBFosFTz31FP74xz+iZ8+eLr+vra3FokWL8Oabb+LkyZMuz1WrV69eLguNxcCjvLzcFmD9+9//xt///nccPHjQYe1Obm6u5H5nzZqFl19+Gffddx9WrlyJiy66CAMHDpRtx/Dhw5Gfn4/XX38d999/P1auXImHH37YZa0G0DVt7JFHHsHmzZtRX1/v8Dul58C5Lf3794der3dYZ7Bjxw4sXLgQhYWFLp18i8UCk8mE0tJSAHCb9lzJNocPH4YgCFiwY
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2QAAAI1CAYAAAC5TTkuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAD2iUlEQVR4nOzdd3wUdfoH8M9uKgmphGQThCQUhRCKIJAYikIQBMWC54+ih4JgAQ+xAXoo5RTROxFPBEGxUE9PTlG4HCUoxVAEgsSAUhIQTMB0SEjd+f2xzLJlZvY7s7O7s5vn/Xr5uiM7OzvbZr/PfJ/v8+g4juNACCGEEEIIIcTt9J4+AEIIIYQQQghpriggI4QQQgghhBAPoYCMEEIIIYQQQjyEAjJCCCGEEEII8RAKyAghhBBCCCHEQyggI4QQQgghhBAPoYCMEEIIIYQQQjyEAjJCCCGEEEII8RAKyAghhBBCCCHEQ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zzz4Dx3Hm9C4hP//8M+677z5EREQgPDwcrVu3xkMPPQSA/TWwPZYOHTpAr9dbPee9e/ciMzMToaGhiIyMROvWrfHSSy9ZPc7p06cBQLKVAcs2p06dAsdxmDNnDlq3bm31Hx9oXbp0ye5+jj4vAPDbb7+Z93XzzTfj9OnT+PLLL63SzuS8pidOnBA9RjFvv/02amtrza+fpVatWqFTp0748MMPsXXrVly6dAklJSWC67qccfbsWej1enTs2NHq7waDA
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(df[\"price\"], df[\"carat\"])\n",
"plt.xlabel(\"Цена\")\n",
"plt.ylabel(\"Карат\")\n",
"plt.xticks(rotation=45)\n",
"plt.title(\"Диаграмма рассеивания перед чисткой\")\n",
"plt.show()\n",
"\n",
"\n",
"# Выбираем столбцы для анализа\n",
"column1 = \"carat\"\n",
"column2 = \"price\"\n",
"# Функция для удаления выбросов\n",
"def remove_outliers(df, column):\n",
" Q1 = df[column].quantile(0.25)\n",
" Q3 = df[column].quantile(0.75)\n",
" IQR = Q3 - Q1\n",
" lower_bound = Q1 - 1.5 * IQR\n",
" upper_bound = Q3 + 1.5 * IQR\n",
" return df[(df[column] >= lower_bound) & (df[column] <= upper_bound)]\n",
"\n",
"\n",
"# Удаление выбросов для каждого столбца\n",
"df_cleaned = df.copy()\n",
"for column in [column1, column2]:\n",
" df_cleaned = remove_outliers(df_cleaned, column)\n",
"\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(df_cleaned[column1], df_cleaned[column2])\n",
"plt.xlabel(\"Цена\")\n",
"plt.ylabel(\"Карат\")\n",
"plt.xticks(rotation=45)\n",
"plt.title(\"Диаграмма рассеивания после чистки\")\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Количество строк до удаления выбросов: 53943\n",
"Количество строк после удаления выбросов: 49517\n"
]
}
],
"source": [
"# Вывод количества строк до и после удаления выбросов\n",
"print(f\"Количество строк до удаления выбросов: {len(df)}\")\n",
"print(f\"Количество строк после удаления выбросов: {len(df_cleaned)}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Перейдем к созданию выборок"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Размер обучающей выборки: 32365\n",
"Размер контрольной выборки: 10789\n",
"Размер тестовой выборки: 10789\n"
]
}
],
"source": [
"from sklearn.model_selection import train_test_split\n",
"\n",
"df = pd.read_csv(\"../data/Diamonds-Prices.csv\")\n",
"\n",
"# Выбираем признаки и целевую переменную\n",
"X = df.drop(\"price\", axis=1) # Все столбцы, кроме цены\n",
"y = df[\"price\"]\n",
"\n",
"# Разбиение данных на обучающую и оставшуюся часть (контрольную + тестовую)\n",
"X_train, X_temp, y_train, y_temp = train_test_split(\n",
" X, y, test_size=0.4, random_state=42\n",
")\n",
"\n",
"# Разбиение оставшейся части на контрольную и тестовую выборки\n",
"X_val, X_test, y_val, y_test = train_test_split(\n",
" X_temp, y_temp, test_size=0.5, random_state=42\n",
")\n",
"\n",
"# Вывод размеров выборок\n",
"print(f\"Размер обучающей выборки: {X_train.shape[0]}\")\n",
"print(f\"Размер контрольной выборки: {X_val.shape[0]}\")\n",
"print(f\"Размер тестовой выборки: {X_test.shape[0]}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Проанализируем сбалансированность выборок"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Распределение Price в обучающей выборке:\n",
"price\n",
"327 1\n",
"334 1\n",
"336 1\n",
"337 1\n",
"338 1\n",
" ..\n",
"18791 1\n",
"18795 2\n",
"18797 1\n",
"18804 1\n",
"18806 1\n",
"Name: count, Length: 9476, dtype: int64\n",
"Процент положительных значений: 100.00%\n",
"Процент отрицательных значений: 0.00%\n",
"\n",
"Необходима аугментация данных для балансировки классов.\n",
"\n",
"Распределение Price в контрольной выборке:\n",
"price\n",
"326 2\n",
"340 1\n",
"344 1\n",
"354 1\n",
"357 1\n",
" ..\n",
"18781 1\n",
"18784 1\n",
"18791 1\n",
"18803 1\n",
"18823 1\n",
"Name: count, Length: 5389, dtype: int64\n",
"Процент положительных значений: 100.00%\n",
"Процент отрицательных значений: 0.00%\n",
"\n",
"Необходима аугментация данных для балансировки классов.\n",
"\n",
"Распределение Price в тестовой выборке:\n",
"price\n",
"335 1\n",
"336 1\n",
"337 1\n",
"351 1\n",
"353 1\n",
" ..\n",
"18766 1\n",
"18768 1\n",
"18780 1\n",
"18788 1\n",
"18818 1\n",
"Name: count, Length: 5308, dtype: int64\n",
"Процент положительных значений: 100.00%\n",
"Процент отрицательных значений: 0.00%\n",
"\n",
"Необходима аугментация данных для балансировки классов.\n",
"\n"
]
}
],
"source": [
"def analyze_distribution(data, title):\n",
" print(f\"Распределение Price в {title}:\")\n",
" distribution = data.value_counts().sort_index()\n",
" print(distribution)\n",
" total = len(data)\n",
" positive_count = (data > 0).sum()\n",
" negative_count = (data < 0).sum()\n",
" positive_percent = (positive_count / total) * 100\n",
" negative_percent = (negative_count / total) * 100\n",
" print(f\"Процент положительных значений: {positive_percent:.2f}%\")\n",
" print(f\"Процент отрицательных значений: {negative_percent:.2f}%\")\n",
" print(\"\\nНеобходима аугментация данных для балансировки классов.\\n\")\n",
"\n",
"\n",
"# Анализ распределения для каждой выборки\n",
"analyze_distribution(y_train, \"обучающей выборке\")\n",
"analyze_distribution(y_val, \"контрольной выборке\")\n",
"analyze_distribution(y_test, \"тестовой выборке\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Применяем методы приращения данных"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Распределение Price в обучающей выборке после oversampling:\n",
"price\n",
"327 85\n",
"334 85\n",
"336 85\n",
"337 85\n",
"338 85\n",
" ..\n",
"18791 85\n",
"18795 85\n",
"18797 85\n",
"18804 85\n",
"18806 85\n",
"Name: count, Length: 9476, dtype: int64\n",
"Процент положительных значений: 100.00%\n",
"Процент отрицательных значений: 0.00%\n",
"\n",
"Необходима аугментация данных для балансировки классов.\n",
"\n",
"Распределение Price в контрольной выборке:\n",
"price\n",
"326 2\n",
"340 1\n",
"344 1\n",
"354 1\n",
"357 1\n",
" ..\n",
"18781 1\n",
"18784 1\n",
"18791 1\n",
"18803 1\n",
"18823 1\n",
"Name: count, Length: 5389, dtype: int64\n",
"Процент положительных значений: 100.00%\n",
"Процент отрицательных значений: 0.00%\n",
"\n",
"Необходима аугментация данных для балансировки классов.\n",
"\n",
"Распределение Price в тестовой выборке:\n",
"price\n",
"335 1\n",
"336 1\n",
"337 1\n",
"351 1\n",
"353 1\n",
" ..\n",
"18766 1\n",
"18768 1\n",
"18780 1\n",
"18788 1\n",
"18818 1\n",
"Name: count, Length: 5308, dtype: int64\n",
"Процент положительных значений: 100.00%\n",
"Процент отрицательных значений: 0.00%\n",
"\n",
"Необходима аугментация данных для балансировки классов.\n",
"\n"
]
}
],
"source": [
"from imblearn.over_sampling import RandomOverSampler\n",
"\n",
"# Применение oversampling к обучающей выборке\n",
"oversampler = RandomOverSampler(random_state=42)\n",
"X_train_resampled, y_train_resampled = oversampler.fit_resample(X_train, y_train)\n",
"\n",
"# Анализ распределения для каждой выборки\n",
"analyze_distribution(y_train_resampled, \"обучающей выборке после oversampling\")\n",
"analyze_distribution(y_val, \"контрольной выборке\")\n",
"analyze_distribution(y_test, \"тестовой выборке\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Начнем анализировать датасет №18.\n",
"\n",
"Ссылка на исходные данные: https://www.kaggle.com/datasets/dewangmoghe/mobile-phone-price-prediction\n",
"\n",
"**Общее описание**: Данный датасет содержит информацию о ценах и атрибутах для 1369 мобильных телефонов разных конфигураций и производителей. Имеются 17 характеристик (именование модели, оценка (мин - 0, макс - 5), оценка на основе характеристик (мин - 0, макс - 100), информация о поддержке 2 симок и сетевых технологий (3G, 4G, 5G, VoLTE), количество оперативной памяти, характеристики батареи, информация о дисплее, характеристики камеры, поддержка внешней памяти, версия системы Android, цена, компания-производитель, поддержка быстрой зарядки, разрешение экрана, тип процессора, название процессора).\n",
"\n",
"**Проблемная область**: Финансовый анализ и прогнозирование цен на мобильные телефоны.\n",
"\n",
"**Объекты наблюдения**: телефон, включающий атрибуты: _Name, Rating, Spec_score, No_of_sim, RAM, Battery, Display, Camera, External_Memory, Android_version, Price, Company, Inbuilt_memory, Fast_charging, Screen_resolution, Processor, Processor_name_.\n",
"\n",
"**Бизнес цели**:\n",
"- ***Прогнозирование цен мобильные телефоны на основе оценки характеристик***.\n",
"- ***Прогнозирование оценки на основе фирмы и цены***.\n",
"\n",
"**Цели технического проекта**:\n",
"1. ***Прогнозирование цен на телефоны***: Входные данные - _оценка характеристик_; целевой признак - _цена_,\n",
"2. ***Анализ факторов влияния***: Входные данные - _фирма и цена_; целевой признак - _оценка характеристик_."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['Unnamed: 0', 'Name', 'Rating', 'Spec_score', 'No_of_sim', 'Ram',\n",
" 'Battery', 'Display', 'Camera', 'External_Memory', 'Android_version',\n",
" 'Price', 'company', 'Inbuilt_memory', 'fast_charging',\n",
" 'Screen_resolution', 'Processor', 'Processor_name'],\n",
" dtype='object')\n"
]
}
],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv(\"../data/mobile-phone-price-prediction.csv\")\n",
"print(df.columns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Атрибуты: \n",
"- Неизвестный: 0, \n",
"- Наименование телефона (Name), \n",
"- Рейтинг (Rating),\n",
"- Рейтинг на основе характеристик (Spec_score),\n",
"- Поддержка различных технологий (No_of_sim),\n",
"- Количество оперативной памяти (Ram),\n",
"- Инфо о батарее (Battery),\n",
"- Инфо о дисплее (Display),\n",
"- Инфо о камере (Camera),\n",
"- Инфо о внешней памяти (External_Memory),\n",
"- Версия Android (Android_version),\n",
"- Цена (Price),\n",
"- Компания-производитель (company),\n",
"- Инфо о внутренней памяти (Inbuilt_memory),\n",
"- Быстрая зарядка (fast_charging),\n",
"- Разрешение экрана (Screen_resolution),\n",
"- Тип процессора (Processor),\n",
"- Наименование процессора (Processor_name)."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIgAAAJLCAYAAACMgK3jAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdfXwU5bk//s9uQkggZCWRkCCSLFALa4xCFY0lYKlRRPHxVOUncCyeiFh85Gs1VIiAGtGeatVKIaXyVGt7WqsiIZZKlXgaDBUR0+ATbIJgQiCBTQIJS3b390fOpoTsw0wymZlr9/N+vXi9mp2LeDG99557r525L4vP5/OBiIiIiIiIiIiiltXoBIiIiIiIiIiIyFgsEBERERERERERRTkWiIiIiIiIiIiIohwLREREREREREREUY4FIiIiIiIiIiKiKMcCERERERERERFRlGOBiIiIiIiIiIgoyrFAREREREREREQU5VggIiIiIiIiIiKKciwQERERERERERFFORaIiIiIyLT+9Kc/wWKxBPyTlZVldHpRq6WlBYWFhZg6dSqSk5NhsViwZs0ao9MiIiKiXog1OgEiIiKicBYuXIixY8d2/vzUU08ZmA0dOXIES5cuxYgRI3DhhRfi/fffNzolIiIi6iUWiIiIiMj08vLycMUVV3T+/Jvf/AZHjhwxLqEol56ejtraWqSlpeGf//wnLrnkEqNTIiIiol7iI2ZERERkWm63GwBgtYZfsqxZswYWiwXV1dWdr3m9XmRnZ3d7BGr37t248847MXLkSMTHxyMtLQ1z5sxBQ0NDl9/5xBNPBHy8LTb239+xXXHFFcjKysLHH3+Myy+/HAkJCbDb7fj1r3/d7d+yePFifO9734PNZsPAgQORm5uLv//9713iqqurO/87b775ZpdjbW1tGDx4MCwWC37+8593yzM1NRWnTp3q8nd+//vfd/6+04tqb731Fq699loMGzYM/fv3x6hRo7Bs2TJ4PJ6w57p///5IS0sLG0dERERy8A4iIiIiMi1/gah///49+vvr16/HZ5991u31LVu2YN++ffjxj3+MtLQ0/Otf/8KqVavwr3/9C9u3b4fFYukSv2LFCiQmJnb+fGbB6ujRo5g2bRpuvfVWzJgxA3/84x8xb948xMXFYc6cOQCApqYm/OY3v8GMGTOQn5+P5uZmrF69GldffTUqKipw0UUXdfmd8fHxePXVV3HjjTd2vvbGG2+gra0t6L+3ubkZ77zzDm666abO11599VXEx8d3+3tr1qxBYmIiHn74YSQmJmLr1q1YvHgxmpqa8NxzzwX9bxAREVFkYoGIiIiITMvlcgEAEhISVP/dkydPYvHixbjmmmuwefPmLsfuvfdeLFiwoMtrl112GWbMmIEPP/wQubm5XY79x3/8B84+++yg/61vv/0W//3f/42HH34YADB37lxceumlKCgowKxZs9CvXz8MHjwY1dXViIuL6/x7+fn5GDNmDF566SWsXr26y++86aab8D//8z84dOgQhg4dCgD47W9/i5tvvhmvvfZawDxuuukm/Pa3v+0sEO3fvx/vvfcebrvtNvz+97/vEvvaa691Oa/33HMP7rnnHrzyyit48skne1yUIyIiIpn4iBkRERGZlv+RryFDhqj+u7/61a/Q0NCAwsLCbsdOL4y0tbXhyJEjuOyyywAAO3fuVP3fio2Nxdy5czt/jouLw9y5c1FfX4+PP/4YABATE9NZHPJ6vWhsbER7ezsuvvjigP/N8ePH4/zzz8f69esBADU1Nfj73/+OO++8M2gec+bMQWlpKerq6gAAa9euRU5ODs4777xusaefg+bmZhw5cgS5ubk4ceIEPv/8c9XngIiIiGRjgYiIiIhMq6amBrGxsaoLRC6XC08//TQefvjhzrtvTtf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v/0WALBx40YcOHAAAHDffffBZrMp/l1ERERkPBaIiIiIyFQOHz6MgoKCzp9P7w52plmzZuHvf/97lwLRRRddhBkzZoT8b7z22mu477778Ktf/Qo+nw9XXXUVNm/ejGHDhvUo58GDB2Pt2rW47777UFxcjKFDh+Lll19Gfn5+Z8ydd96Juro6rFy5Eu+++y4cDgc2bNiA//mf/8H7778f9HdbLJaghZ5gEhISunQpO1NKSgreeecdLFiwAI8//jgGDx6MmTNn4oc//CGuvvpqRf+Nn//856ipqen8+Y033sAbb7wBoGPvJBaIiIiIZLH41HxVRERERNTHqqurYbfb8fe//x1XXHFFr+P62hVXXIEjR46gsrLSsByIiIiIeot7EBERERERERERRTkWiIiIiMhUEhMTcccdd3R5bKw3cUREREQUHh8xIyIiIuoFPmJGREREkYAFIiIiIiIiIiKiKMdHzIiIiIiIiIiIohzb3APwer349ttvMWjQIFgsFqPTISIiIiIiIiLShM/nQ3NzM4YNGwarNfh9QiwQAfj2229x7rnnGp0GEREREREREVGf+OabbzB8+PCgx1kgAjBo0CAAHScrKSnJ4GyIiIiIiIiIiLTR1NSEc889t7P2EQwLREDnY2VJSUksEBERERERERFRxAm3pY6hm1Rv27YN06dPx7Bhw2CxWPDmm292Oe7z+bB48WKkp6cjISEBV155Jb766qsuMY2NjbjjjjuQlJSEs846C3fddRdaWlp0/FcQEREREREREclmaIHo+PHjuPDCC/GrX/0q4PFnn30WL774In7961/jo48+wsCBA3H11Vejra2tM+aOO+7Av/71L2zZsgXvvPMOtm3bhrvvvluvfwIRERERERERkXgWn8/nMzoJoONWp7/85S+48cYbAXTcPTRs2DAsWLAA/+///T8AgMvlwtChQ7FmzRrcfvvt2LNnDxwOB3bs2IGLL74YAFBaWopp06bhwIEDGDZsWMD/1smTJ3Hy5MnOn/3P47lcLj5iR
"text/plain": [
"<Figure size 1400x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(14, 6))\n",
"\n",
"\n",
"plt.scatter(df[\"company\"].str.lower(), df[\"Spec_score\"])\n",
"plt.xlabel(\"Фирма\")\n",
"plt.ylabel(\"Оценка характеристик\")\n",
"plt.xticks(rotation=45)\n",
"plt.title(\"Диаграмма 1\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Между атрибутами присутствует связь. Пример, на диаграмме 1 - связь между фирмой и оценкой характеристик"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Перейдем к проверке на выбросы"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Пустые значения по столбцам:\n",
"Unnamed: 0 0\n",
"Name 0\n",
"Rating 0\n",
"Spec_score 0\n",
"No_of_sim 0\n",
"Ram 0\n",
"Battery 0\n",
"Display 0\n",
"Camera 0\n",
"External_Memory 0\n",
"Android_version 443\n",
"Price 0\n",
"company 0\n",
"Inbuilt_memory 19\n",
"fast_charging 89\n",
"Screen_resolution 2\n",
"Processor 28\n",
"Processor_name 0\n",
"dtype: int64\n",
"\n",
"Количество дубликатов: 0\n",
"\n",
"Статистический обзор данных:\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Unnamed: 0</th>\n",
" <th>Rating</th>\n",
" <th>Spec_score</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>1370.000000</td>\n",
" <td>1370.000000</td>\n",
" <td>1370.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>684.500000</td>\n",
" <td>4.374416</td>\n",
" <td>80.234307</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>395.629246</td>\n",
" <td>0.230176</td>\n",
" <td>8.373922</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>0.000000</td>\n",
" <td>3.750000</td>\n",
" <td>42.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>342.250000</td>\n",
" <td>4.150000</td>\n",
" <td>75.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>684.500000</td>\n",
" <td>4.400000</td>\n",
" <td>82.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>1026.750000</td>\n",
" <td>4.550000</td>\n",
" <td>86.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>1369.000000</td>\n",
" <td>4.750000</td>\n",
" <td>98.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Unnamed: 0 Rating Spec_score\n",
"count 1370.000000 1370.000000 1370.000000\n",
"mean 684.500000 4.374416 80.234307\n",
"std 395.629246 0.230176 8.373922\n",
"min 0.000000 3.750000 42.000000\n",
"25% 342.250000 4.150000 75.000000\n",
"50% 684.500000 4.400000 82.000000\n",
"75% 1026.750000 4.550000 86.000000\n",
"max 1369.000000 4.750000 98.000000"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"null_values = df.isnull().sum()\n",
"print(\"Пустые значения по столбцам:\")\n",
"print(null_values)\n",
"\n",
"duplicates = df.duplicated().sum()\n",
"print(f\"\\nКоличество дубликатов: {duplicates}\")\n",
"\n",
"print(\"\\nСтатистический обзор данных:\")\n",
"df.describe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Видим, что есть пустые данные, но нет дубликатов. Удаляем их"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"В наборе данных 'Phones' было удалено 553 строк с пустыми значениями.\n"
]
}
],
"source": [
"def drop_missing_values(dataframe, name):\n",
" before_shape = dataframe.shape\n",
" cleaned_dataframe = dataframe.dropna()\n",
" after_shape = cleaned_dataframe.shape\n",
" print(\n",
" f\"В наборе данных '{name}' было удалено {before_shape[0] - after_shape[0]} строк с пустыми значениями.\"\n",
" )\n",
" return cleaned_dataframe\n",
"\n",
"\n",
"cleaned_df = drop_missing_values(df, \"Phones\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Рассчитаем коэффициент ассиметрии"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Коэффициент асимметрии для столбца 'Unnamed: 0': 0.0\n",
"\n",
"Коэффициент асимметрии для столбца 'Rating': -0.06697860128699223\n",
"\n",
"Коэффициент асимметрии для столбца 'Spec_score': -0.7393772365886471\n"
]
}
],
"source": [
"import numpy as np\n",
"for column in df.select_dtypes(include=[np.number]).columns:\n",
" asymmetry = df[column].skew()\n",
" print(f\"\\nКоэффициент асимметрии для столбца '{column}': {asymmetry}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Выбросы незначительные.\n",
"\n",
"Очистим данные от шумов."
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1IAAAJLCAYAAADtiKfgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADus0lEQVR4nOzdeXxTVfo/8E/a0oUusQW6AELL4mBFBAQUZBsFQRQQHRFHUOQnMDKoIKMjDKuyjKKi4ICAyqqjjgiCIoiALFIWBUQsqEDL2lKg0AW60Ob8/ug3SdMmaZLmJk/Sz/v16kt7c0iennvvufe59+Y8OqWUAhERERERETkswNsBEBERERER+RomUkRERERERE5iIkVEREREROQkJlJEREREREROYiJFRERERETkJCZSRERERERETmIiRURERERE5CQmUkRERERERE5iIkVEREREROQkJlJEREREgp05cwZLly41/Z6eno6PPvrIewEREQAmUkSksc8//xw6nc7qT8uWLb0dHhGReDqdDn//+9+xceNGpKen46WXXsKOHTu8HRZRjRfk7QCIqGaYMGECbr75ZtPvM2bM8GI0RES+o0GDBhg+fDh69+4NAEhISMD333/v3aCICDqllPJ2EETkvz7//HM88sgj2Lp1K7p3725a3r17d1y8eBGHDx/2XnBERD7k+PHjuHjxIlq2bInw8HBvh0NU4/HRPiLSVHFxMQAgIKDq4Wbp0qXQ6XRIT083LTMYDGjVqhV0Op3FdwQOHTqEoUOHokmTJggNDUV8fDyGDRuGS5cuWbzn1KlTrT5WGBRkviHfvXt3tGzZEj/99BM6deqEsLAwJCUl4b333qv0t0yePBm333479Ho9wsPD0aVLF2zdutWiXXp6uulz1qxZY/FaYWEhoqOjodPp8MYbb1SKMzY2FtevX7f4N//9739N73fx4kXT8i+//BL3338/6tevj5CQEDRt2hSvvvoqSktLq+xr4+cdPXoUAwcORFRUFOrUqYPnn38ehYWFFm2XLFmCu+++G7GxsQgJCUFycjIWLFhg9X2/+eYbdOvWDZGRkYiKikL79u3x8ccfW7TZs2cP+vTpg+joaISHh6NVq1Z45513LNocPXoUf/nLXxATE4PQ0FC0a9cOa9eutWjjzPYydOhQi/UfHR2N7t27V3o8ytE+NW4zFb3xxhuVYkpMTMTQoUMt2v3vf/+DTqdDYmKixfKsrCz8v//3/9CoUSMEBgaa4o2IiKj0WRUlJibafIxWp9NVar9y5UrcfvvtCAsLQ0xMDAYNGoTTp09b/Tur2jcAoKioCFOmTEGzZs0QEhKCG2+8ES+99BKKiooqtf3+++8djrMi47Zr7e8v38/ObB8ATPtCvXr1EBYWhj/96U/417/+ZfGZ9n6Md4i6d+9ucdEIKLsDHxAQUGlf+N///mdaB3Xr1sXgwYNx9uxZizZD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8/PDDle5m/vjjj8jKysKoUaMs+uD+++9HixYt8PXXX9t83/Hjx6Nt27Z45JFHXI6NiNyDj/YRkaZOnjyJoKAgpxOpnJwczJw5Ey+88ALi4uIqvZ6dnY1p06bhk08+QVZWVqV/66z69etX+vK2MXlJT083JWnLli3Dm2++iaNHj1p8lykpKcnq+z711FNYtGgR/vGPf2Dp0qXo1KkTmjdvbjOO1q1bo2XLlli+fDlefPFFLF26FBMmTKj03RWg7BG4iRMnYsuWLcjNzbV4zdE+qBhL06ZNERAQYPG9ix9++AFTpkxBSkpKpUQhJycHer0ex48fBwC7U9o70ubYsWNQSmHSp
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Выбросы в датасете:\n",
" Unnamed: 0 Name Rating Spec_score \\\n",
"99 99 Vivo Y02 4.35 54 \n",
"214 214 Realme C30s 4.55 58 \n",
"802 802 Vivo Y02 (2GB RAM + 32GB) 4.50 53 \n",
"803 803 Vivo Y02 4.35 54 \n",
"1344 1344 TCL 501 4.25 55 \n",
"\n",
" No_of_sim Ram Battery Display \\\n",
"99 Dual Sim, 3G, 4G, VoLTE, 3 GB RAM 5000 mAh Battery 6.51 inches \n",
"214 Dual Sim, 3G, 4G, VoLTE, 2 GB RAM 5000 mAh Battery 6.5 inches \n",
"802 Dual Sim, 3G, 4G, VoLTE, 2 GB RAM 5000 mAh Battery 6.51 inches \n",
"803 Dual Sim, 3G, 4G, VoLTE, 3 GB RAM 5000 mAh Battery 6.51 inches \n",
"1344 Dual Sim, 3G, 4G, VoLTE, 2 GB RAM 3000 mAh Battery 6 inches \n",
"\n",
" Camera External_Memory \\\n",
"99 8 MP Rear &amp; 5 MP Front Camera Memory Card Supported, upto 1 TB \n",
"214 8 MP Rear &amp; 5 MP Front Camera Memory Card Supported, upto 1 TB \n",
"802 8 MP Rear &amp; 5 MP Front Camera Memory Card Supported, upto 1 TB \n",
"803 8 MP Rear &amp; 5 MP Front Camera Memory Card Supported, upto 1 TB \n",
"1344 5 MP Rear &amp; 2 MP Front Camera Memory Card Supported \n",
"\n",
" Android_version Price company Inbuilt_memory fast_charging \\\n",
"99 12 9,999 Vivo 32 GB inbuilt 10W Fast Charging \n",
"214 12 6,950 Realme 32 GB inbuilt 10W Fast Charging \n",
"802 12 8,999 Vivo 32 GB inbuilt 10W Fast Charging \n",
"803 12 8,489 Vivo 32 GB inbuilt 10W Fast Charging \n",
"1344 14 7,990 TCL 32 GB inbuilt 10W Fast Charging \n",
"\n",
" Screen_resolution Processor \\\n",
"99 720 x 1600 px Display with Water Drop Notch Octa Core Processor \n",
"214 720 x 1600 px Display with Water Drop Notch Octa Core \n",
"802 720 x 1600 px Display with Water Drop Notch Octa Core Processor \n",
"803 720 x 1600 px Display with Water Drop Notch Octa Core Processor \n",
"1344 540 x 1092 px Display Octa Core \n",
"\n",
" Processor_name \n",
"99 Helio \n",
"214 Unisoc SC9863A \n",
"802 Helio \n",
"803 Helio \n",
"1344 Helio G36 \n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0kAAAJLCAYAAAAyxt3/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzde3hTZbo28DtJSdNjbAqlRaQtoONUYASlM2UsuFUEURCd2aIjIDJWNoyjoltHGLFUlG51vsHTyEAdQcBRnO1hU6dW8QRlRMsWlMGo4yEtIsViAz3QpmmS9f2RnbZpDl1Js1bepPfvunpdNH1In6618q715F15H40kSRKIiIiIiIgIAKCNdgJEREREREQiYZFERERERETUC4skIiIiIiKiXlgkERERERER9cIiiYiIiIiIqBcWSURERERERL2wSCIiIiIiIuqFRRIREREREVEvLJKIiIiIiIh6YZFERERERETUC4skIlLEf//3f0Oj0fj9GjduXLTTIyIiIgooIdo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WlrwyCOPBPwdvV1zzTXIy8tDeXk5PvjgAzz++OM4ceIEtmzZ4rXtzjnnHMyZMwcJCQmorKzEsmXL4HK58Jvf/MYrn8WLF+Occ87BihUrcNppp+HAgQOorq7Gr371KwDu/XbFFVcgJycHt912G7Kzs/HZZ5/htddew2233QYA+PTTT/Hzn/8cp59+Ou655x6kpKTgxRdfxNy5c/HSSy95bZu+Ah0vADB06FCsW7cOAHDkyBE89thjmDVrFr799lucdtppEdum/XE4HPj973/v92c33HAD3nrrLfz2t7/FT37yE+h0OmzcuBH79++X9dznnnsu7rzzTq/HtmzZgp07d3o9dtNNN+HZZ5/FL3/5S9x555348MMPUV5ejs8++wyvvPJKd5ycfdrbzTffjOLiYgDuY733cwHAkiVLsHnzZtx444249dZbYbFY8OSTT+LAgQP4xz/+gSFDhsj6O0P1u9/9zu/jZWVlWL16NaZMmYL7778fer0eH374Id555x1ceumlePTRR9HW1gYA+Oyzz7B27VqvW4cDFa9dXV34xS9+gcOHD+Mf//gHcnJyAub21VdfoaKiYoB/IREpRiIiUsCjjz4qAZA++eQTr8enTZsmnXPOOV6Pbdq0SQIgWSwWSZIkyWazSaNGjZIuu+wyCYC0adOm7tj29naf3/X8889LAKTdu3d3P1ZaWioBkI4fPx4wx2nTpkkApP/3//5f92OdnZ3SueeeK2VlZUl2u12SJElyOBxSZ2en1/89ceKENHz4cGnx4sXdj1ksFgmAdN1110kJCQnSsWPHun928cUXS7/61a8kANIjjzzik+d1110nXXHFFd2P19fXS1qtVrruuut8/g5/22DJkiVScnKyZLPZAv69vX/fnDlzvB5ftmyZz/7y93tmzJghjR49uvv7kydPSmlpadJPf/pTqaOjwyvW5XJJkuTefvn5+VJubq504sQJvzGS5N5G48eP9/obXC6XNGXKFOnMM8/sfiyU4+WGG26QcnNzvX7nxo0bJQBSbW1t0L/V3zb1d/xKkiQ98sgjXjlJkiTl5uZKN9xwQ/f3Tz31lJSYmCj927/9m1dOHR0dklarlZYsWeL1nDfccIOUkpLi87v6ys3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n1zGTNmDLRardff/I9//AOXXHIJUlJScNppp2HYsGFYuXKl1+/5+uuvASDosu5yYr766itIkoRVq1Zh2LBhXl+e4qexsdHn//V3vADAt99+2/1cEydOxNdff42XXnrJ65apULbp559/HjDHQP74xz/CZrN1b7/eMjMzceaZZ+Lpp5/Gm2++icbGRvzww
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(cleaned_df[\"company\"].str.lower(), cleaned_df[\"Spec_score\"])\n",
"plt.xlabel(\"Фирма\")\n",
"plt.ylabel(\"Оценка характеристик\")\n",
"plt.xticks(rotation=45)\n",
"plt.title(\"Диаграмма рассеивания перед чисткой\")\n",
"plt.show()\n",
"\n",
"Q1 = cleaned_df[\"Spec_score\"].quantile(0.25)\n",
"Q3 = cleaned_df[\"Spec_score\"].quantile(0.75)\n",
"\n",
"IQR = Q3 - Q1\n",
"\n",
"threshold = 1.5 * IQR\n",
"lower_bound = Q1 - threshold\n",
"upper_bound = Q3 + threshold\n",
"\n",
"outliers = (cleaned_df[\"Spec_score\"] < lower_bound) | (\n",
" cleaned_df[\"Spec_score\"] > upper_bound\n",
")\n",
"\n",
"print(\"Выбросы в датасете:\")\n",
"print(cleaned_df[outliers])\n",
"\n",
"median_score = cleaned_df[\"Spec_score\"].median()\n",
"cleaned_df.loc[outliers, \"Spec_score\"] = median_score\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(cleaned_df[\"company\"].str.lower(), cleaned_df[\"Spec_score\"])\n",
"plt.xlabel(\"Фирма\")\n",
"plt.ylabel(\"Оценка характеристик\")\n",
"plt.xticks(rotation=45)\n",
"plt.title(\"Диаграмма рассеивания после чистки\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Разбиваем на выборки."
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Размер обучающей выборки: 489\n",
"Размер контрольной выборки: 164\n",
"Размер тестовой выборки: 164\n",
"\n",
"Распределение оценки характеристик в обучающей выборке:\n",
"Spec_score\n",
"75 48\n",
"86 35\n",
"80 34\n",
"84 32\n",
"85 23\n",
"78 23\n",
"83 23\n",
"77 19\n",
"79 19\n",
"82 18\n",
"89 17\n",
"88 17\n",
"71 16\n",
"73 15\n",
"72 13\n",
"74 13\n",
"87 12\n",
"69 11\n",
"76 10\n",
"81 10\n",
"67 9\n",
"90 9\n",
"70 8\n",
"68 8\n",
"91 8\n",
"64 7\n",
"93 7\n",
"92 6\n",
"66 5\n",
"94 4\n",
"63 4\n",
"96 2\n",
"95 1\n",
"65 1\n",
"60 1\n",
"61 1\n",
"Name: count, dtype: int64\n",
"\n",
"Распределение оценки характеристик в контрольной выборке:\n",
"Spec_score\n",
"75 18\n",
"81 12\n",
"74 11\n",
"79 9\n",
"82 9\n",
"85 9\n",
"84 8\n",
"86 8\n",
"76 7\n",
"78 7\n",
"77 7\n",
"83 6\n",
"89 5\n",
"71 5\n",
"72 5\n",
"80 4\n",
"70 4\n",
"88 3\n",
"68 3\n",
"65 3\n",
"73 3\n",
"67 2\n",
"87 2\n",
"63 2\n",
"95 2\n",
"93 2\n",
"90 2\n",
"94 1\n",
"66 1\n",
"92 1\n",
"69 1\n",
"98 1\n",
"61 1\n",
"Name: count, dtype: int64\n",
"\n",
"Распределение оценки характеристик в тестовой выборке:\n",
"Spec_score\n",
"75 15\n",
"84 13\n",
"76 11\n",
"82 10\n",
"81 9\n",
"80 9\n",
"77 8\n",
"83 8\n",
"86 7\n",
"89 6\n",
"78 6\n",
"79 6\n",
"87 5\n",
"71 5\n",
"74 5\n",
"85 5\n",
"70 4\n",
"94 3\n",
"72 3\n",
"73 3\n",
"66 3\n",
"91 3\n",
"88 3\n",
"92 3\n",
"93 2\n",
"96 1\n",
"64 1\n",
"90 1\n",
"67 1\n",
"62 1\n",
"65 1\n",
"68 1\n",
"95 1\n",
"69 1\n",
"Name: count, dtype: int64\n",
"\n"
]
}
],
"source": [
"train_df, test_df = train_test_split(cleaned_df, test_size=0.2, random_state=42)\n",
"\n",
"train_df, val_df = train_test_split(train_df, test_size=0.25, random_state=42)\n",
"\n",
"print(\"Размер обучающей выборки:\", len(train_df))\n",
"print(\"Размер контрольной выборки:\", len(val_df))\n",
"print(\"Размер тестовой выборки:\", len(test_df))\n",
"\n",
"print()\n",
"\n",
"\n",
"def check_balance(df, name):\n",
" counts = df[\"Spec_score\"].value_counts()\n",
" print(f\"Распределение оценки характеристик в {name}:\")\n",
" print(counts)\n",
" print()\n",
"\n",
"\n",
"check_balance(train_df, \"обучающей выборке\")\n",
"check_balance(val_df, \"контрольной выборке\")\n",
"check_balance(test_df, \"тестовой выборке\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Оверсемплинг и андерсемплинг"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Оверсэмплинг:\n",
"Распределение оценки характеристик в обучающей выборке:\n",
"Spec_score\n",
"85 48\n",
"78 48\n",
"75 48\n",
"82 48\n",
"64 48\n",
"73 48\n",
"79 48\n",
"87 48\n",
"86 48\n",
"80 48\n",
"70 48\n",
"83 48\n",
"68 48\n",
"74 48\n",
"71 48\n",
"72 48\n",
"66 48\n",
"93 48\n",
"77 48\n",
"88 48\n",
"69 48\n",
"89 48\n",
"84 48\n",
"94 48\n",
"76 48\n",
"95 48\n",
"90 48\n",
"63 48\n",
"81 48\n",
"67 48\n",
"91 48\n",
"92 48\n",
"96 48\n",
"65 48\n",
"60 48\n",
"61 48\n",
"Name: count, dtype: int64\n",
"\n",
"Распределение оценки характеристик в контрольной выборке:\n",
"Spec_score\n",
"75 18\n",
"94 18\n",
"72 18\n",
"82 18\n",
"70 18\n",
"74 18\n",
"68 18\n",
"88 18\n",
"71 18\n",
"80 18\n",
"92 18\n",
"86 18\n",
"66 18\n",
"81 18\n",
"84 18\n",
"79 18\n",
"73 18\n",
"76 18\n",
"67 18\n",
"95 18\n",
"78 18\n",
"85 18\n",
"83 18\n",
"77 18\n",
"89 18\n",
"98 18\n",
"69 18\n",
"90 18\n",
"87 18\n",
"65 18\n",
"63 18\n",
"93 18\n",
"61 18\n",
"Name: count, dtype: int64\n",
"\n",
"Распределение оценки характеристик в тестовой выборке:\n",
"Spec_score\n",
"80 15\n",
"94 15\n",
"82 15\n",
"77 15\n",
"75 15\n",
"79 15\n",
"96 15\n",
"83 15\n",
"76 15\n",
"71 15\n",
"64 15\n",
"78 15\n",
"84 15\n",
"91 15\n",
"74 15\n",
"93 15\n",
"87 15\n",
"89 15\n",
"81 15\n",
"66 15\n",
"86 15\n",
"92 15\n",
"88 15\n",
"73 15\n",
"90 15\n",
"67 15\n",
"85 15\n",
"72 15\n",
"62 15\n",
"70 15\n",
"65 15\n",
"68 15\n",
"95 15\n",
"69 15\n",
"Name: count, dtype: int64\n",
"\n",
"Андерсэмплинг:\n",
"Распределение оценки характеристик в обучающей выборке:\n",
"Spec_score\n",
"60 1\n",
"61 1\n",
"63 1\n",
"64 1\n",
"65 1\n",
"66 1\n",
"67 1\n",
"68 1\n",
"69 1\n",
"70 1\n",
"71 1\n",
"72 1\n",
"73 1\n",
"74 1\n",
"75 1\n",
"76 1\n",
"77 1\n",
"78 1\n",
"79 1\n",
"80 1\n",
"81 1\n",
"82 1\n",
"83 1\n",
"84 1\n",
"85 1\n",
"86 1\n",
"87 1\n",
"88 1\n",
"89 1\n",
"90 1\n",
"91 1\n",
"92 1\n",
"93 1\n",
"94 1\n",
"95 1\n",
"96 1\n",
"Name: count, dtype: int64\n",
"\n",
"Распределение оценки характеристик в контрольной выборке:\n",
"Spec_score\n",
"61 1\n",
"63 1\n",
"65 1\n",
"66 1\n",
"67 1\n",
"68 1\n",
"69 1\n",
"70 1\n",
"71 1\n",
"72 1\n",
"73 1\n",
"74 1\n",
"75 1\n",
"76 1\n",
"77 1\n",
"78 1\n",
"79 1\n",
"80 1\n",
"81 1\n",
"82 1\n",
"83 1\n",
"84 1\n",
"85 1\n",
"86 1\n",
"87 1\n",
"88 1\n",
"89 1\n",
"90 1\n",
"92 1\n",
"93 1\n",
"94 1\n",
"95 1\n",
"98 1\n",
"Name: count, dtype: int64\n",
"\n",
"Распределение оценки характеристик в тестовой выборке:\n",
"Spec_score\n",
"62 1\n",
"64 1\n",
"65 1\n",
"66 1\n",
"67 1\n",
"68 1\n",
"69 1\n",
"70 1\n",
"71 1\n",
"72 1\n",
"73 1\n",
"74 1\n",
"75 1\n",
"76 1\n",
"77 1\n",
"78 1\n",
"79 1\n",
"80 1\n",
"81 1\n",
"82 1\n",
"83 1\n",
"84 1\n",
"85 1\n",
"86 1\n",
"87 1\n",
"88 1\n",
"89 1\n",
"90 1\n",
"91 1\n",
"92 1\n",
"93 1\n",
"94 1\n",
"95 1\n",
"96 1\n",
"Name: count, dtype: int64\n",
"\n"
]
}
],
"source": [
"from imblearn.over_sampling import RandomOverSampler\n",
"from imblearn.under_sampling import RandomUnderSampler\n",
"\n",
"def oversample(df, target_column):\n",
" X = df.drop(target_column, axis=1)\n",
" y = df[target_column]\n",
"\n",
" oversampler = RandomOverSampler(random_state=42)\n",
" x_resampled, y_resampled = oversampler.fit_resample(X, y)\n",
"\n",
" resampled_df = pd.concat([x_resampled, y_resampled], axis=1)\n",
" return resampled_df\n",
"\n",
"\n",
"def undersample(df, target_column):\n",
" X = df.drop(target_column, axis=1)\n",
" y = df[target_column]\n",
"\n",
" undersampler = RandomUnderSampler(random_state=42)\n",
" x_resampled, y_resampled = undersampler.fit_resample(X, y)\n",
"\n",
" resampled_df = pd.concat([x_resampled, y_resampled], axis=1)\n",
" return resampled_df\n",
"\n",
"train_df_oversampled = oversample(train_df, \"Spec_score\")\n",
"val_df_oversampled = oversample(val_df, \"Spec_score\")\n",
"test_df_oversampled = oversample(test_df, \"Spec_score\")\n",
"\n",
"train_df_undersampled = undersample(train_df, \"Spec_score\")\n",
"val_df_undersampled = undersample(val_df, \"Spec_score\")\n",
"test_df_undersampled = undersample(test_df, \"Spec_score\")\n",
"\n",
"print(\"Оверсэмплинг:\")\n",
"check_balance(train_df_oversampled, \"обучающей выборке\")\n",
"check_balance(val_df_oversampled, \"контрольной выборке\")\n",
"check_balance(test_df_oversampled, \"тестовой выборке\")\n",
"\n",
"print(\"Андерсэмплинг:\")\n",
"check_balance(train_df_undersampled, \"обучающей выборке\")\n",
"check_balance(val_df_undersampled, \"контрольной выборке\")\n",
"check_balance(test_df_undersampled, \"тестовой выборке\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Начнем анализировать датасет №19.\n",
"\n",
"Ссылка на исходные данные: https://www.kaggle.com/datasets/surajjha101/forbes-billionaires-data-preprocessed\n",
"\n",
"**Общее описание**: «Миллиардеры мира» — это ежегодный рейтинг документально подтвержденного состояния богатейших миллиардеров мира, который составляется и публикуется ежегодно в марте американским деловым журналом Forbes. Список был впервые опубликован в марте 1987 года. Общий собственный капитал каждого человека в списке оценивается и указывается в долларах США на основе их документально подтвержденных активов, а также с учетом долга и других факторов. Члены королевской семьи и диктаторы, чье богатство обусловлено их положением, исключены из этих списков. Этот рейтинг представляет собой индекс самых богатых задокументированных людей, исключая любой рейтинг тех, кто обладает богатством, которое невозможно полностью установить.\n",
"\n",
"**Проблемная область**: Анализ состояния, возраста и источников богатства самых богатых людей в мире.\n",
"\n",
"**Объекты наблюдения**: Богатейшие люди мира, представленные в датасете.\n",
"\n",
"**Связи между объектами**: можно выявить следующие связи:\n",
"- Между возрастом и состоянием\n",
"- Между страной проживания и источником дохода\n",
"- Между отраслью бизнеса и уровнем благосостояния.\n",
"\n",
"**Бизнес цели**:\n",
"- ***Понять факторы успеха:***: Исследовать, какие факторы (возраст, страна, источник дохода) влияют на высокие состояния. Это может помочь новым предпринимателям и стартапам учиться на опыте успешных людей.\n",
"- ***Анализ тенденций богатства***: Понимание как источники богатства меняются со временем и как это связано с экономическими условиями в разных странах. Это непременно поможет инвесторам и аналитикам определить, какие секторы могут быть наиболее перспективными для инвестиций в будущем. \n",
"\n",
"**Цели технического проекта**:\n",
"1. ***Исследование факторов успеха***: Входные данные - данные о богатейших людях (возраст, чистая стоимость, индустрия); целевой признак - выявление факторов, способствующих накоплению состояния.\n",
"2. ***Анализ тенденций богатства***: Входные данные - данные о богатейших людях (возраст, страна, источник богатства); целевой признак - наличие зависимости между источником богатства и страной."
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['Rank ', 'Name', 'Networth', 'Age', 'Country', 'Source', 'Industry'], dtype='object')\n"
]
}
],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv(\"../data/Forbes Billionaires.csv\")\n",
"print(df.columns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Атрибуты:\n",
"- Ранг (Rank),\n",
"- Имя (Name),\n",
"- Общая стоимость (Networth),\n",
"- Возраст (Age),\n",
"- Страна (Country),\n",
"- Источник дохода(Source),\n",
"- Индустрия (Industry)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Посмотрим на связи."
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAasAAAEnCAYAAAAXY2zOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABnb0lEQVR4nO2dd3hUxfrHv9tLkt30BgESQidABEFIgIsgRUDaRQUuVcFCUxABlSZSBCuIFyt6LwJeRFHEn0oVwYAISFFEQm8JpG42m2yd3x+bPezZvmGTbMj7eZ48sGfmzHnPe+bMe2bmnXcEjDEGgiAIgghihDUtAEEQBEF4g4wVQRAEEfSQsSIIgiCCHjJWBEEQRNBDxoogCIIIeshYEQRBEEEP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EGD8Pbbbzvl6dWrF2JiYqBSqRAREYGnn34apaWlPskbExOD/v374+OPPwYAfPzxxxg7diyEQn5VOXv2LABg7NixiImJ4f19+OGH0Ov1KC4u5p1TXl6OoqIi/PDDD9y81Ny5c/HDDz+guLgYer3erVx5eXlQq9Ve5R8zZgwuX77MDdvt3LkTubm5GD16tE/3v2nTJsTExCAuLg69e/dGUlISPvzwQy790qVLSExMdPpoadGiBZduz8SJExEXF4cuXbpALBZj586dTo1dkyZNnORo2rQpb46moKAA06dPR1xcHBQKBWJiYrjhVJueb926BY1GwxsCrSy2+2jWrJlTWosWLbiGzJ527dqhdevW+M9//gPGGD755BOMH
"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/++y8CAgIU3lBClOnt27eIi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kACiehFdWmTRv8+eefWLRoEXbu3Mkdf/DgAQYNGoRhw4ZhxowZX2xTTk4O5s+fD39/f1SrVk1qmaysLLx//
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAbQAAAFiCAYAAACeUy10AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACLjElEQVR4nO3dd1RTydsH8G+ooRdBigKCnSZgW0Sx4dr7YkPF3rFgXwuiKOquDcVeQMVVEevaRRRURBER7DTBBopIE+nz/sGb+yMmtBQC2fmck6O592buk5DkycydwiKEEFAURVFUPScj6QAoiqIoShRoQqMoiqKkAk1oFEVRlFSgCY2iKIqSCjShURRFUVKBJjSKoihKKtCERlEURUkFmtAoiqIoqUATGkVRFCUVaEKjKIqipIJACS0hIQHTp0+HmZkZ2Gw21NXV4eDggB07duDnz5+ijpGiKIqiqiRX0wdcvnwZzs7OUFRUxPjx42FpaYnCwkLcu3cPixcvxosXL7B//35xxEpRFEVRFWLVZHLipKQkWFtbo3Hjxrh9+zYMDAy49sfHx+Py5cuYN2+eyAOlKIqiqMrUqMlx8+bNyM3NxaFDh3iSGQA0a9aMK5mxWCzmJisri0aNGmHatGnIzMzkelxiYiKcnZ1haGgIGRkZ5jGWlpbMMffu3UPnzp2ho6MDNpsNMzMzLF26FPn5+cwxfn5+YLFYiIyMrMnT4nqsgoICvn79yrUvPDycienXsiMiItCnTx9oaGhAWVkZXbt2xf3797mOWb58OdhsNtf2O3fugMVi4c6dO8y2+/fvg81mY/ny5TzxdevWjev15NzWrFnDHNO1a1e0adOG7/Nr2bIlevfuXelr0KRJE0yYMIFrW2BgIFgsFpo0acK1vbS0FDt27ICVlRXYbDZ0dXXRp08f5vXhF2v5W7du3Ziyvnz5gs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kried4jRowglpaWxMjIiOvvz0913tvR0dEEAJkyZQrX/kWLFhEA5Pbt24SQss+jmpoa6dixI/n58yffsqqKnaO65ySEEHt7e9K6dWuuc/D7bjQxMSH9+/fnORe/v8mv3zVLliwhDRs2JG3btuX6/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+Tu6u7tz7efUji9fvgwAuHnzJnJycrBs2TKe5yzI56Q65wTK3vtaWlrVOkdRURHP56SqloGPH
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAGVCAYAAADAPivmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tY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MH78+AplZWVlQV9fn3lfUFCAzMxM3Lx5k/khLVu2DE+ePIGGhgYKCwsrlJWeno7GjRtXqf+4ceNw9uxZ3Lt3D25ubrh9+zY+ffpU5eN3cnIygLK/By8qKiqwsbFh9ouLMJ1tbW2Rn5+PL1++wNjYGN+/f8emTZtw+PBhfPz4kbl5AGXnkEt8fDyGDBki0nEzMzOhpaVV5bi8vDzUq1ePed+gQQMsWLBAYCH54cOHfOPKnyddXV2YmJggKSlJJP0A4P79+wgMDERQUBDevXtX5fiEhAQA4HMvlefLly/Iz88X0A8AmjZtitLSUrx//x4ODg5inc/KEOeYrVq1grKyMtasWQNDQ0PGBVHe8HHhvZZFITExEXv37sXu3bsFJiySXLPOzs5o1qwZjh07hkWLFuHIkSP49ddf8f79e7H0AmRggE1NTfHy5UuxPjd27FiMGzcOpaWlSEhIwLp169C3b1/cvn0bLBYLWlpaOHv2LCZOnIiOHTvyfdbBwUFA3vnz55GdnY1nz55h8+bNMDMzw/r16/nG+Pv7w9bWFoWFhbh79y7++OMPAMCuXbtE0nnixIkYN24cZs+ejZCQEBw4cAD37t3jG8P9wfz+++9wdnYWKqe8AfDx8YGJiQk2bNgAT09PAMCzZ89w5swZLFu2DD4+P
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"\n",
"\n",
"# Связь между возрастом и состоянием\n",
"\n",
"plt.subplot(2, 2, 1)\n",
"\n",
"sns.scatterplot(data=df, x=\"Age\", y=\"Networth\")\n",
"\n",
"plt.title(\"Связь между возрастом и состоянием\")\n",
"\n",
"plt.xlabel(\"Возраст\")\n",
"\n",
"plt.ylabel(\"Состояние (млрд)\")\n",
"\n",
"plt.show()\n",
"\n",
"\n",
"\n",
"# Связь между страной проживания и состоянием (топ-10 стран)\n",
"\n",
"plt.subplot(2, 2, 2)\n",
"\n",
"top_countries = df[\"Country\"].value_counts().index[:10]\n",
"\n",
"sns.boxplot(data=df[df[\"Country\"].isin(top_countries)], x=\"Country\", y=\"Networth\")\n",
"\n",
"plt.title(\"Связь между страной проживания и состоянием\")\n",
"\n",
"plt.xticks(rotation=90)\n",
"\n",
"plt.xlabel(\"Страна\")\n",
"\n",
"plt.ylabel(\"Состояние (млрд)\")\n",
"\n",
"plt.show()\n",
"\n",
"\n",
"\n",
"# Связь между источником дохода и состоянием (топ-10 источников дохода)\n",
"\n",
"plt.subplot(2, 2, 3)\n",
"\n",
"top_sources = df[\"Source\"].value_counts().index[:10]\n",
"\n",
"sns.boxplot(data=df[df[\"Source\"].isin(top_sources)], x=\"Source\", y=\"Networth\")\n",
"\n",
"plt.title(\"Связь между источником дохода и состоянием\")\n",
"\n",
"plt.xticks(rotation=90)\n",
"\n",
"plt.xlabel(\"Источник дохода\")\n",
"\n",
"plt.ylabel(\"Состояние (млрд)\")\n",
"\n",
"plt.show()\n",
"\n",
"\n",
"# Связь между отраслью и состоянием (топ-10 отраслей)\n",
"\n",
"plt.subplot(2, 2, 4)\n",
"\n",
"top_industries = df[\"Industry\"].value_counts().index[:10]\n",
"\n",
"sns.boxplot(data=df[df[\"Industry\"].isin(top_industries)], x=\"Industry\", y=\"Networth\")\n",
"\n",
"plt.title(\"Связь между отраслью и состоянием\")\n",
"\n",
"plt.xticks(rotation=90)\n",
"\n",
"plt.xlabel(\"Отрасль\")\n",
"\n",
"plt.ylabel(\"Состояние (млрд)\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Перейдем к выявлению выбросов."
]
},
{
"cell_type": "code",
"execution_count": 65,
"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 = df.isnull().sum()\n",
"print(\"Пропущенные значения в данных:\\n\", missing_values)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Пропущенных данных не найдено.\n"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKMAAAHWCAYAAACrLUrEAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABKhklEQVR4nO3dd5RV5b0//s/MwAwdRLpIFUWUpihBr4KRKIgJMf5sQSMxRqIY201uTDBgzDVYYhI7eMUSMXZjIRYwBlADiCixYwErAiK9Dszs3x+uOV8OQxkQ9rTXa61Zi9n72c9+yjnDc95nn31ykiRJAgAAAABSkFveDQAAAACg+hBGAQAAAJAaYRQAAAAAqRFGAQAAAJAaYRQAAAAAqRFGAQAAAJAaYRQAAAAAqRFGAQAAAJAaYRR8A8XFxbF48eKYO3dueTcFAIAUWQcC7DxhFOygBQsWxEUXXRRt27aN/Pz8aNq0aXTp0iVWrFhR3k0DAGA3sg4E2DVqlHcDYFe566674sc//nHWtqZNm8YBBxwQ//M//xMDBw78xuf44IMP4qijjooNGzbEBRdcEAcddFDUqFEjateuHXXr1v3G9QMAsOOsAwEqF2EUVc4VV1wR7du3jyRJYuHChXHXXXfFcccdF08++WQcf/zx36juYcOGRX5+fkyfPj322muvXdRiAAB2BetAgMpBGEWVM3DgwOjVq1fm95/85CfRvHnzuO+++77RImTWrFnx/PPPx8SJEy1AAAAqIOtAgMrBPaOo8ho1ahS1a9eOGjX+X/b60UcfRU5OTvzxj3/c6nGXX3555OTkZH6fPn161KpVKz788MM44IADoqCgIFq0aBHDhg2LJUuWZB3br1+/OPDAA2PWrFlx2GGHRe3ataN9+/YxZsyYUudZtGhRZqFUq1at6N69e9x9992lyhUXF8f1118fXbt2jVq1akXTpk1jwIAB8corr2TK5OTkxPnnn7/VPt11112Rk5MTH3300VbLREQMHTo0cnJytvozefLkrPIPPfRQHHzwwVG7du1o0qRJnH766fH5559v8xwlli1bFhdffHG0a9cuCgoKonXr1vGjH/0oFi9evMvHaFt9ysnJiX79+u3wOUvKtWnTJvLy8jJ11atXL1NmW4+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/++9G0adNo165dj
"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=df, x='Networth', ax=axs[0])\n",
"axs[0].set_title(\"Выбросы по состоянию\")\n",
"\n",
"sns.boxplot(data=df, x=\"Age\", ax=axs[1])\n",
"axs[1].set_title(\"Выбросы по возрасту\")\n",
"\n",
"plt.show()\n",
"print(\"Размер данных до удаления выбросов: \", df.shape)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Выбросов в данном случае не видно, данные в районе допустимых значений"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA/YAAAIjCAYAAACpnIB8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB8/0lEQVR4nO3deVxU9f7H8fcMzAw7roDkRmou5VJaSuWSqWjWbfHXbbEyNbsZ1lXLylu5dcuyW2Zletu0zRYru6WlYq4ZmpmWaZmZRqXgCijrwJzfHzhHRhYRwZmB1/Px4BGc850znzPMl3zP93u+x2IYhiEAAAAAAOCXrN4uAAAAAAAAVB7BHgAAAAAAP0awBwAAAADAjxHsAQAAAADwYwR7AAAAAAD8GMEeAAAAAAA/RrAHAAAAAMCPEewBAAAAAPBjBHsAAAAAAPwYwR4AAKAWe/vtt7V7927z57lz5+qvv/7yXkEAgFNGsAeACpg7d64sFkuZX3/++ae3SwSASlmzZo0eeOAB7d69W0uWLFFiYqKsVv6JCAD+JNDbBQCAP5kyZYri4uJKbK9Xr54XqgGA0zdmzBj16tXL/Ns2duxYNWrUyMtVAQBOBcEeAE7BgAED1KVLF2+XAQBVpk2bNtq5c6d+/PFHNWjQQC1atPB2SQCAU8Q8KwCoQu4p+8WvV3W5XOrQoYMsFovmzp3r0f7nn3/W3//+dzVs2FDBwcFq3bq1Hn74YUnSpEmTyp3+b7FYtHLlSvNY8+fPV+fOnRUcHKwGDRrolltuKXGd7O23317qcVq2bGm2ad68ua688kotXbpUnTp1UlBQkNq1a6ePP/7Y41iHDh3S/fffr/bt2yssLEwREREaMGCAvv/+e492K1euNJ9n8+bNHvv++usvBQQEyGKx6MMPPyxRZ6dOnUq8xlOnTpXFYlF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L1++3JBk3HvvvSWeq7S/CaU9l9tzzz1nSDLefvttc1t+fr4RHx9vhIWFGZmZmYZhFPXXE/8u/f3vfzfOO+88o0mTJqX+vSnO12t2P99NN91ktG/f3tyelZVlREREmH973H/XT+VvaVX9/TaMU3vPAkBZmIoPANVo5syZOnjwoCZOnOixff/+/Vq9erWGDRumpk2beuw71amX3377rfbt26e7777bYyR74MCBatOmjRYtWnTKdcfGxuraa681f46IiNBtt92mTZs2KTU1VVLRyL975ezCwkIdPHhQYWFhat26tb777rsSx7zqqqtksVj06aefSioavfvzzz91ww03lFnHsGHDNG/ePOXl5UkqGmW77rrrFBkZWaJtcHCw+X1GRoYOHDignj176rffflNGRkaFznvUqFHm9+4R7/z8fC1btqzU5zl8+LAyMjLUvXt3j3P+5JNP5HK5NGHChBKri5/O1Nr4+Hh17tzZ/Llp06a6+uqrtWTJEhUWFsowDH300Ue66qqrZBiGDhw4YH4lJCQoIyOjxO/GPWJZ2iwIt82bN2vHjh26+eabdfDgQfOYWVlZuvzyy7V69Wq5XC6Px+Tn58vhcJR5zKSkJKWnp+umm27yqDMgIEBdu3bVihUrSjymeLsDBw7oyJEj5b5ehmFo/PjxGjRokLp27Vpi/5EjR1S/fv1yj1GWqKioU74bRnZ2tqZMmaJRo0aV6PcfffSRLBZLib8V0qm/Zz7//HPFxMTopptuMrfZbDbde++9Onr0qFatWlXq4zZu3Kj58+dr6tSpFVoV319qvvXWW/Xzzz+bU+4/+ugjRUZG6vLLL/doV9G/pVX59/tEJ3vPAkBZCPYAUE0yMjL0xBNPaOzYseZ0U7fff
"text/plain": [
"<Figure size 1200x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Гистограмма распределения чистой стоимости\n",
"plt.figure(figsize=(12, 6))\n",
"sns.histplot(df['Networth'], bins=10, kde=True)\n",
"plt.title(\"Гистограмма распределения чистой стоимости\")\n",
"plt.xlabel(\"Чистая стоимость (в миллиардах долларов)\")\n",
"plt.ylabel(\"Частота\")\n",
"plt.grid(True)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Распределение чистой стоимости имеет ярко выраженное смещение: большая часть значений сосредоточена в нижнем диапазоне, с небольшим количеством высоких значений. Это указывает на преобладание людей с относительно низкой чистой стоимостью, тогда как у немногих (например, миллиардеров) чистая стоимость крайне высока."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABAwAAAKICAYAAAD0EmiCAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3QU5dvG8XtTgZBCIIXQA6GETmihl0joVRBEuqAISJOmNOlFBZGqIqACKh2RXhSVIlXpItIEQiehpd/vH7w7v6wTIISQBPx+ztlzkpnZee6Znd2dueaZWYuqqgAAAAAAACRgl9YFAAAAAACA9IfAAAAAAAAAmBAYAAAAAAAAEwIDAAAAAABgQmAAAAAAAABMCAwAAAAAAIAJgQEAAAAAADAhMAAAAAAAACYEBgAAAAAAwITAAAAApDuHDx+WlStXGv8fPHhQfvjhh7QrCACA/yACAwBAks2fP18sFovs3bvXNO6zzz4Ti8UiTZs2lbi4uDSoDi+S27dvyxtvvCG7du2SkydPSu/eveXQoUNpXRYAAP8pDmldAADg+bdixQrp3r27VK1aVb755huxt7dP65LwnAsODjYeIiIFCxaUrl27pnFVAAD8txAYAACeyo8//iht2rSRwMBA+f777yVDhgxpXRJeECtXrpSjR4/K/fv3pXjx4uLk5JTWJQEA8J/CJQkAgGQ7ePCgNGnSRLJnzy4bNmwQd3d30zRLliyRoKAgyZgxo2TLlk1ee+01uXDhQqLzs1gsiT7OnDljM83IkSNtnjd58mSxWCxSo0YNY9jIkSPFYrGY2sibN6907NjRZtitW7ekT58+kitXLnF2dpYCBQrIxIkTJ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b6Rly5ayZs0aadCgwROtp+TMM0OGDDJv3jzp06ePMWzHjh1y9uzZZLUNAEjHFACAJJo3b56KiK5Zs0bz58+vIqJ16tRJdNro6Gj19vbWYsWK6f37943ha9asURHR4cOH20wfExOjIqLvv/++qb3Tp08bw0RER4wYYfw/cOBA9fb21qCgIK1evbox/P3331cR0fj4eJt28uTJox06dDD+Hz16tLq4uOiff/5pM93gwYPV3t5ez507p6qqW7duVRHRt99+27Ss/27jYbVbbdu2TUVEt23bZgyLjIxUOzs7feutt4xhTZs2VScnJz116pQx7OLFi+rq6qrVqlUzzTcx7733nlosFpth/14H/641KChI3d3dNSwszJjmzz//VEdHR23RooWpjUqVKmmxYsWM/69evWp6nc6cOaP29vY6duxYm+ceOnRIHRwcbIZXr17d5rVcu3atiojWrVtXk7LrUr16dS1atKhp+OTJk22W88qVK+rk5KR16tTRuLg4Y7rp06eriOgXX3zxyHbat2+vdnZ2umfPHtO4xLaJfy9XQh06dFAR0V69etnMo0GDBurk5KRXr141ht+7d8/mudHR0VqsWDGtVauWzXAR0R49epjaatCggebJk8dm2JPM8+WXX1YHBwfdu3evMbxLly766quvPrRNAMDziUsSAABPrGPHjnL+/Hl59dVXZePGjbJkyRLTNHv37pUrV67IW2+9ZXNfgwYNGkjhwoVNP5EXHR0tIiLOzs5JruPChQvyySefyLBhwyRz5sw247y9vUVE5J9//nnkPJYsWSJVq1aVLFmyyLVr14xHSEiIxMXFyfbt20VEZNmyZWKxWGTEiBGmeSSlm3xiwsPD5dq1a3Lu3DmZNGmSxMfHS61atUTkwdnmjRs3StOmTcXf3994Tvbs2eXVV1+VX375RSIiIh7bRnR0dJLX6c2bN+XPP/+Uffv2Sdu2bW16RAQEBEjjxo1l/fr1pl/BiIyMfOy9K5YvXy7x8fHSqlUrm/Xs6+srAQEBsm3btkSfp6oyZMgQadGixRP1qEiKzZs3S3R0tPTp00fs7P63S9S1a1dxc3N75M84xsfHy8qVK6VRo0ZStmxZ0/jkbhMJu/Nbu/dHR0fL5s2bjeEZM2Y0/r5586aEh4dL1apVZf/+/ab5RUZG2qzva9euSUxMjGm6J5mnj4+PNGjQQObNmyciD3rpfPfdd9KpU6dkLTMAIP3ikgQAwBO7ceOGfPPNN9KsWTM5evSo9O7dW+rUqWNzDwNr9+RChQqZnl+4cGH55ZdfbIZZrxn/94H/o4wYMUL8/PzkjTfeMF1vHRwcLBaLRYYMGSJjxowx5vvv+xKcPHlS/vjjD/Hy8kq0jStXrojIg0sw/Pz8xNPTM8n1PU7Tpk2Nv+3s7GTo0KHSokULERG5evWq3Lt3L9H1V6RIEYmPj5fz589L0aJFH9nGrVu3krxOy5QpY/z9sHaXLVsm165dswkTrl27JgEBAY+c98mTJ0VVHzrdw7r+L1y4UI4cOSLfffedLFq0KCmLkWQP20adnJzE39//kV3sr169KhEREVKsWLEUq8fOzs4mHBIR4/KPhPddWLNmjYwZM0YOHjwoUVFRxvDEQoq5c+fK3LlzTcPz5Mlj8/+TzFNEpFOnTtKpUyf58MMPZcmSJZIlSxYj7AIAvDgIDAAAT2zy5MnSsmVLERH59NNPpWLFijJkyBCZOXNmsucZFhYmIiK+vr5Jmv7YsWMyf/58+frrrxM92CxZsqSMGDFC3n//fVm4cOFD5xMfHy8vvfSSDBw4MNHxiV2vn1I++OADKVmypMTExMiePXtkzJgx4uDgkGgvhuQKCwtL8jr9+uuv5d69e9KtW7ckzz86OlouXbokL7300iOni4+PF4vFIuvWrUv0ZzcTCzWio6Nl2LBh0qVLl2f6OjxPfv75Z2ncuLFUq1ZNZs6cKdmzZxdHR0eZN29eooFKkyZNTDchHDp0qPF+S848RR70FHJycpKVK1fKvHnzpEOHDja9NAAALwYCAwDAE6tWrZrxd7ly5aRHjx4yY8YMad++vVSsWFFE/ncG88SJE6YzjydOnDCd4Tx69
"text/plain": [
"<Figure size 1200x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABAsAAAKpCAYAAADaPqVoAAA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YaOqz4J9//hERkUKFCsW6f+HCheX33383TbNdI/70Sf/zjBgxQry8vKRbt26xrn/29/cXi8UiwcHB8vHHHxvrfbofgpMnT8qhQ4ckW7ZscW7j2rVrIvLksgsvLy9xc3N76fpepGnTpsbfqVKlko8++khatGghIiLXr1+X+/fvx/n4FSlSRKxWq1y4cEGKFi363G3cuXPnpR/TMmXKGH8/a7vLly+XGzdumIKEGzduSIECBZ677pMnT4qqPnO5ZzX3X7RokRw9elR++OEHWbx48cvsxkt71jHq4OAgefPmNebHJaGen6elSpXKFD6IiHHZR8y+FtasWSMff/yxHDx4UCIjI43pMUOA06dPS6pUqcTX1/eF232Z11+hQoUkc+bM8tlnn4mvr69xGcKjR4/iXD5t2rTSrl07mTdvnrRs2VLmzZsnLVq0EBcXlxfWAwBImggLAADPNXHiRGnVqpWIPLmuuWLFihIcHCyzZs2K9zpDQ0NFRMTDw+Ollv/rr79kwYIFsnDhwjhPNEuWLCkjRoyQUaNGyaJFi565HqvVKnXq1JHBgwfHOT+u6/MTyqRJk6RkyZLy6NEj2bt3r3z88ceSJk2aOFsvxFdoaOhLP6YLFy6U+/fvS9euXV96/VFRUXLlyhWpU6fOc5ezWq1isVhk3bp1cQ6tGddJalRUlAwbNkw6d+78Wp+H5Oa3336Tx
"text/plain": [
"<Figure size 1200x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA1IAAAHWCAYAAAB9mLjgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB8xElEQVR4nOzdd3wUdeLG8c/upvfeCxAghI4gGLGLAqKiYIFDxe6d4Nl+Fs6zn/3O3nvD3lA8QAQBkV5CDS2UAOm9t935/RHJGakJm0zK83699iWZnf3Os+NC8mRmvmMxDMNAREREREREjpnV7AAiI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gG+++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/bLS8oqKCvLw8UlJSeOuttwgPD6dnz56N1klOTmbw4MENX8fFxTF27FjmzJmD3W4HaDg6eSBjfn4+3bt3JyAg4KDP6YABA7j44osPem9N/Zwe6zZFRFqbTu0TEWkFr7zyCj179sTFxYXw8HASExMbihPUnw72wgsv8Oqrr7Jr166GH1zhf6f/Qf0pgYmJibi4OPef7x49ejT62mKx0L1794brULZv3w7A5MmTDztGcXExgYGBDV/n5eUdNO6fbd++HcMwDrven0/BKyoqAjiovPx5zOLiYsLCwg75fE5OTqOvf/rpJ0JDQ4+Y888efPBBoqKiuOmmm/jqq68O2n5qauphx/zz9g9lyZIljV7fo0cPvvvuu4YSsmfPHqxWK927d2/0uoiICAICAtizZ0+j5Y888ghPPfVUw1gLFixoVJwPLP+znj17UlFRQW5uLhEREVRWVvLEE0/w3nvvsX//fgzDaFi3uLi44c9paWmMHz/+qO/zWBzrNkVEWpuKlIhIKxg6dGjDrH2H8vjjj3P//fdz7bXX8uijjxIUFITVauW222476EiPGQ5keOaZZxg4cOAh1/ljuampqSEzM5NzzjnnqONaLBZmzZqFzWY74pgAWVlZQH1hONKYYWFhTJ8+/ZDP/7ngDBs2jH/961+Nlr388svMmDHjkK9PTU3l/fff5+OPPz7ktVYOh4N+/frx7LPPHvL1sbGxh81+QP/+/fnPf/4DQG5uLi+++CJnnHEGa9asafTej/XozvXXX8/ZZ5/Nvn37eO655xg/fjxLlizB39//mF5/wC233MJ7773HbbfdRnJyMv7+/lgsFiZMmNBin1MztikicixUpERE2oCvvvqKM888k3feeafR8qKioobTuQASEhJYvnw5tbW1Tpkw4YADR5wOMAyDHTt2NFzwf2ASCz8/P0aMGHHU8datW0dtbe0Ry+OBcQ3DoGvXrgedanYomzdvxmKxkJiYeMQxf/75Z4YPH97otLDDCQkJOeg9HWlCiGnTpjFw4EAuv/zyw25/3bp1nH322c0+3TIwMLBRpjPOOIOoqCjee+89pk2bRnx8PA6Hg+3bt5OUlNSwXnZ2NkVFRcTHxzcar3v37g1Hr0aMGEFcXByffPJJo8k//vwZANi2bRteXl4N5fOrr75i8uTJDSUP6k/hPHCk8I/74M+zDDbXsW5TRKS16RopEZE2wGazNTplCeqvtdm/f3+jZePHjycvL4+XX375oDH+/Pqm+PDDDyktLW34+quvviIzM5PRo
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# 1. Столбчатая диаграмма по странам\n",
"\n",
"plt.figure(figsize=(12, 6))\n",
"\n",
"sns.countplot(data=df, x=\"Country\", order=df[\"Country\"].value_counts().index)\n",
"\n",
"plt.title(\"Количество людей по странам\")\n",
"\n",
"plt.xlabel(\"Страна\")\n",
"\n",
"plt.ylabel(\"Количество\")\n",
"\n",
"plt.xticks(rotation=45)\n",
"\n",
"plt.show()\n",
"\n",
"\n",
"# 2. Столбчатая диаграмма по отраслям\n",
"\n",
"plt.figure(figsize=(12, 6))\n",
"\n",
"sns.countplot(data=df, x=\"Industry\", order=df[\"Industry\"].value_counts().index)\n",
"\n",
"plt.title(\"Количество людей по отраслям\")\n",
"\n",
"plt.xlabel(\"Отрасль\")\n",
"\n",
"plt.ylabel(\"Количество\")\n",
"\n",
"plt.xticks(rotation=45)\n",
"\n",
"plt.show()\n",
"\n",
"\n",
"# 3. Гистограмма для анализа возраста\n",
"\n",
"plt.figure(figsize=(10, 5))\n",
"\n",
"sns.histplot(df[\"Age\"], bins=30, kde=True)\n",
"\n",
"plt.title(\"Распределение возраста\")\n",
"\n",
"plt.xlabel(\"Возраст\")\n",
"\n",
"plt.ylabel(\"Частота\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Графики демонстрируют разнообразие стран и отраслей, представленных в наборе данных, что указывает на охват данных по множеству регионов и различных сфер деятельности.\n",
"\n",
"Разбиваем набор данных на обучающую, контрольную и тестовую выборки"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((1560, 6), (520, 6), (520, 6))"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.model_selection import train_test_split\n",
"\n",
"# Разделим набор данных на признаки (X) и целевой признак (y)\n",
"X = df.drop(columns=[\"Networth\"])\n",
"y = df[\"Networth\"]\n",
"\n",
"# Разделение на обучающую, контрольную и тестовую выборки\n",
"X_train, X_temp, y_train, y_temp = train_test_split(\n",
" X, y, test_size=0.4, random_state=42\n",
")\n",
"X_val, X_test, y_val, y_test = train_test_split(\n",
" X_temp, y_temp, test_size=0.5, random_state=42\n",
")\n",
"\n",
"# Проверка размера выборок\n",
"(X_train.shape, X_val.shape, X_test.shape)"
]
},
{
"cell_type": "code",
"execution_count": 68,
"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": 68,
"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": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Размеры после oversampling: (13910, 10047) (13910,)\n",
"Размеры после undersampling: (13065, 10047) (13065,)\n"
]
}
],
"source": [
"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)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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"
}
2024-10-26 01:15:17 +04:00
},
2024-11-09 10:04:05 +04:00
"nbformat": 4,
"nbformat_minor": 2
}