2024-10-26 12:47:48 +04:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-11-09 11:59:00 +04:00
"*Вариант задания:* Заработная плата рабочих мест в области Data Science (вариант - 8) \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Бизнес-цели для датасета о заработной плате в Data Science:\n",
"Оптимизация стратегии найма и оплаты труда в Data Science\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Формулировка: Разработать модель, которая позволяет точно прогнозировать и оптимизировать заработную плату для специалистов в области Data Science на основе их опыта, типа занятости, местоположения и других факторов.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Цель: Увеличить привлекательность компании для талантливых специалистов в Data Science, обеспечивая конкурентоспособные зарплаты, а также оптимизировать расходы на персонал, избегая переплат и недоплат.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Ключевые показатели успеха (KPI):\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Точность модели прогнозирования зарплаты (RMSE): Минимизация среднеквадратичной ошибки до уровня ниже 10% от реальной зарплаты, чтобы учитывать большие отклонения в оценке.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Средняя абсолютная ошибка (MAE): Модель должна предсказать зарплату с минимальной ошибкой и снизить MAE до 5% или меньше, учитывая большие отклонения в оценке.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Скорость оценки зарплаты: Уменьшение времени на оценку зарплаты для новых сотрудников, чтобы быстрее принимать решения о найме.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Доступность: Внедрение модели в систему управления персоналом для использования HR-специалистами.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Оптимизация распределения ресурсов в компании\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Формулировка: Разработать модель, которая поможет компаниям определить оптимальное распределение ресурсов (бюджета) на Data Science проекты и команды, учитывая уровень зарплат, опыт и другие факторы.\n",
"\n",
"Цель: Снизить затраты на Data Science проекты, оптимизировать распределение бюджета, обеспечивая максимальную эффективность и результативность проектов.\n",
"\n",
"Ключевые показатели успеха (KPI):\n",
"\n",
"Возврат инвестиций (ROI): Проекты должны показывать не менее 20% прироста в результатах (например, увеличение прибыли, улучшение показателей) на каждый вложенный доллар в Data Science.\n",
"\n",
"Средняя стоимость проекта на 1 сотрудника (CPA): Задача снизить расходы на проекты, минимизировав ненужные траты. Например, оптимизация затрат до $50,000 на проект с учетом максимального прироста в результатах.\n",
"\n",
"Сокращение времени на принятие решений: Модель должна сокращать время, необходимое на оценку вариантов распределения ресурсов, до нескольких минут, что ускорит принятие решений.\n",
"\n",
"Оптимизация стратегии развития карьеры в Data Science\n",
"\n",
"Формулировка: Разработать модель, которая поможет специалистам в Data Science определить оптимальные пути развития карьеры, учитывая текущий уровень зарплаты, опыт и перспективы роста.\n",
"\n",
"Цель: Повысить удовлетворенность и мотивацию специалистов в Data Science, обеспечивая им четкие пути развития карьеры и возможность получения конкурентоспособных зарплат.\n",
"\n",
"Ключевые показатели успеха (KPI):\n",
"\n",
"Уровень удовлетворенности сотрудников: Увеличение уровня удовлетворенности сотрудников на 15% за счет предоставления четких путей развития карьеры и возможностей для роста.\n",
"\n",
"Средний срок пребывания в компании: Увеличение среднего срока пребывания сотрудников в компании на 20% за счет предоставления привлекательных перспектив развития.\n",
"\n",
"Доступность: Внедрение модели в систему управления карьерой для использования сотрудниками и HR-специалистами.\n",
"\n",
"**Технические цели проекта для каждой выделенной бизнес-цели**\n",
"\n",
"Оптимизация стратегии найма и оплаты труда в Data Science\n",
"\n",
"С б о р и подготовка данных:\n",
"\n",
"С б о р данных: Получение данных о заработных платах специалистов в Data Science из различных источников (например, Glassdoor, LinkedIn, Kaggle).\n",
"\n",
"Очистка данных: Удаление пропусков, выбросов и дубликатов. Преобразование категориальных переменных (например, experience_level, employment_type, employee_residence, company_location) в числовую форму с использованием One-Hot Encoding.\n",
"\n",
"Нормализация и стандартизация: Применение методов масштабирования данных (нормировка, стандартизация) для числовых признаков (например, salary_in_usd, remote_ratio).\n",
"\n",
"Разбиение данных: Разделение набора данных на обучающую, контрольную и тестовую выборки для предотвращения утечек данных и переобучения.\n",
"\n",
"Разработка и обучение модели:\n",
"\n",
"Исследование моделей: Эксперименты с различными алгоритмами (линейная регрессия, случайный лес, градиентный бустинг, деревья решений) для предсказания заработной платы.\n",
"\n",
"Обучение модели: Обучение модели на обучающей выборке с использованием метрик оценки качества, таких как RMSE (Root Mean Square Error) и MAE (Mean Absolute Error).\n",
"\n",
"Оценка качества: Оценка качества моделей на тестовой выборке, минимизируя MAE и RMSE для получения точных прогнозов заработной платы.\n",
"\n",
"Развёртывание модели:\n",
"\n",
"Интеграция модели: Интеграция модели в существующую систему управления персоналом или разработка API для доступа к модели.\n",
"\n",
"Создание интерфейса: Создание веб-приложения или мобильного интерфейса для удобного использования модели и получения прогнозов в режиме реального времени.\n",
"\n",
"Оптимизация распределения ресурсов в компании\n",
"\n",
"С б о р и подготовка данных:\n",
"\n",
"С б о р данных: Получение данных о затратах на Data Science проекты, результатах проектов, уровнях зарплат сотрудников и других релевантных факторов.\n",
"\n",
"Очистка данных: Удаление пропусков, выбросов и дубликатов. Преобразование категориальных переменных в числовую форму с использованием One-Hot Encoding.\n",
"\n",
"Нормализация и стандартизация: Применение методов масштабирования данных для числовых признаков.\n",
"\n",
"Разбиение данных: Разделение набора данных на обучающую, контрольную и тестовую выборки.\n",
"\n",
"Разработка и обучение модели:\n",
"\n",
"Исследование моделей: Эксперименты с различными алгоритмами (линейная регрессия, случайный лес, градиентный бустинг) для предсказания оптимального распределения ресурсов.\n",
"\n",
"Обучение модели: Обучение модели на обучающей выборке с использованием метрик оценки качества, таких как ROI (Return on Investment) и CPA (Cost Per Acquisition).\n",
"\n",
"Оценка качества: Оценка качества моделей на тестовой выборке, минимизируя CPA и максимизируя ROI.\n",
"\n",
"Развёртывание модели:\n",
"\n",
"Интеграция модели: Интеграция модели в систему управления проектами или разработка API для доступа к модели.\n",
"\n",
"Создание интерфейса: Создание веб-приложения или мобильного интерфейса для удобного использования модели и получения рекомендаций по распределению ресурсов.\n",
"\n",
"Оптимизация стратегии развития карьеры в Data Science\n",
"\n",
"С б о р и подготовка данных:\n",
"\n",
"С б о р данных: Получение данных о карьерных траекториях специалистов в Data Science, уровнях зарплат, опыте и других релевантных факторах.\n",
"\n",
"Очистка данных: Удаление пропусков, выбросов и дубликатов. Преобразование категориальных переменных в числовую форму с использованием One-Hot Encoding.\n",
"\n",
"Нормализация и стандартизация: Применение методов масштабирования данных для числовых признаков.\n",
"\n",
"Разбиение данных: Разделение набора данных на обучающую, контрольную и тестовую выборки.\n",
"\n",
"Разработка и обучение модели:\n",
"\n",
"Исследование моделей: Эксперименты с различными алгоритмами (линейная регрессия, случайный лес, градиентный бустинг) для предсказания оптимальных путей развития карьеры.\n",
"\n",
"Обучение модели: Обучение модели на обучающей выборке с использованием метрик оценки качества, таких как MAE (Mean Absolute Error) и RMSE (Root Mean Square Error).\n",
"\n",
"Оценка качества: Оценка качества моделей на тестовой выборке, минимизируя MAE и RMSE.\n",
"\n",
"Развёртывание модели:\n",
"\n",
"Интеграция модели: Интеграция модели в систему управления карьерой или разработка API для доступа к модели.\n",
"\n",
"Создание интерфейса: Создание веб-приложения или мобильного интерфейса для удобного использования модели и получения рекомендаций по развитию карьеры."
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 2,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"Index(['work_year', 'experience_level', 'employment_type', 'job_title',\n",
" 'salary', 'salary_currency', 'salary_in_usd', 'employee_residence',\n",
" 'remote_ratio', 'company_location', 'company_size'],\n",
2024-10-26 12:47:48 +04:00
" dtype='object')\n"
]
}
],
"source": [
"import pandas as pd\n",
2024-11-09 11:59:00 +04:00
"df = pd.read_csv(\"..//static//csv//ds_salaries.csv\")\n",
2024-10-26 12:47:48 +04:00
"print(df.columns)"
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 3,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
2024-11-09 11:59:00 +04:00
" <th>work_year</th>\n",
" <th>experience_level</th>\n",
" <th>employment_type</th>\n",
" <th>job_title</th>\n",
" <th>salary</th>\n",
" <th>salary_currency</th>\n",
" <th>salary_in_usd</th>\n",
" <th>employee_residence</th>\n",
" <th>remote_ratio</th>\n",
" <th>company_location</th>\n",
" <th>company_size</th>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023</td>\n",
" <td>SE</td>\n",
" <td>FT</td>\n",
" <td>Principal Data Scientist</td>\n",
" <td>80000</td>\n",
" <td>EUR</td>\n",
" <td>85847</td>\n",
" <td>ES</td>\n",
" <td>100</td>\n",
" <td>ES</td>\n",
" <td>L</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023</td>\n",
" <td>MI</td>\n",
" <td>CT</td>\n",
" <td>ML Engineer</td>\n",
" <td>30000</td>\n",
" <td>USD</td>\n",
" <td>30000</td>\n",
" <td>US</td>\n",
" <td>100</td>\n",
" <td>US</td>\n",
" <td>S</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023</td>\n",
" <td>MI</td>\n",
" <td>CT</td>\n",
" <td>ML Engineer</td>\n",
" <td>25500</td>\n",
" <td>USD</td>\n",
" <td>25500</td>\n",
" <td>US</td>\n",
" <td>100</td>\n",
" <td>US</td>\n",
" <td>S</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023</td>\n",
" <td>SE</td>\n",
" <td>FT</td>\n",
" <td>Data Scientist</td>\n",
" <td>175000</td>\n",
" <td>USD</td>\n",
" <td>175000</td>\n",
" <td>CA</td>\n",
" <td>100</td>\n",
" <td>CA</td>\n",
" <td>M</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023</td>\n",
" <td>SE</td>\n",
" <td>FT</td>\n",
" <td>Data Scientist</td>\n",
" <td>120000</td>\n",
" <td>USD</td>\n",
" <td>120000</td>\n",
" <td>CA</td>\n",
" <td>100</td>\n",
" <td>CA</td>\n",
" <td>M</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2024-11-09 11:59:00 +04:00
" work_year experience_level employment_type job_title \\\n",
"0 2023 SE FT Principal Data Scientist \n",
"1 2023 MI CT ML Engineer \n",
"2 2023 MI CT ML Engineer \n",
"3 2023 SE FT Data Scientist \n",
"4 2023 SE FT Data Scientist \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
" salary salary_currency salary_in_usd employee_residence remote_ratio \\\n",
"0 80000 EUR 85847 ES 100 \n",
"1 30000 USD 30000 US 100 \n",
"2 25500 USD 25500 US 100 \n",
"3 175000 USD 175000 CA 100 \n",
"4 120000 USD 120000 CA 100 \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
" company_location company_size \n",
"0 ES L \n",
"1 US S \n",
"2 US S \n",
"3 CA M \n",
"4 CA M "
2024-10-26 12:47:48 +04:00
]
},
2024-11-09 11:59:00 +04:00
"execution_count": 3,
2024-10-26 12:47:48 +04:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Для наглядности\n",
"df.head()"
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 4,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
2024-11-09 11:59:00 +04:00
" <th>work_year</th>\n",
" <th>salary</th>\n",
" <th>salary_in_usd</th>\n",
" <th>remote_ratio</th>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
2024-11-09 11:59:00 +04:00
" <td>3755.000000</td>\n",
" <td>3.755000e+03</td>\n",
" <td>3755.000000</td>\n",
" <td>3755.000000</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2022.373635</td>\n",
" <td>1.906956e+05</td>\n",
" <td>137570.389880</td>\n",
" <td>46.271638</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
2024-11-09 11:59:00 +04:00
" <td>0.691448</td>\n",
" <td>6.716765e+05</td>\n",
" <td>63055.625278</td>\n",
" <td>48.589050</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2020.000000</td>\n",
" <td>6.000000e+03</td>\n",
" <td>5132.000000</td>\n",
2024-10-26 12:47:48 +04:00
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2022.000000</td>\n",
" <td>1.000000e+05</td>\n",
" <td>95000.000000</td>\n",
2024-10-26 12:47:48 +04:00
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2022.000000</td>\n",
" <td>1.380000e+05</td>\n",
" <td>135000.000000</td>\n",
2024-10-26 12:47:48 +04:00
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023.000000</td>\n",
" <td>1.800000e+05</td>\n",
" <td>175000.000000</td>\n",
" <td>100.000000</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
2024-11-09 11:59:00 +04:00
" <td>2023.000000</td>\n",
" <td>3.040000e+07</td>\n",
" <td>450000.000000</td>\n",
" <td>100.000000</td>\n",
2024-10-26 12:47:48 +04:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2024-11-09 11:59:00 +04:00
" work_year salary salary_in_usd remote_ratio\n",
"count 3755.000000 3.755000e+03 3755.000000 3755.000000\n",
"mean 2022.373635 1.906956e+05 137570.389880 46.271638\n",
"std 0.691448 6.716765e+05 63055.625278 48.589050\n",
"min 2020.000000 6.000000e+03 5132.000000 0.000000\n",
"25% 2022.000000 1.000000e+05 95000.000000 0.000000\n",
"50% 2022.000000 1.380000e+05 135000.000000 0.000000\n",
"75% 2023.000000 1.800000e+05 175000.000000 100.000000\n",
"max 2023.000000 3.040000e+07 450000.000000 100.000000"
2024-10-26 12:47:48 +04:00
]
},
2024-11-09 11:59:00 +04:00
"execution_count": 4,
2024-10-26 12:47:48 +04:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Описание данных (основные статистические показатели)\n",
"df.describe()"
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 5,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"work_year 0\n",
"experience_level 0\n",
"employment_type 0\n",
"job_title 0\n",
"salary 0\n",
"salary_currency 0\n",
"salary_in_usd 0\n",
"employee_residence 0\n",
"remote_ratio 0\n",
"company_location 0\n",
"company_size 0\n",
2024-10-26 12:47:48 +04:00
"dtype: int64\n"
]
},
{
"data": {
"text/plain": [
2024-11-09 11:59:00 +04:00
"work_year False\n",
"experience_level False\n",
"employment_type False\n",
"job_title False\n",
"salary False\n",
"salary_currency False\n",
"salary_in_usd False\n",
"employee_residence False\n",
"remote_ratio False\n",
"company_location False\n",
"company_size False\n",
2024-10-26 12:47:48 +04:00
"dtype: bool"
]
},
2024-11-09 11:59:00 +04:00
"execution_count": 5,
2024-10-26 12:47:48 +04:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Процент пропущенных значений признаков\n",
"for i in df.columns:\n",
" null_rate = df[i].isnull().sum() / len(df) * 100\n",
" if null_rate > 0:\n",
" print(f'{i} Процент пустых значений: %{null_rate:.2f}')\n",
"\n",
"# Проверка на пропущенные данные\n",
"print(df.isnull().sum())\n",
"\n",
"df.isnull().any()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Разбиваем на выборки (обучающую, тестовую, контрольную)"
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 6,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"Размер обучающей выборки: 3004\n",
"Размер контрольной выборки: 751\n",
"Размер тестовой выборки: 751\n"
2024-10-26 12:47:48 +04:00
]
}
],
"source": [
"from sklearn.model_selection import train_test_split\n",
"\n",
"# Разделение данных на обучающую и тестовую выборки (80% - обучение, 20% - тестовая)\n",
"train_data, test_data = train_test_split(df, test_size=0.2, random_state=42)\n",
"\n",
"# Разделение данных на обучающую и контрольную выборки (80% - обучение, 20% - контроль)\n",
"train_data, val_data = train_test_split(df, test_size=0.2, random_state=42)\n",
"\n",
"print(\"Размер обучающей выборки: \", len(train_data))\n",
"print(\"Размер контрольной выборки: \", len(val_data))\n",
"print(\"Размер тестовой выборки: \", len(test_data))"
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 7,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAj4AAAHHCAYAAAC/R1LgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACC50lEQVR4nO3dd3hT5dsH8G+SNqNN9y6dUPYeAgWZIhscKIr8FBwswQWi4kJx4FZExA0qKgrKEBHZyCirUmYpq6VQuvdIM5/3j9K8hJYu2p62+X6uKxfk5Dnn3DnnNLnzrCMTQggQERER2QG51AEQERER1RcmPkRERGQ3mPgQERGR3WDiQ0RERHaDiQ8RERHZDSY+REREZDeY+BAREZHdYOJDREREdoOJD1ETZjKZkJaWhsTERKlDoSaI11fTZTAYkJKSgitXrkgdSq1j4kPUxJw9exZTpkxBQEAAlEol/Pz8EBkZicY4SfuGDRsQExNjfb527VqcPHlSuoCoSV1fUlixYgUSEhKsz5cvX46kpCTpArrG4cOH8cADD8Db2xsqlQoBAQEYN26c1GHVOgepA5DS8uXL8fDDD1ufq1QqhISEYOjQoXjllVfg5+cnYXRE1bd//36MGDECnp6eeOGFF9CuXTvIZDK4ublBJpNJHV61HT9+HO+//z6++eYbZGZmYvr06Vi7dq3UYdmtpnZ9SWH37t1Yv3493nvvPcTFxWHmzJk4d+6c1GFh3bp1uO+++9CmTRu89dZbaNGiBQDA19dX4shqn8ye79VVmvgsWLAA4eHhKC4uxp49e/Djjz8iNDQUJ06cgJOTk9RhElWJwWBA586d4erqis2bN8PNzU3qkG5aeno6+vTpY/1iuPvuu/H7779LHJV9aorXlxROnz6NgQMHIjU1FQAwe/ZsfPjhh5LGlJWVhdatW6NPnz5YtWoVlEqlpPHUNbuu8Sk1YsQI9OjRAwDw2GOPwcvLCx999BHWrVuHCRMmSBwdUdX8+eefiIuLw+nTp5vMl5KPjw9OnDhh/RHStm1bqUOyW03x+pJCmzZtcP78eZw4cQLe3t7WmhUpLVu2DMXFxVi+fHmTT3oA9vEp1+DBgwEA8fHxAEqy4WeffRYdO3aEVquFq6srRowYgaNHj5ZZt7i4GK+99hpatWoFtVqNgIAA3H333Th//jwAICEhATKZ7IaPgQMHWre1c+dOyGQy/Prrr3jxxRfh7+8PZ2dnjB07FpcuXSqz7wMHDmD48OFwc3ODk5MTBgwYgL1795b7HgcOHFju/l977bUyZVesWIHu3btDo9HA09MT999/f7n7r+i9XctiseCTTz5B+/btoVar4efnh2nTpiE7O9umXFhYGEaPHl1mP7NmzSqzzfJif//998scUwDQ6/WYP38+IiIioFKpEBwcjOeeew56vb7cY3Wt6dOno2XLlnBycoKnpycGDx6M3bt325RZt24dRo0ahcDAQKhUKrRo0QJvvPEGzGazTbmBAweiQ4cOiI6ORp8+faDRaBAeHo4vvvjCppzBYMCrr76K7t27w83NDc7OzujXrx927NhhU27//v0IDw/H77//jhYtWkCpVCIkJATPPfccdDpdmffy+eefo3379lCpVAgMDMTMmTORk5NjE19F1+q150Amk2HWrFll9jF69GiEhYXZLCssLMScOXMQHBwMlUqF1q1b44MPPijTR6T0nKpUKnTv3h1t27a94TktT0VxXx8TALz22mvllp08ebK1zMWL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LF26FIcOHbKeg5deegmPPfYYACAjIwPPPPOMzbmtCSEExo4dix07duDRRx9Fly5d8M8//2Du3LlISkrCxx9/fMN1b3ROK3L77bfjoYcesln24Ycflkmyr/Xjjz9a///MM8/YvHbo0CHs27cP999/P4KCgpCQkIClS5di4MCBOHXqFJycnNC/f3+bbbz11lsAgJdeesm6rE+fPtV6H1X14osvom3bttDpdNYfTL6+vnj00UdvuI5Op8PAgQNx7tw5zJo1C+Hh4Vi1ahUmT56MnJwcPPXUUwCqfn09+OCD+OGHH/DPP//Y/HBJSUnB9u3bMX/+/Gq/r0WLFmHs2LGYOHEiDAYDVq5ciXvvvRcbNmzAqFGjbrjeuHHjsGXLFjz00EPo2bMnduzYgXnz5iEhIaHMD4yaKioqwoABA5CUlIRp06YhJCQE+/btw7x585CcnIxPPvnkhuueO3cOX3/9dbX2V/o3qNfr8c8//+CDDz6AWq3GG2+8UeP3kJmZiT179mDPnj145JFH0L17d2zbtq3cY/XYY4/h+++/xz333IM5c+bgwIEDWLhwIWJjY8t81p89exb33Xcfpk+fjkmTJmHZsmW49957sWnTJtx+++3lxnLp0iUMHz4cbdq0wW+//QYHh5I05WaOcxnCji1btkwAEFu3bhXp6eni0qVLYuXKlcLLy0toNBpx+fJlIYQQxcXFwmw226wbHx8vVCqVWLBggXXZd999JwCIjz76qMy+LBaLdT0A4v333y9Tpn379mLAgAHW5zt27BAARLNmzUReXp51+W+//SYAiEWLFlm33bJlSzFs2DDrfoQQoqioSISHh4vbb7+9zL769OkjOnToYH2enp4uAIj58+dblyUkJAiFQiHeeustm3WPHz8uHBwcyiw/e/asACC+//5767L58+eLay+z3bt3CwDip59+sll306ZNZZaHhoaKUaNGlYl95syZ4vpL9/rYn3vuOeHr6yu6d+9uc0x//PFHIZfLxe7du23W/+KLLwQAsXfv3jL7q8jBgwcFALF69WrrsqKiojLlpk2bJpycnERxcbF12YABAwQA8eGHH1qX6fV60aVLF+Hr6ysMBoMQQgiTyST0er3N9rKzs4Wfn5945JFHrMsmTZokAIjJkyfblC09B3/++acQQoi0tDShVCrF0KFDba7rzz77TAAQ3333XZn4S6/bZcuWlXscAIi
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlEAAAHHCAYAAACfqw0dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACC6ElEQVR4nO3dd3xTVf8H8E9Gk6Z70T0oUEopuwhUZAnIEhAQ1B8qOAARVBBRcYDg4EFUlgr6qAzFAbIUAWUryIYChUILFFpK915pm+T8/ijNQ2gLbUh7Oz7v1ysvyM25J9+Tm/HtOeeeKxNCCBARERFRtcilDoCIiIioPmISRURERGQGJlFEREREZmASRURERGQGJlFEREREZmASRURERGQGJlFEREREZmASRURERGQGJlFEDYBOp0NKSgri4uKkDoWIGrjc3FxcvXoV+fn5UociOSZRRPVUTEwMJkyYAC8vL6hUKnh4eCA8PBz18SIEW7duRUREhPH+5s2bce7cOekCIqpleXl5WLx4sfF+VlYWvvjiC+kCuoUQAl9//TW6desGGxsbODg4IDAwED/88IPUoUmuUSRRq1atgkwmM96sra3RsmVLTJ06FcnJyVKHR1Rthw8fRpcuXbBnzx68+eab+PPPP7Fz505s3rwZMplM6vCq7ezZs3jllVcQExODw4cP44UXXkBubq7UYRHVGo1Gg3feeQdr165FfHw83nvvPfz+++9ShwUA+L//+z+88MILCAkJwffff4+dO3di165dGDlypNShSU4pdQC1ad68eQgMDIRWq8WBAwewfPlybNu2DZGRkbCxsZE6PKIqKS4uxjPPPIOWLVvir7/+gqOjo9Qh3bPnn38e3333HVq2bAkAGDlyJLp16yZxVES1R6FQYO7cuXj66adhMBjg4OCAP/74Q+qwsGbNGvzyyy/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cunQJU6dORWBgINavX4/x48cjKysLr7zySrViLZtHU+brr79GVFSUyXugXbt2JvuMGTMGTZs2xfz583H48GEsXboUmZmZWLNmjbHM888/j9WrV+PRRx/FjBkzcOTIEcyfPx9RUVHlvovKlL1uZXHU9Nmsu3btwqBBg9CsWTO89957KCwsxLJly9C9e3ecPHmywiS/zKefflrtObtlr3NaWhq+/PJLjB49GpGRkQgODjYr/vT0dADAggUL4OnpiZkzZ8La2hr//e9/0a9fP+zcuRM9e/YEACQnJ+P+++9HQUEBXn75Zbi6umL16tUYNmwYfv31V4wYMcKk7qr83t1u5cqVeOedd/Dpp5+aDC2a87toMaIRWLlypQAgdu3aJVJTU0V8fLz4+eefhaurq9BoNOL69etCCCG0Wq3Q6/Um+8bGxgq1Wi3mzZtn3Pbdd98JAOKzzz4r91wGg8G4HwCxcOHCcmVCQ0NFr169jPf37t0rAAgfHx+Rk5Nj3L5u3ToBQCxZssRYd1BQkBgwYIDxeYQQoqCgQAQGBor+/fuXe677779ftGnTxng/NTVVABBz5swxbrt69apQKBTiww8/NNn37NmzQqlUltseExMjAIjVq1cbt82ZM0fc+nb6559/BACxdu1ak3137NhRbntAQIAYMmRIudinTJkibn+L3h7766+/Ltzd3UVYWJjJa/r9998LuVwu/vnnH5P9V6xYIQCIgwcPlnu+Ozl69KgAIH799VfjtoKCgnLlJk2aJGxsbIRWqzVu69WrlwAgPv30U+O2oqIi0aFDB+Hu7i6Ki4uFEELodDpRVFRkUl9mZqbw8PAQzz77rHHbuHHjBAAxfvx4k7Jlx+D3338XQgiRkpIiVCqVeOihh0ze159//rkAIL777rty8Ze9b1euXFnh6wBATJkypdz2IUOGiIC
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlEAAAHHCAYAAACfqw0dAAAAOXRFWHRTb2Z0d2FyZQBNYX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nvvQSaT4dVXX0VKSgoWL16M/v37IyoqChqNBgCwc+dODBo0CB06dMDcuXMhl8uxatUq45d8586dy5Xr5+dnHCiZl5eHKVOmVHjs2bNnY8yYMfi///s/pKamYunSpejVqxdOnDgBJyencvtMmjQJPXv2BABs2LABGzduNFk/efJkYyvgCy+8gNjYWHz22Wc4ceIE9u3bBysrqwpfh+rIysqqcBCowWDAgw8+iL1792LSpEkICwvD6dOnsWjRIly4cKHCD6JbFRcX47HHHoOfnx8yMjLw5ZdfYuDAgYiJiUFAQACA0g9QOzs7vPTSS7Czs8POnTsxZ84c5OTkYOHChSblZWZmYvDgwRgzZgweffRRrF27FlOmTIFKpcJTTz0FAMjJycFXX32FRx99FBMnTkRubi6+/vprDBgwAIcPH0bbtm0BAOnp6bhy5Qpef/11jBo1CjNmzMDRo0excOFCREdH448//jAmPm+99Rbefvtt9O/fH1OmTMH58+exfPlyHDlyxHgO3njjDfzf//0fACAtLQ3Tp083ObfmEELgwQcfxK5du/D000+jbdu2+OuvvzBz5kwkJCRg0aJFle5b2Tm9k/vvvx9PPPGEybKPP/74jlcxfffdd8b/T58+3WTdkSNHsH//fowdOxZ+fn64evUqli9fjj59+uDs2bOwsbFBr169TMp47733AABvvPGGcVm3bt2qVY+qev311xEWFobCwkLjjy8PDw88/fTTFW4fFhZmEuuKFSsQExNjch5at24NAEhOTkbXrl2NCbO7uzu2bNmCp59+Gjk5OZg2bRqAu38O9u/f3+SYZZ8Rty4r+6xMTk5Gt27dUFBQgBdeeAGurq745ptv8OCDD+KXX37ByJEjq1X/M2fOoGfPnnBwcMArr7wCKysrfPnll+jTpw/27NmDLl26VPrafvfddzh9+nRVToPRokWL4ObmhpycHKxcuRITJ05EkyZN0L9//2qVc6v09HSsWLECdnZ2eOGFF+Du7o7vv/8eo0aNwpo1a4y9J4WFhejTpw8uXbqE5557DkFBQVi3bh0mTJiArKwsvPjiiyblfvvtt8jNzcXUqVOh1WqxZMkS3HfffTh9+jQ8PT0rjOXvv//GU089heeee86ka/HMmTPo3r07fH198dprr8HW1hZr167FiBEjsH79+nLnrc4RVCWrVq0SAMT27dtFamqqiI+PFz/99JNwdXUVGo1GXL9+XQghhFarFXq93mTf2NhYoVarxbx584zLVq5cKQCITz75pNyxDAaDcT8AYuHCheW2CQ8PF7179zY+37VrlwAgfH19RU5OjnH52rVrBQCxZMkSY9khISFiwIABxuMIIURBQYEICgoS999/f7ljdevWTbRq1cr4PDU1VQAQc+fONS67evWqUCgU4r333jPZ9/Tp00KpVJZbfvHiRQFAfPPNN8Zlc+fOFbe+Jf/9918BQKxZs8Zk361bt5ZbHhgYKIYMGVIu9qlTp4rb3+a3x/7KK68IDw8P0aFDB5PX9LvvvhNyuVz8+++/Jvt/8cUXAoDYt29fuePdyeHDhwUA8csvvxiXFRQUlNtu8uTJwsbGRmi1WuOy3r17CwDi448/Ni4rKioSbdu2FR4eHqK4uFgIIYROpxNFRUUm5WVmZgpPT0/x1FNPGZeNHz9eABATJkww2bbsHPz2229CCCFSUlKESqUSDzzwgMn7+rPPPhMAxMqVK8vFX/a+XbVqVYWvAwAxderUcsuHDBkiAgMDjc83bdokAIh3333XZLuHHnpIyGQycen
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"Средняя заработная плата в обучающей выборке: 138055.9893475366\n",
"Средняя заработная плата в контрольной выборке: 135627.99201065247\n",
"Средняя заработная плата в тестовой выборке: 135627.99201065247\n"
2024-10-26 12:47:48 +04:00
]
}
],
"source": [
2024-11-09 11:59:00 +04:00
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Предположим, что у вас уже есть данные, разделенные на обучающую, контрольную и тестовую выборки\n",
"# train_data, val_data, test_data\n",
"\n",
"# Визуализация распределения заработной платы в выборках (гистограмма)\n",
"def plot_salary_distribution(data, title):\n",
" sns.histplot(data['salary_in_usd'], kde=True)\n",
2024-10-26 12:47:48 +04:00
" plt.title(title)\n",
2024-11-09 11:59:00 +04:00
" plt.xlabel('Заработная плата (USD)')\n",
2024-10-26 12:47:48 +04:00
" plt.ylabel('Частота')\n",
" plt.show()\n",
"\n",
2024-11-09 11:59:00 +04:00
"plot_salary_distribution(train_data, 'Распределение заработной платы в обучающей выборке')\n",
"plot_salary_distribution(val_data, 'Распределение заработной платы в контрольной выборке')\n",
"plot_salary_distribution(test_data, 'Распределение заработной платы в тестовой выборке')\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Оценка сбалансированности данных по целевой переменной (salary_in_usd)\n",
"print(\"Средняя заработная плата в обучающей выборке: \", train_data['salary_in_usd'].mean())\n",
"print(\"Средняя заработная плата в контрольной выборке: \", val_data['salary_in_usd'].mean())\n",
"print(\"Средняя заработная плата в тестовой выборке: \", test_data['salary_in_usd'].mean())"
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 10,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm4AAAHHCAYAAAAGU9SoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABgTElEQVR4nO3dd3iN9/8/8OfJXhISsjRiixArlFgxQpCqkUqpElsJtaq+1IiovUesltCKqq222Cu2KEKo0mhJIsgQZL5/f/id+5M754QkEsfN83Fd57py3vf73PfrHuecZ+51VEIIASIiIiJ67+npugAiIiIiyhsGNyIiIiKFYHAjIiIiUggGNyIiIiKFYHAjIiIiUggGNyIiIiKFYHAjIiIiUggGNyIiIiKFYHAjoveWEAJPnjzB7du3dV0KfYC4fX24srKyEB8fj7///lvX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/8kK9pNWnSBAMGDEBWVhauXbuGBQsW4MGDBzhx4kSB63/8+DFevnyJQYMGoUWLFvjmm29w584dBAcHaywr9XzWq1cP06dPR2xsLBYuXIhTp05pfCdnZmaiTZs2aNCgAWbNmoV9+/Zh0qRJyMjIQFBQkNZa0tPT4evri+joaJw6dQoODg7SsEL77hZvISQkRAAQBw8eFI8ePRL3798XGzZsEDY2NsLU1FT8+++/QgghXr58KTIzM2WvvXv3rjA2NhZBQUFS2+rVqwUAMW/ePI1pZWVlSa8DIGbPnq3Rp1q1asLT01N6fuTIEQFAlC5dWiQlJUntGzd
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmIAAAHHCAYAAAAcbzQmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABdhElEQVR4nO3dd1QU1+M28GfpTarSFLGLGBSDia4NC4qKJUokGqJYokbR2KL+jA0x9l4QNVHsMfaCFXvDLjYUSzAQpYhKEZV63z98mS/LggKiY/T5nLPnsHfuzNwpO/swc2dWIYQQICIiIqIPTkPuBhARERF9rhjEiIiIiGTCIEZEREQkEwYxIiIiIpkwiBERERHJhEGMiIiISCYMYkREREQyYRAjIiIikgmDGBF9UoQQePr0Ke7evSt3U4iI3opBjOgz8Pz5c8yfP196n5iYiICAAPkaVMJSUlIwbtw4VK9eHTo6OrCwsEC1atUQEREhd9OK7MaNG9ixY4f0PiwsDHv27JGvQUSfgAoVKqBnz57S+2PHjkGhUODYsWOytSnHBw9iq1atgkKhkF56enqoVq0aBg0ahLi4uA/dHKLPgr6+PsaNG4f169cjOjoafn5+2L17t9zNKhFPnjyBUqnEwoUL8e2332Lnzp0ICQnBs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VNUxr1+/brQ0tJSK797964AIFavXi2VTZw4UeTetCdPnhQAxPr161XG3b9/v1q5vb298PDwUGu7r6+vyLu75G37qFGjhKWlpXBxcVFZp2vXrhUaGhri5Mm
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmcAAAHHCAYAAAD6Rv9iAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABdIUlEQVR4nO3deXhMZ/8G8Huyb5JISCLEvoYQjZaxxRIiUpRUSlN7UQ2116u2oErtWwR9CYqqpahYY1diF7XG0qiULIIsgqzP7w+/OW9OJiEbcyr357rmujLPeeac71lm5s7ZRiWEECAiIiIiRdDTdQFERERE9D8MZ0REREQKwnBGREREpCAMZ0REREQKwnBGREREpCAMZ0REREQKwnBGREREpCAMZ0REREQKwnBGRP9aQgg8efIEt2/f1nUpRETFhuGM6D3z7NkzLFy4UHqekJCAwMBA3RVUzJKTkzFx4kTUqlULRkZGsLW1Rc2aNREREaHr0grs6tWr2LFjh/Q8PDwcu3fv1l1BVCK0atUKrVq10nUZirBmzRqoVCrcu3dPalPC8nmr4Uwz05qHiYkJatasiaFDhyI2NvZtTpqoxDI1NcXEiROxYcMGREVFISAgALt27dJ1WcXi8ePHUKvVWLx4MT799FPs3LkToaGhOHr0KCpXrqzr8gosOTkZgwcPxunTp3H79m0MHz4cV65c0XVZRKRjBu9iItOmTUOVKlXw8uVL/PHHHwgKCsKePXtw9epVmJmZvYsSiEoMfX19TJ06Fb1790ZWVhYsLS3fm70xY8eORXR0NMLCwlC3bl1dl1NkarVaegBAzZo1MXDgQB1XRVSyHThwQNclvJtw5uXlhUaNGgEAvvzyS9ja2mL+/Pn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ldOvWTRaqR44ciTp16mDQoEFSW506dfK13LIryPrPady4cQWaVvbPGI09e/bgl19+yfM13333nTRfK1eulAXbpKQk/Pe//0XPnj0xcOBAJCcnY9WqVfD09MTZs2fh6uqKsmXL4ueff5Zeo/kMyt6W/bO4OLVr1w69e/eWtc2bN0/2j6cQAp07d8aRI0cwYMAAuLq6Yv/+/Rg7diwePHiABQsWSH2nTp2KgIAANG3aFNOmTYORkRHOnDmDw4cPo3379lrTf92yK+7PvjeZNWsW9PT0MGbMGCQmJmL27Nnw8/PDmTNnpD6rVq3C4MGD0bRpU4wYMQJ//fUXOnfuDBsbGzg5ORW69sOHD2Pz5s0YOnQoypQpg8qVKyM0NBQ9e/ZE27Zt8eOPPwIAbty4gZMnT2L48OEA8v9drzFz5kyYmpriP//5D+7cuYMlS5bA0NAQenp6ePr0KQICAnD69GmsWbMGVapUweTJk2WvP3bsGH799Vd88803MDY2xrJly9ChQwecPXs213+2imOZBwUFYejQoWjRogVGjhyJe/fu4ZNPPkHp0qVRoUKF/E9MvEXBwcECgDh48KB49OiRiIqKEps2bRK2trbC1NRU/PPPP0IIIV6+fCkyMzNlr42MjBTGxsZi2rRpUtvq1asFADF//nytaWVlZUmvAyDmzJmj1adu3brC3d1den7kyBEBQJQvX14kJSVJ7Zs3bxYAxKJFi6Rx16hRQ3h6ekrTEUKI58+fiypVqoh27dppTatp06aiXr160vNHjx4JAGLKlClS271794S+vr6YMWOG7LVXrlwRBgYGWu23b98WAMTatWultilTpojsq/HEiRMCgNiwYYPstfv27dNqr1SpkvD29taq3d/fX+TcNHLW/u233wo7Ozvh5uYmW6Y///yz0NPTEydOnJC9fvny5QKAOHnypNb0snN3d5fGt3v3bmFgYCBGjx6t1e/58+dabTNnzhQqlUr8/ff
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"Размер обучающей выборки после oversampling и undersampling: 3044\n"
2024-10-26 12:47:48 +04:00
]
}
],
"source": [
2024-11-09 11:59:00 +04:00
"import pandas as pd\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
2024-10-26 12:47:48 +04:00
"from sklearn.model_selection import train_test_split\n",
"from imblearn.over_sampling import RandomOverSampler\n",
"from imblearn.under_sampling import RandomUnderSampler\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Предположим, что у вас уже есть данные, разделенные на обучающую, контрольную и тестовую выборки\n",
"# train_data, val_data, test_data\n",
"\n",
"# Преобразование целевой переменной (заработная плата) в категориальные диапазоны с использованием квантилей\n",
"train_data['salary_category'] = pd.qcut(train_data['salary_in_usd'], q=4, labels=['low', 'medium', 'high', 'very_high'])\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Визуализация распределения заработной платы после преобразования в категории\n",
"sns.countplot(x=train_data['salary_category'])\n",
"plt.title('Распределение категорий заработной платы в обучающей выборке')\n",
"plt.xlabel('Категория заработной платы')\n",
2024-10-26 12:47:48 +04:00
"plt.ylabel('Частота')\n",
"plt.show()\n",
"\n",
"# Балансировка категорий с помощью RandomOverSampler (увеличение меньшинств)\n",
"ros = RandomOverSampler(random_state=42)\n",
2024-11-09 11:59:00 +04:00
"X_train = train_data.drop(columns=['salary_in_usd', 'salary_category'])\n",
"y_train = train_data['salary_category']\n",
2024-10-26 12:47:48 +04:00
"\n",
"X_resampled, y_resampled = ros.fit_resample(X_train, y_train)\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Визуализация распределения заработной платы после oversampling\n",
2024-10-26 12:47:48 +04:00
"sns.countplot(x=y_resampled)\n",
2024-11-09 11:59:00 +04:00
"plt.title('Распределение категорий заработной платы после oversampling')\n",
"plt.xlabel('Категория заработной платы')\n",
2024-10-26 12:47:48 +04:00
"plt.ylabel('Частота')\n",
"plt.show()\n",
"\n",
"# Применение RandomUnderSampler для уменьшения большего класса\n",
"rus = RandomUnderSampler(random_state=42)\n",
"X_resampled, y_resampled = rus.fit_resample(X_resampled, y_resampled)\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Визуализация распределения заработной платы после undersampling\n",
2024-10-26 12:47:48 +04:00
"sns.countplot(x=y_resampled)\n",
2024-11-09 11:59:00 +04:00
"plt.title('Распределение категорий заработной платы после undersampling')\n",
"plt.xlabel('Категория заработной платы')\n",
2024-10-26 12:47:48 +04:00
"plt.ylabel('Частота')\n",
"plt.show()\n",
"\n",
"# Печать размеров выборки после балансировки\n",
"print(\"Размер обучающей выборки после oversampling и undersampling: \", len(X_resampled))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-11-09 11:59:00 +04:00
"### Конструирование признаков\n",
2024-10-26 12:47:48 +04:00
"Теперь приступим к конструированию признаков для решения каждой задачи.\n",
"\n",
2024-11-09 11:59:00 +04:00
"**Процесс конструирования признаков**\n",
"Задача 1: Прогнозирование заработной платы в Data Science. Цель технического проекта: Разработка модели машинного обучения для точного прогнозирования заработной платы специалистов в области Data Science.\n",
"Задача 2: Оптимизация распределения ресурсов в компании. Цель технического проекта: Разработка модели машинного обучения для оптимизации распределения ресурсов на Data Science проекты.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"**Унитарное кодирование**\n",
2024-10-26 12:47:48 +04:00
"Унитарное кодирование категориальных признаков (one-hot encoding). Преобразование категориальных признаков в бинарные векторы.\n",
"\n",
2024-11-09 11:59:00 +04:00
"**Дискретизация числовых признаков**\n",
2024-10-26 12:47:48 +04:00
"Процесс преобразования непрерывных числовых значений в дискретные категории или интервалы (бины)."
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 16,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"Столбцы train_data_encoded: ['work_year', 'job_title', 'salary', 'salary_currency', 'salary_in_usd', 'remote_ratio', 'salary_category', 'experience_level_EN', 'experience_level_EX', 'experience_level_MI', 'experience_level_SE', 'employment_type_CT', 'employment_type_FL', 'employment_type_FT', 'employment_type_PT', 'employee_residence_AE', 'employee_residence_AM', 'employee_residence_AR', 'employee_residence_AT', 'employee_residence_AU', 'employee_residence_BA', 'employee_residence_BE', 'employee_residence_BG', 'employee_residence_BO', 'employee_residence_BR', 'employee_residence_CA', 'employee_residence_CF', 'employee_residence_CH', 'employee_residence_CL', 'employee_residence_CN', 'employee_residence_CO', 'employee_residence_CR', 'employee_residence_CY', 'employee_residence_CZ', 'employee_residence_DE', 'employee_residence_DK', 'employee_residence_DZ', 'employee_residence_EE', 'employee_residence_EG', 'employee_residence_ES', 'employee_residence_FI', 'employee_residence_FR', 'employee_residence_GB', 'employee_residence_GH', 'employee_residence_GR', 'employee_residence_HK', 'employee_residence_HN', 'employee_residence_HR', 'employee_residence_HU', 'employee_residence_ID', 'employee_residence_IE', 'employee_residence_IL', 'employee_residence_IN', 'employee_residence_IQ', 'employee_residence_IR', 'employee_residence_IT', 'employee_residence_JP', 'employee_residence_KE', 'employee_residence_KW', 'employee_residence_LT', 'employee_residence_LU', 'employee_residence_LV', 'employee_residence_MA', 'employee_residence_MD', 'employee_residence_MK', 'employee_residence_MX', 'employee_residence_MY', 'employee_residence_NG', 'employee_residence_NL', 'employee_residence_NZ', 'employee_residence_PH', 'employee_residence_PK', 'employee_residence_PL', 'employee_residence_PR', 'employee_residence_PT', 'employee_residence_RO', 'employee_residence_RS', 'employee_residence_RU', 'employee_residence_SE', 'employee_residence_SG', 'employee_residence_SI', 'employee_residence_SK', 'employee_residence_TH', 'employee_residence_TN', 'employee_residence_TR', 'employee_residence_UA', 'employee_residence_US', 'employee_residence_UZ', 'employee_residence_VN', 'company_location_AE', 'company_location_AL', 'company_location_AM', 'company_location_AR', 'company_location_AS', 'company_location_AT', 'company_location_AU', 'company_location_BA', 'company_location_BE', 'company_location_BO', 'company_location_BR', 'company_location_CA', 'company_location_CF', 'company_location_CH', 'company_location_CL', 'company_location_CO', 'company_location_CR', 'company_location_CZ', 'company_location_DE', 'company_location_DK', 'company_location_DZ', 'company_location_EE', 'company_location_EG', 'company_location_ES', 'company_location_FI', 'company_location_FR', 'company_location_GB', 'company_location_GH', 'company_location_GR', 'company_location_HN', 'company_location_HR', 'company_location_HU', 'company_location_ID', 'company_location_IE', 'company_location_IL', 'company_location_IN', 'company_location_IQ', 'company_location_IR', 'company_location_IT', 'company_location_JP', 'company_location_KE', 'company_location_LT', 'company_location_LU', 'company_location_LV', 'company_location_MA', 'company_location_MD', 'company_location_MK', 'company_location_MX', 'company_location_MY', 'company_location_NG', 'company_location_NL', 'company_location_NZ', 'company_location_PH', 'company_location_PK', 'company_location_PL', 'company_location_PR', 'company_location_PT', 'company_location_RO', 'company_location_RU', 'company_location_SE', 'company_location_SG', 'company_location_SI', 'company_location_SK', 'company_location_TH', 'company_location_TR', 'company_location_UA', 'company_location_US', 'company_location_VN', 'company_size_L', 'company_size_M', 'company_size_S']\n",
"Столбцы val_data_encoded: ['work_year', 'job_title', 'salary', 'salary_currency', 'salary_in_usd', 'remote_ratio', 'experience_level_EN', 'experience_level_EX', 'experience_level_MI', 'experience_level_SE', 'employment_type_FL', 'employment_type_FT', 'employment_type_PT', 'employee_residence_AE', 'employee_residence_AR', 'employee_residence_AS', 'employee_residence_AT', 'employee_residence_AU', 'employee_residence_BE', 'employee_residence_BR', 'employee_residence_CA', 'employee_residence_CF', 'employee_residence_CH', 'employee_residence_CO', 'employee_residence_DE', 'employee_residence_DO', 'employee_residence_ES', 'employee_residence_FR', 'employee_residence_GB', 'employee_residence_GH', 'employee_residence_GR', 'employee_residence_HK', 'employee_residence_HR', 'employee_residence_IE', 'employee_residence_IN', 'employee_residence_IT', 'employee_residence_JE', 'employee_residence_JP', 'employee_residence_LV', 'employee_residence_MT', 'employee_residence_MX', 'employee_residence_NG', 'employee_residence_NL', 'employee_residence_PK', 'employee_residence_PR', 'employee_residence_PT', 'employee_residence_RU', 'employee_residence_TH', 'employee_residence_TR', 'employee_residence_UA', 'employee_residence_US', 'employee_residence_UZ', 'company_location_AE', 'company_location_AS', 'company_location_AT', 'company_location_AU', 'company_location_BE', 'company_location_BS', 'company_location_CA', 'company_location_CF', 'company_location_CH', 'company_location_CN', 'company_location_CO', 'company_location_DE', 'company_location_ES', 'company_location_FI', 'company_location_FR', 'company_location_GB', 'company_location_GH', 'company_location_GR', 'company_location_HK', 'company_location_HR', 'company_location_IE', 'company_location_IN', 'company_location_JP', 'company_location_LU', 'company_location_LV', 'company_location_MT', 'company_location_MX', 'company_location_NG', 'company_location_NL', 'company_location_PK', 'company_location_PR', 'company_location_PT', 'company_location_RU', 'company_location_SG', 'company_location_TH', 'company_location_TR', 'company_location_UA', 'company_location_US', 'company_size_L', 'company_size_M', 'company_size_S']\n",
"Столбцы test_data_encoded: ['work_year', 'job_title', 'salary', 'salary_currency', 'salary_in_usd', 'remote_ratio', 'experience_level_EN', 'experience_level_EX', 'experience_level_MI', 'experience_level_SE', 'employment_type_FL', 'employment_type_FT', 'employment_type_PT', 'employee_residence_AE', 'employee_residence_AR', 'employee_residence_AS', 'employee_residence_AT', 'employee_residence_AU', 'employee_residence_BE', 'employee_residence_BR', 'employee_residence_CA', 'employee_residence_CF', 'employee_residence_CH', 'employee_residence_CO', 'employee_residence_DE', 'employee_residence_DO', 'employee_residence_ES', 'employee_residence_FR', 'employee_residence_GB', 'employee_residence_GH', 'employee_residence_GR', 'employee_residence_HK', 'employee_residence_HR', 'employee_residence_IE', 'employee_residence_IN', 'employee_residence_IT', 'employee_residence_JE', 'employee_residence_JP', 'employee_residence_LV', 'employee_residence_MT', 'employee_residence_MX', 'employee_residence_NG', 'employee_residence_NL', 'employee_residence_PK', 'employee_residence_PR', 'employee_residence_PT', 'employee_residence_RU', 'employee_residence_TH', 'employee_residence_TR', 'employee_residence_UA', 'employee_residence_US', 'employee_residence_UZ', 'company_location_AE', 'company_location_AS', 'company_location_AT', 'company_location_AU', 'company_location_BE', 'company_location_BS', 'company_location_CA', 'company_location_CF', 'company_location_CH', 'company_location_CN', 'company_location_CO', 'company_location_DE', 'company_location_ES', 'company_location_FI', 'company_location_FR', 'company_location_GB', 'company_location_GH', 'company_location_GR', 'company_location_HK', 'company_location_HR', 'company_location_IE', 'company_location_IN', 'company_location_JP', 'company_location_LU', 'company_location_LV', 'company_location_MT', 'company_location_MX', 'company_location_NG', 'company_location_NL', 'company_location_PK', 'company_location_PR', 'company_location_PT', 'company_location_RU', 'company_location_SG', 'company_location_TH', 'company_location_TR', 'company_location_UA', 'company_location_US', 'company_size_L', 'company_size_M', 'company_size_S']\n",
"Столбцы train_data_encoded после дискретизации: ['work_year', 'job_title', 'salary', 'salary_currency', 'salary_in_usd', 'remote_ratio', 'salary_category', 'experience_level_EN', 'experience_level_EX', 'experience_level_MI', 'experience_level_SE', 'employment_type_CT', 'employment_type_FL', 'employment_type_FT', 'employment_type_PT', 'employee_residence_AE', 'employee_residence_AM', 'employee_residence_AR', 'employee_residence_AT', 'employee_residence_AU', 'employee_residence_BA', 'employee_residence_BE', 'employee_residence_BG', 'employee_residence_BO', 'employee_residence_BR', 'employee_residence_CA', 'employee_residence_CF', 'employee_residence_CH', 'employee_residence_CL', 'employee_residence_CN', 'employee_residence_CO', 'employee_residence_CR', 'employee_residence_CY', 'employee_residence_CZ', 'employee_residence_DE', 'employee_residence_DK', 'employee_residence_DZ', 'employee_residence_EE', 'employee_residence_EG', 'employee_residence_ES', 'employee_residence_FI', 'employee_residence_FR', 'employee_residence_GB', 'employee_residence_GH', 'employee_residence_GR', 'employee_residence_HK', 'employee_residence_HN', 'employee_residence_HR', 'employee_residence_HU', 'employee_residence_ID', 'employee_residence_IE', 'employee_residence_IL', 'employee_residence_IN', 'employee_residence_IQ', 'employee_residence_IR', 'employee_residence_IT', 'employee_residence_JP', 'employee_residence_KE', 'employee_residence_KW', 'employee_residence_LT', 'employee_residence_LU', 'employee_residence_LV', 'employee_residence_MA', 'employee_residence_MD', 'employee_residence_MK', 'employee_residence_MX', 'employee_residence_MY', 'employee_residence_NG', 'employee_residence_NL', 'employee_residence_NZ', 'employee_residence_PH', 'employee_residence_PK', 'employee_residence_PL', 'employee_residence_PR', 'employee_residence_PT', 'employee_residence_RO', 'employee_residence_RS', 'employee_residence_RU', 'employee_residence_SE', 'employee_residence_SG', 'employee_residence_SI', 'employee_residence_SK', 'employee_residence_TH', 'employee_residence_TN', 'employee_residence_TR', 'employee_residence_UA', 'employee_residence_US', 'employee_residence_UZ', 'employee_residence_VN', 'company_location_AE', 'company_location_AL', 'company_location_AM', 'company_location_AR', 'company_location_AS', 'company_location_AT', 'company_location_AU', 'company_location_BA', 'company_location_BE', 'company_location_BO', 'company_location_BR', 'company_location_CA', 'company_location_CF', 'company_location_CH', 'company_location_CL', 'company_location_CO', 'company_location_CR', 'company_location_CZ', 'company_location_DE', 'company_location_DK', 'company_location_DZ', 'company_location_EE', 'company_location_EG', 'company_location_ES', 'company_location_FI', 'company_location_FR', 'company_location_GB', 'company_location_GH', 'company_location_GR', 'company_location_HN', 'company_location_HR', 'company_location_HU', 'company_location_ID', 'company_location_IE', 'company_location_IL', 'company_location_IN', 'company_location_IQ', 'company_location_IR', 'company_location_IT', 'company_location_JP', 'company_location_KE', 'company_location_LT', 'company_location_LU', 'company_location_LV', 'company_location_MA', 'company_location_MD', 'company_location_MK', 'company_location_MX', 'company_location_MY', 'company_location_NG', 'company_location_NL', 'company_location_NZ', 'company_location_PH', 'company_location_PK', 'company_location_PL', 'company_location_PR', 'company_location_PT', 'company_location_RO', 'company_location_RU', 'company_location_SE', 'company_location_SG', 'company_location_SI', 'company_location_SK', 'company_location_TH', 'company_location_TR', 'company_location_UA', 'company_location_US', 'company_location_VN', 'company_size_L', 'company_size_M', 'company_size_S']\n",
"Столбцы val_data_encoded после дискретизации: ['work_year', 'job_title', 'salary', 'salary_currency', 'salary_in_usd', 'remote_ratio', 'experience_level_EN', 'experience_level_EX', 'experience_level_MI', 'experience_level_SE', 'employment_type_FL', 'employment_type_FT', 'employment_type_PT', 'employee_residence_AE', 'employee_residence_AR', 'employee_residence_AS', 'employee_residence_AT', 'employee_residence_AU', 'employee_residence_BE', 'employee_residence_BR', 'employee_residence_CA', 'employee_residence_CF', 'employee_residence_CH', 'employee_residence_CO', 'employee_residence_DE', 'employee_residence_DO', 'employee_residence_ES', 'employee_residence_FR', 'employee_residence_GB', 'employee_residence_GH', 'employee_residence_GR', 'employee_residence_HK', 'employee_residence_HR', 'employee_residence_IE', 'employee_residence_IN', 'employee_residence_IT', 'employee_residence_JE', 'employee_residence_JP', 'employee_residence_LV', 'employee_residence_MT', 'employee_residence_MX', 'employee_residence_NG', 'employee_residence_NL', 'employee_residence_PK', 'employee_residence_PR', 'employee_residence_PT', 'employee_residence_RU', 'employee_residence_TH', 'employee_residence_TR', 'employee_residence_UA', 'employee_residence_US', 'employee_residence_UZ', 'company_location_AE', 'company_location_AS', 'company_location_AT', 'company_location_AU', 'company_location_BE', 'company_location_BS', 'company_location_CA', 'company_location_CF', 'company_location_CH', 'company_location_CN', 'company_location_CO', 'company_location_DE', 'company_location_ES', 'company_location_FI', 'company_location_FR', 'company_location_GB', 'company_location_GH', 'company_location_GR', 'company_location_HK', 'company_location_HR', 'company_location_IE', 'company_location_IN', 'company_location_JP', 'company_location_LU', 'company_location_LV', 'company_location_MT', 'company_location_MX', 'company_location_NG', 'company_location_NL', 'company_location_PK', 'company_location_PR', 'company_location_PT', 'company_location_RU', 'company_location_SG', 'company_location_TH', 'company_location_TR', 'company_location_UA', 'company_location_US', 'company_size_L', 'company_size_M', 'company_size_S', 'salary_category']\n",
"Столбцы test_data_encoded после дискретизации: ['work_year', 'job_title', 'salary', 'salary_currency', 'salary_in_usd', 'remote_ratio', 'experience_level_EN', 'experience_level_EX', 'experience_level_MI', 'experience_level_SE', 'employment_type_FL', 'employment_type_FT', 'employment_type_PT', 'employee_residence_AE', 'employee_residence_AR', 'employee_residence_AS', 'employee_residence_AT', 'employee_residence_AU', 'employee_residence_BE', 'employee_residence_BR', 'employee_residence_CA', 'employee_residence_CF', 'employee_residence_CH', 'employee_residence_CO', 'employee_residence_DE', 'employee_residence_DO', 'employee_residence_ES', 'employee_residence_FR', 'employee_residence_GB', 'employee_residence_GH', 'employee_residence_GR', 'employee_residence_HK', 'employee_residence_HR', 'employee_residence_IE', 'employee_residence_IN', 'employee_residence_IT', 'employee_residence_JE', 'employee_residence_JP', 'employee_residence_LV', 'employee_residence_MT', 'employee_residence_MX', 'employee_residence_NG', 'employee_residence_NL', 'employee_residence_PK', 'employee_residence_PR', 'employee_residence_PT', 'employee_residence_RU', 'employee_residence_TH', 'employee_residence_TR', 'employee_residence_UA', 'employee_residence_US', 'employee_residence_UZ', 'company_location_AE', 'company_location_AS', 'company_location_AT', 'company_location_AU', 'company_location_BE', 'company_location_BS', 'company_location_CA', 'company_location_CF', 'company_location_CH', 'company_location_CN', 'company_location_CO', 'company_location_DE', 'company_location_ES', 'company_location_FI', 'company_location_FR', 'company_location_GB', 'company_location_GH', 'company_location_GR', 'company_location_HK', 'company_location_HR', 'company_location_IE', 'company_location_IN', 'company_location_JP', 'company_location_LU', 'company_location_LV', 'company_location_MT', 'company_location_MX', 'company_location_NG', 'company_location_NL', 'company_location_PK', 'company_location_PR', 'company_location_PT', 'company_location_RU', 'company_location_SG', 'company_location_TH', 'company_location_TR', 'company_location_UA', 'company_location_US', 'company_size_L', 'company_size_M', 'company_size_S', 'salary_category']\n"
2024-10-26 12:47:48 +04:00
]
}
],
"source": [
"# Конструирование признаков\n",
"# Унитарное кодирование категориальных признаков (применение one-hot encoding)\n",
"\n",
"# Пример категориальных признаков\n",
2024-11-09 11:59:00 +04:00
"categorical_features = ['experience_level', 'employment_type', 'employee_residence', 'company_location', 'company_size']\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Применение one-hot encoding\n",
"train_data_encoded = pd.get_dummies(train_data, columns=categorical_features)\n",
"val_data_encoded = pd.get_dummies(val_data, columns=categorical_features)\n",
"test_data_encoded = pd.get_dummies(test_data, columns=categorical_features)\n",
"df_encoded = pd.get_dummies(df, columns=categorical_features)\n",
"\n",
"print(\"Столбцы train_data_encoded:\", train_data_encoded.columns.tolist())\n",
"print(\"Столбцы val_data_encoded:\", val_data_encoded.columns.tolist())\n",
"print(\"Столбцы test_data_encoded:\", test_data_encoded.columns.tolist())\n",
"\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Пример дискретизации признака 'salary_in_usd' на 5 категорий\n",
"train_data_encoded['salary_category'] = pd.cut(train_data_encoded['salary_in_usd'], bins=5, labels=False)\n",
"val_data_encoded['salary_category'] = pd.cut(val_data_encoded['salary_in_usd'], bins=5, labels=False)\n",
"test_data_encoded['salary_category'] = pd.cut(test_data_encoded['salary_in_usd'], bins=5, labels=False)\n",
"df_encoded['salary_category'] = pd.cut(df_encoded['salary_in_usd'], bins=5, labels=False)\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"print(\"Столбцы train_data_encoded после дискретизации:\", train_data_encoded.columns.tolist())\n",
"print(\"Столбцы val_data_encoded после дискретизации:\", val_data_encoded.columns.tolist())\n",
"print(\"Столбцы test_data_encoded после дискретизации:\", test_data_encoded.columns.tolist())\n"
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Ручной синтез\n",
2024-11-09 11:59:00 +04:00
"Создание новых признаков на основе экспертных знаний и логики предметной области. К примеру, для данных о заработной плате в Data Science можно создать признак \"зарплата в месяц\"."
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 34,
2024-10-26 12:47:48 +04:00
"metadata": {},
2024-11-09 11:59:00 +04:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" work_year experience_level employment_type job_title \\\n",
"0 2023 SE FT Principal Data Scientist \n",
"1 2023 MI CT ML Engineer \n",
"2 2023 MI CT ML Engineer \n",
"3 2023 SE FT Data Scientist \n",
"4 2023 SE FT Data Scientist \n",
"\n",
" salary salary_currency salary_in_usd employee_residence remote_ratio \\\n",
"0 80000 EUR 85847 ES 100 \n",
"1 30000 USD 30000 US 100 \n",
"2 25500 USD 25500 US 100 \n",
"3 175000 USD 175000 CA 100 \n",
"4 120000 USD 120000 CA 100 \n",
"\n",
" company_location company_size Salary in month \n",
"0 ES L 6666 \n",
"1 US S 2500 \n",
"2 US S 2125 \n",
"3 CA M 14583 \n",
"4 CA M 10000 \n"
]
}
],
2024-10-26 12:47:48 +04:00
"source": [
2024-11-09 11:59:00 +04:00
"df = pd.read_csv(\"..//static//csv//ds_salaries.csv\")\n",
"# Создание нового признака 'Salary in month'\n",
"df['Salary in month'] = df['salary'] // 12\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Вывод первых нескольких строк датафрейма для проверки\n",
"print(df.head())"
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Масштабирование признаков - это процесс преобразования числовых признаков таким образом, чтобы они имели одинаковый масштаб. Это важно для многих алгоритмов машинного обучения, которые чувствительны к масштабу признаков, таких как линейная регрессия, метод опорных векторов (SVM) и нейронные сети."
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 36,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [],
"source": [
"from sklearn.preprocessing import StandardScaler, MinMaxScaler\n",
"\n",
"# Пример масштабирования числовых признаков\n",
2024-11-09 11:59:00 +04:00
"numerical_features = ['work_year', 'salary']\n",
2024-10-26 12:47:48 +04:00
"\n",
"scaler = StandardScaler()\n",
"train_data_encoded[numerical_features] = scaler.fit_transform(train_data_encoded[numerical_features])\n",
"val_data_encoded[numerical_features] = scaler.transform(val_data_encoded[numerical_features])\n",
2024-11-09 11:59:00 +04:00
"test_data_encoded[numerical_features] = scaler.transform(test_data_encoded[numerical_features])\n"
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Конструирование признаков с применением фреймворка Featuretools"
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 43,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n"
2024-10-26 12:47:48 +04:00
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
" work_year experience_level employment_type job_title \\\n",
2024-10-26 12:47:48 +04:00
"id \n",
2024-11-09 11:59:00 +04:00
"1 2023 SE FT Principal Data Scientist \n",
"2 2023 MI CT ML Engineer \n",
"3 2023 MI CT ML Engineer \n",
"4 2023 SE FT Data Scientist \n",
"5 2023 SE FT Data Scientist \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
" salary salary_currency salary_in_usd employee_residence remote_ratio \\\n",
"id \n",
"1 80000 EUR 85847 ES 100 \n",
"2 30000 USD 30000 US 100 \n",
"3 25500 USD 25500 US 100 \n",
"4 175000 USD 175000 CA 100 \n",
"5 120000 USD 120000 CA 100 \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
" company_location company_size \n",
"id \n",
"1 ES L \n",
"2 US S \n",
"3 US S \n",
"4 CA M \n",
"5 CA M \n",
" work_year experience_level employment_type job_title salary \\\n",
"id \n",
"2385 2022 SE FT Data Engineer 175000 \n",
"941 2023 SE FT Analytics Engineer 150000 \n",
"1617 2023 MI FT Data Analyst 65000 \n",
"1443 2023 MI FT Data Analyst 61200 \n",
"416 2023 SE FT Data Scientist 175000 \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
" salary_currency salary_in_usd employee_residence remote_ratio \\\n",
"id \n",
"2385 USD 175000 US 100 \n",
"941 USD 150000 US 0 \n",
"1617 GBP 78990 GB 0 \n",
"1443 USD 61200 US 0 \n",
"416 USD 175000 US 100 \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
" company_location company_size \n",
"id \n",
"2385 US M \n",
"941 US M \n",
"1617 GB M \n",
"1443 US M \n",
"416 US M \n",
" work_year experience_level employment_type job_title salary \\\n",
"id \n",
"2321 2022 SE FT Analytics Engineer 116250 \n",
"473 2023 EX FT Data Engineer 286000 \n",
"2269 2022 EN FT Data Engineer 135000 \n",
"430 2023 SE FT Data Analyst 208450 \n",
"3574 2020 MI FT Data Engineer 88000 \n",
"\n",
" salary_currency salary_in_usd employee_residence remote_ratio \\\n",
"id \n",
"2321 USD 116250 US 100 \n",
"473 USD 286000 US 100 \n",
"2269 USD 135000 US 0 \n",
"430 USD 208450 US 100 \n",
"3574 GBP 112872 GB 50 \n",
"\n",
" company_location company_size \n",
"id \n",
"2321 US M \n",
"473 US M \n",
"2269 US M \n",
"430 US M \n",
"3574 GB L \n"
2024-10-26 12:47:48 +04:00
]
}
],
"source": [
2024-11-09 11:59:00 +04:00
"import pandas as pd\n",
2024-10-26 12:47:48 +04:00
"import featuretools as ft\n",
2024-11-09 11:59:00 +04:00
"from sklearn.model_selection import train_test_split\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Загрузка данных\n",
"df = pd.read_csv(\"..//static//csv//ds_salaries.csv\")\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Создание уникального идентификатора для каждой строки\n",
"df['id'] = range(1, len(df) + 1)\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Предобработка данных (например, кодирование категориальных признаков, удаление дубликатов)\n",
"# Удаление дубликатов по всем столбцам\n",
"df = df.drop_duplicates()\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Создание EntitySet\n",
2024-11-09 11:59:00 +04:00
"es = ft.EntitySet(id='data_science_jobs')\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Добавление датафрейма с данными о рабочих местах\n",
"es = es.add_dataframe(\n",
" dataframe_name='jobs',\n",
" dataframe=df,\n",
" index='id'\n",
")\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Генерация признаков с помощью глубокой синтезы признаков\n",
2024-11-09 11:59:00 +04:00
"feature_matrix, feature_defs = ft.dfs(entityset=es, target_dataframe_name='jobs', max_depth=1)\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Выводим первые 5 строк сгенерированного набора признаков\n",
"print(feature_matrix.head())\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Разделение данных на обучающую и тестовую выборки\n",
"train_data, test_data = train_test_split(df, test_size=0.3, random_state=42)\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Разделение оставшейся части на валидационную и тестовую выборки\n",
"val_data, test_data = train_test_split(test_data, test_size=0.5, random_state=42)\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Преобразование признаков для контрольной и тестовой выборок\n",
2024-11-09 11:59:00 +04:00
"val_feature_matrix = ft.calculate_feature_matrix(features=feature_defs, entityset=es, instance_ids=val_data['id'])\n",
"test_feature_matrix = ft.calculate_feature_matrix(features=feature_defs, entityset=es, instance_ids=test_data['id'])\n",
"\n",
"# Вывод первых 5 строк сгенерированных признаков для валидационной и тестовой выборок\n",
"print(val_feature_matrix.head())\n",
"print(test_feature_matrix.head())"
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Оценка качества каждого набора признаков \n",
"\n",
"*Предсказательная способность Метрики:* RMSE, MAE, R² \n",
"\n",
"*Методы:* Обучение модели на обучающей выборке и оценка на контрольной и тестовой выборках. \n",
"\n",
"*Скорость вычисления Методы:* Измерение времени выполнения генерации признаков и обучения модели. \n",
"\n",
"*Надежность Методы:* К р о с с -валидация, анализ чувствительности модели к изменениям в данных. \n",
"\n",
"*Корреляция Методы:* Анализ корреляционной матрицы признаков, удаление мультиколлинеарных признаков. \n",
"\n",
"*Цельность Методы:* Проверка логической связи между признаками и целевой переменной, интерпретация результатов модели. "
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": 44,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"Время обучения модели: 1.81 секунд\n",
"Среднеквадратичная ошибка (RMSE): 49834.60\n",
"Средняя абсолютная ошибка (MAE): 37776.22\n",
"Коэффициент детерминации (R²): 0.37\n",
"К р о с с -валидация RMSE: 51653687796568.14 (± 37705548691705.71)\n",
"Корреляционная матрица признаков:\n",
" work_year remote_ratio experience_level_EX \\\n",
"work_year 1.000000 -0.236430 0.003156 \n",
"remote_ratio -0.236430 1.000000 0.007190 \n",
"experience_level_EX 0.003156 0.007190 1.000000 \n",
"experience_level_MI -0.128381 -0.000650 -0.092433 \n",
"experience_level_SE 0.194923 -0.035201 -0.252152 \n",
"... ... ... ... \n",
"company_location_UA 0.005969 -0.005896 -0.005778 \n",
"company_location_US 0.267002 -0.077706 0.022562 \n",
"company_location_VN 0.014787 -0.015545 -0.002888 \n",
"company_size_M 0.421975 -0.154550 -0.003061 \n",
"company_size_S -0.257948 0.108512 0.012020 \n",
"\n",
" experience_level_MI experience_level_SE \\\n",
"work_year -0.128381 0.194923 \n",
"remote_ratio -0.000650 -0.035201 \n",
"experience_level_EX -0.092433 -0.252152 \n",
"experience_level_MI 1.000000 -0.744400 \n",
"experience_level_SE -0.744400 1.000000 \n",
"... ... ... \n",
"company_location_UA -0.017059 0.005553 \n",
"company_location_US -0.255712 0.324686 \n",
"company_location_VN -0.008526 -0.023258 \n",
"company_size_M -0.097174 0.236746 \n",
"company_size_S 0.060936 -0.163489 \n",
"\n",
" employment_type_FL employment_type_FT \\\n",
"work_year -0.050350 0.116310 \n",
"remote_ratio 0.025238 -0.068702 \n",
"experience_level_EX -0.009144 0.001938 \n",
"experience_level_MI 0.035964 -0.033295 \n",
"experience_level_SE -0.040667 0.113486 \n",
"... ... ... \n",
"company_location_UA 0.156722 -0.079394 \n",
"company_location_US -0.053906 0.082093 \n",
"company_location_VN -0.000843 0.001628 \n",
"company_size_M -0.047840 0.125424 \n",
"company_size_S 0.095761 -0.173783 \n",
"\n",
" employment_type_PT job_title_AI Developer \\\n",
"work_year -0.093825 0.027726 \n",
"remote_ratio 0.041919 -0.016126 \n",
"experience_level_EX -0.011933 -0.009591 \n",
"experience_level_MI -0.006230 -0.004301 \n",
"experience_level_SE -0.096100 -0.045802 \n",
"... ... ... \n",
"company_location_UA -0.002202 0.300345 \n",
"company_location_US -0.078434 -0.099216 \n",
"company_location_VN -0.001101 -0.000885 \n",
"company_size_M -0.100277 -0.043467 \n",
"company_size_S 0.108664 0.064994 \n",
"\n",
" job_title_AI Programmer ... company_location_SG \\\n",
"work_year 0.004219 ... -0.021620 \n",
"remote_ratio 0.001772 ... 0.016794 \n",
"experience_level_EX -0.004085 ... -0.007079 \n",
"experience_level_MI -0.012059 ... 0.044089 \n",
"experience_level_SE -0.032896 ... -0.042828 \n",
"... ... ... ... \n",
"company_location_UA -0.000754 ... -0.001306 \n",
"company_location_US -0.047600 ... -0.082490 \n",
"company_location_VN -0.000377 ... -0.000653 \n",
"company_size_M -0.021372 ... -0.055210 \n",
"company_size_S -0.004676 ... -0.008104 \n",
"\n",
" company_location_SI company_location_SK \\\n",
"work_year -0.017648 -0.008821 \n",
"remote_ratio 0.027712 0.018050 \n",
"experience_level_EX -0.005778 -0.002888 \n",
"experience_level_MI 0.042620 -0.008526 \n",
"experience_level_SE -0.029172 0.011453 \n",
"... ... ... \n",
"company_location_UA -0.001066 -0.000533 \n",
"company_location_US -0.067335 -0.033654 \n",
"company_location_VN -0.000533 -0.000266 \n",
"company_size_M -0.030233 -0.037352 \n",
"company_size_S -0.006615 0.080574 \n",
"\n",
" company_location_TH company_location_TR \\\n",
"work_year -0.001648 -0.051424 \n",
"remote_ratio 0.011871 -0.004714 \n",
"experience_level_EX -0.005003 -0.006461 \n",
"experience_level_MI 0.008196 0.052106 \n",
"experience_level_SE -0.020249 -0.036503 \n",
"... ... ... \n",
"company_location_UA -0.000923 -0.001192 \n",
"company_location_US -0.058306 -0.075293 \n",
"company_location_VN -0.000462 -0.000596 \n",
"company_size_M -0.039024 -0.003949 \n",
"company_size_S -0.005728 -0.007397 \n",
"\n",
" company_location_UA company_location_US \\\n",
"work_year 0.005969 0.267002 \n",
"remote_ratio -0.005896 -0.077706 \n",
"experience_level_EX -0.005778 0.022562 \n",
"experience_level_MI -0.017059 -0.255712 \n",
"experience_level_SE 0.005553 0.324686 \n",
"... ... ... \n",
"company_location_UA 1.000000 -0.067335 \n",
"company_location_US -0.067335 1.000000 \n",
"company_location_VN -0.000533 -0.033654 \n",
"company_size_M -0.030233 0.314961 \n",
"company_size_S 0.035342 -0.229439 \n",
"\n",
" company_location_VN company_size_M company_size_S \n",
"work_year 0.014787 0.421975 -0.257948 \n",
"remote_ratio -0.015545 -0.154550 0.108512 \n",
"experience_level_EX -0.002888 -0.003061 0.012020 \n",
"experience_level_MI -0.008526 -0.097174 0.060936 \n",
"experience_level_SE -0.023258 0.236746 -0.163489 \n",
"... ... ... ... \n",
"company_location_UA -0.000533 -0.030233 0.035342 \n",
"company_location_US -0.033654 0.314961 -0.229439 \n",
"company_location_VN 1.000000 -0.037352 -0.003306 \n",
"company_size_M -0.037352 1.000000 -0.463577 \n",
"company_size_S -0.003306 -0.463577 1.000000 \n",
"\n",
"[250 rows x 250 columns]\n",
"Коэффициенты модели:\n",
" Feature Coefficient\n",
"0 work_year 3996.696898\n",
"1 remote_ratio 5.199270\n",
"2 experience_level_EX 88740.552288\n",
"3 experience_level_MI 20170.854874\n",
"4 experience_level_SE 44093.474726\n",
".. ... ...\n",
"245 company_location_UA -64984.628104\n",
"246 company_location_US 40574.678578\n",
"247 company_location_VN 24478.024917\n",
"248 company_size_M -2895.244061\n",
"249 company_size_S -23506.811439\n",
"\n",
"[250 rows x 2 columns]\n"
2024-10-26 12:47:48 +04:00
]
}
],
"source": [
"import time\n",
2024-11-09 11:59:00 +04:00
"import pandas as pd\n",
"from sklearn.model_selection import train_test_split, cross_val_score\n",
2024-10-26 12:47:48 +04:00
"from sklearn.linear_model import LinearRegression\n",
2024-11-09 11:59:00 +04:00
"from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score\n",
"\n",
"# Загрузка данных\n",
"df = pd.read_csv(\"..//static//csv//ds_salaries.csv\")\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Разделение данных на признаки и целевую переменную\n",
"X = df.drop(['salary_in_usd', 'salary', 'salary_currency'], axis=1) # Удаляем целевую переменную и ненужные столбцы\n",
"y = df['salary_in_usd']\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# One-hot encoding для категориальных переменных\n",
2024-10-26 12:47:48 +04:00
"X = pd.get_dummies(X, drop_first=True)\n",
"\n",
"# Проверяем, есть ли пропущенные значения, и заполняем их медианой или другим подходящим значением\n",
"X.fillna(X.median(), inplace=True)\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Разделение данных на обучающую и валидационную выборки\n",
2024-10-26 12:47:48 +04:00
"X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=42)\n",
"\n",
"# Обучение модели\n",
"model = LinearRegression()\n",
"\n",
"# Начинаем отсчет времени\n",
"start_time = time.time()\n",
"model.fit(X_train, y_train)\n",
"\n",
"# Время обучения модели\n",
"train_time = time.time() - start_time\n",
"\n",
2024-11-09 11:59:00 +04:00
"# Предсказания и оценка модели\n",
2024-10-26 12:47:48 +04:00
"predictions = model.predict(X_val)\n",
"mse = mean_squared_error(y_val, predictions)\n",
2024-11-09 11:59:00 +04:00
"mae = mean_absolute_error(y_val, predictions)\n",
"r2 = r2_score(y_val, predictions)\n",
2024-10-26 12:47:48 +04:00
"\n",
"print(f'Время обучения модели: {train_time:.2f} секунд')\n",
2024-11-09 11:59:00 +04:00
"print(f'Среднеквадратичная ошибка (RMSE): {mse**0.5:.2f}')\n",
"print(f'Средняя абсолютная ошибка (MAE): {mae:.2f}')\n",
"print(f'Коэффициент детерминации (R²): {r2:.2f}')\n",
"\n",
"# К р о с с -валидация\n",
"cv_scores = cross_val_score(model, X, y, cv=5, scoring='neg_mean_squared_error')\n",
"cv_rmse_scores = (-cv_scores)**0.5\n",
"print(f'К р о с с -валидация RMSE: {cv_rmse_scores.mean():.2f} (± {cv_rmse_scores.std():.2f})')\n",
"\n",
"# Анализ корреляции\n",
"correlation_matrix = X.corr()\n",
"print(\"Корреляционная матрица признаков:\")\n",
"print(correlation_matrix)\n",
"\n",
"# Цельность: Проверка логической связи между признаками и целевой переменной\n",
"# В данном случае, мы можем проанализировать коэффициенты модели\n",
"coefficients = pd.DataFrame({'Feature': X.columns, 'Coefficient': model.coef_})\n",
"print(\"Коэффициенты модели:\")\n",
"print(coefficients)"
2024-10-26 12:47:48 +04:00
]
},
{
"cell_type": "code",
2024-11-09 11:59:00 +04:00
"execution_count": null,
2024-10-26 12:47:48 +04:00
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\woodwork\\type_sys\\utils.py:33: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.\n",
" pd.to_datetime(\n",
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\sklearn\\metrics\\_regression.py:492: FutureWarning: 'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.\n",
2024-10-26 12:47:48 +04:00
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"RMSE: 8277.602700993119\n",
"R²: 0.9826437806135544\n",
"MAE: 1270.2934354194408 \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"К р о с с -валидация RMSE: 13606.980806552549 \n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Train RMSE: 4839.006207438376\n",
"Train R²: 0.9941174224388726\n",
"Train MAE: 664.4994041278297\n",
2024-10-26 12:47:48 +04:00
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
2024-11-09 11:59:00 +04:00
"d:\\MII\\AIM-PIbd-32-Kaznacheeva-E-K\\aimenv\\Lib\\site-packages\\sklearn\\metrics\\_regression.py:492: FutureWarning: 'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.\n",
2024-10-26 12:47:48 +04:00
" warnings.warn(\n"
]
},
{
"data": {
2024-11-09 11:59:00 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA38AAAIjCAYAAACzjKK3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADxHElEQVR4nOzdd3xT1f/H8VdGk3SmFGjLKLPIkL2HCgpStcLXr+CW5UAUUMEBKILyVXF8FdAqiPp1ggpuQEAEQURUhih7LyltKaV7pEnu7w9+jYQWbLFQxvv5eOQBOffccz/3Jk37yTn3HJNhGAYiIiIiIiJyXjNXdAAiIiIiIiJy+in5ExERERERuQAo+RMREREREbkAKPkTERERERG5ACj5ExERERERuQAo+RMREREREbkAKPkTERERERG5ACj5ExERERERuQAo+RMREREREbkAKPkTERERESmFhIQE0tPTfc8nT55MTk5OxQUkUkZK/kTOUQMHDiQkJKSiwxAREblgzJkzhyeffJL9+/czY8YMnnjiCQIDAys6LJFSMxmGYVR0ECJSOocPH2bGjBksX76cH374gdTUVK688kpatWrFjTfeSKtWrSo6RBERkfPWsmXL6N27N5mZmZjNZl566SUefPDBig5LpNSU/ImcIz7++GPuvvtusrOzqVOnDoWFhSQlJdGqVSt+//13CgsLGTBgANOnT8dms1V0uCIiIuel9PR0Nm/eTExMDDVr1qzocETKRMM+Rc4BK1as4Pbbbyc6OpoVK1awe/duevTogcPhYNWqVSQmJnLLLbfw3nvvMWLECL99//vf/9K5c2cqV65MYGAgbdq04dNPPy12DJPJxJNPPul77na7ueaaa4iIiGDTpk2+Oid7dOvWDYClS5diMplYunSp3z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m1M6f4CNGzfSpUsXatSowejRowkODmbWrFlcd911fPbZZ/z73/8GIDs7m0svvZTNmzdzxx130Lp1a1JTU/n666/5888/fbEeKyMjg6uvvpqAgAC++eYbX8KWmZnJW2+9xS233MLdd99NVlYWb7/9NnFxcfz666+0bNnS18aAAQP47rvvGD58OC1atMBisTB9+nTWrl1bqvMbPHgw0dHRJCYmkpCQQI8ePdi9ezdBQUEATJ06lYsvvpjevXtjtVqZM2cO9913H16vl6FDh/q1tX37dm666SaGDBnCgAEDeOedd7jhhhtYsGABV155pV/dCRMmULduXd/z7Oxs7r333hPGeemllzJ48GAANm/ezLPPPuu3/d133yUkJISRI0cSEhLCkiVLGDduHJmZmbz44osAPP7449x1110ApKamMmLECAYPHsyll15a7HhlOe+S2O123nrrLb+yVatW8corrxSLe9CgQbRr146JEyeSnJzMlClTWLFiBb/99hvh4eEnPEZZ3nPPPPMMJpOJUaNGkZKSwuTJk+nRowfr1q3z3Tc0e/ZscnNzuffee6lcuTK//vorr776Kn/++SezZ8/2O3aVKlWYNGkSAH/++SdTpkzhmmuuYf/+/SeN+USeeeYZnnjiCW688UbuuusuDh06xKuvvspll132t9ehtNxuN48//vjf1nO5XPTo0YMtW7Zw77330rBhQ7788ksGDx7M4cOHGT169En3f/fdd7njjju4+OKLGTNmDOHh4fz2228sWLCAW2+99W+PP3XqVL8vb3bv3s24ceOK1fN4PFx11VV07NiRF154gQULFjB+/HjcbjcTJkwAjiY6vXv35vvvv+fOO++kZcuWLFy4kEceeYQDBw74XsMiV155Jf379/crO/bzprSSk5Pp3Lkzubm53H///VSuXJn33nuP3r178+mnn/o+N7OysmjcuDE33ngjQUFBrFy5khdeeIHc3FxeffXVE7b/wQcfFPuiqrTXxWQycfvtt/PCCy+QlpZGRESEb985c+aQmZnJ7bffDhxNMnv37s2PP/7I4MGDady4MevXr2fSpEls27aNL7/80u/YDoeDd955x2845k8//cTevXtP+RqV5J/+XhOpEIaInPUiIiKM2rVr+5UNGDDACA4O9it74oknDMCYM2eOryw3N9evjsvlMpo2bWpcccUVfuWAMX78eMMwDGPMmDGGxWIxvvzyyxPG9M477xiAsXv37mLbvv/+ewMwvv/+e19Zhw4djKuvvtrvOIZhGJdffrlx2WWX+e2/e/duAzDeeecdX1n37t2NZs2aGfn5+b4yr9drdO7c2WjQoIGvbNy4cQZgfP7558Xi8nq9xeLLz883unXrZkRGRho7duzwq+92u42CggK/siNHjhhRUVHGHXfc4SvLy8szzGazcc899/jVLek1Ko1Zs2YZgLF69Wpf2fGvo2EYRlxcnFGvXj2/stq1axuA8dlnn/nKMjIyjGrVqhmtWrXylRW9fqtWrfLb/9ChQ8VeoyI1atQwBg0a5Hte0utcUpz33HOPERQU5PfaFSnptT5Wac+7JCe6/rNnz/aL2+VyGZGRkUbTpk2NvLw8X725c+cagDFu3LiTHqcs77kaNWoYmZmZvu1Fr/WUKVN8ZSWd88SJEw2TyWTs3bvX7/yO/1yYPn26ARi//vqrr6x27dpGfHx8sTaHDh1qHPtnwJ49ewyLxWI888wzfvXWr19vWK1Wv/KuXbsaF198cbE2X3zxxWKfC7Vr1zYGDBjge/76668bdrvduPzyy4vFf+x779VXXzUAY9q0ab7tbrfb6N69u2G3243U1NRixy+Snp5uhIaGGh06dPB7TQ3jr9fkRMaPH28AxqFDh/zKV61aVey9OmDAAAMwhg8f7td+fHy8YbPZfG18+eWXBmA8/fTTfm327dvXMJlMfp89gDF06NATxlf0Xpo9e3axbcHBwX7X+sEHHzQAY/ny5b6yrKwso27dukadOnUMj8dzwuNcc801RtOmTX3Pj//Mz8/PN2rVquX7XD+V67J161YDMKZ
2024-10-26 12:47:48 +04:00
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-11-09 11:59:00 +04:00
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
2024-10-26 12:47:48 +04:00
"from sklearn.ensemble import RandomForestRegressor\n",
2024-11-09 11:59:00 +04:00
"from sklearn.metrics import r2_score, mean_absolute_error, mean_squared_error\n",
"from sklearn.model_selection import train_test_split, cross_val_score\n",
"\n",
"# Загрузка данных\n",
"df = pd.read_csv(\"..//static//csv//ds_salaries.csv\")\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"# Создание уникального идентификатора для каждой строки\n",
"df['id'] = range(1, len(df) + 1)\n",
"\n",
"# Предобработка данных (например, кодирование категориальных признаков, удаление дубликатов)\n",
"# Удаление дубликатов по всем столбцам\n",
"df = df.drop_duplicates()\n",
"\n",
"# Создание EntitySet\n",
"es = ft.EntitySet(id='data_science_jobs')\n",
"\n",
"# Добавление датафрейма с данными о рабочих местах\n",
"es = es.add_dataframe(\n",
" dataframe_name='jobs',\n",
" dataframe=df,\n",
" index='id'\n",
")\n",
"\n",
"# Генерация признаков с помощью глубокой синтезы признаков\n",
"feature_matrix, feature_defs = ft.dfs(entityset=es, target_dataframe_name='jobs', max_depth=1)\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Удаление строк с NaN\n",
"feature_matrix = feature_matrix.dropna()\n",
"\n",
"# Разделение данных на обучающую и тестовую выборки\n",
2024-11-09 11:59:00 +04:00
"X_train = feature_matrix.drop('salary_in_usd', axis=1)\n",
"y_train = feature_matrix['salary_in_usd']\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Кодирования категориальных переменных с использованием одноразового кодирования\n",
2024-11-09 11:59:00 +04:00
"X_train = pd.get_dummies(X_train, drop_first=True)\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Разобьём тренировочный тест и примерку модели\n",
2024-11-09 11:59:00 +04:00
"X_train, X_test, y_train, y_test = train_test_split(X_train, y_train, test_size=0.2, random_state=42)\n",
2024-10-26 12:47:48 +04:00
"\n",
"# Выбор модели\n",
"model = RandomForestRegressor(random_state=42)\n",
"\n",
"# Обучение модели\n",
"model.fit(X_train, y_train)\n",
"\n",
"# Предсказание и оценка\n",
"y_pred = model.predict(X_test)\n",
"\n",
"rmse = mean_squared_error(y_test, y_pred, squared=False)\n",
"r2 = r2_score(y_test, y_pred)\n",
"mae = mean_absolute_error(y_test, y_pred)\n",
"\n",
"print(f\"RMSE: {rmse}\")\n",
"print(f\"R²: {r2}\")\n",
"print(f\"MAE: {mae} \\n\")\n",
"\n",
"# К р о с с -валидация\n",
"scores = cross_val_score(model, X_train, y_train, cv=5, scoring='neg_mean_squared_error')\n",
"rmse_cv = (-scores.mean())**0.5\n",
"print(f\"К р о с с -валидация RMSE: {rmse_cv} \\n\")\n",
"\n",
"# Анализ важности признаков\n",
"feature_importances = model.feature_importances_\n",
"feature_names = X_train.columns\n",
"\n",
"# Проверка на переобучение\n",
"y_train_pred = model.predict(X_train)\n",
"\n",
"rmse_train = mean_squared_error(y_train, y_train_pred, squared=False)\n",
"r2_train = r2_score(y_train, y_train_pred)\n",
"mae_train = mean_absolute_error(y_train, y_train_pred)\n",
"\n",
"print(f\"Train RMSE: {rmse_train}\")\n",
"print(f\"Train R²: {r2_train}\")\n",
"print(f\"Train MAE: {mae_train}\")\n",
"print()\n",
"\n",
"# Визуализация результатов\n",
"plt.figure(figsize=(10, 6))\n",
"plt.scatter(y_test, y_pred, alpha=0.5)\n",
"plt.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'k--', lw=2)\n",
2024-11-09 11:59:00 +04:00
"plt.xlabel('Фактическая зарплата (USD)')\n",
"plt.ylabel('Прогнозируемая зарплата (USD)')\n",
"plt.title('Фактическая зарплата по сравнению с прогнозируемой')\n",
2024-10-26 12:47:48 +04:00
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-11-09 11:59:00 +04:00
"# Выводы и итог\n",
"Модель случайного леса (RandomForestRegressor) показала удовлетворительные результаты при прогнозировании зарплат в области Data Science. Метрики качества и кросс-валидация позволяют предположить, что модель не сильно переобучена и может быть использована для практических целей.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Точность предсказаний: Модель показывает довольно высокий R² (0.8029), что указывает на хорошее объяснение вариации зарплат. Однако, значения RMSE и MAE довольно высоки, что говорит о том, что модель не очень точно предсказывает зарплаты, особенно для высоких значений.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Переобучение: Разница между RMSE на обучающей и тестовой выборках не очень большая, что указывает на то, что переобучение не является критическим. Однако, стоит быть осторожным и продолжать мониторинг этого показателя.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"К р о с с -валидация: Значение RMSE после кросс-валидации немного выше, чем на тестовой выборке, что может указывать на некоторую нестабильность модели.\n",
2024-10-26 12:47:48 +04:00
"\n",
2024-11-09 11:59:00 +04:00
"Рекомендации: Следует уделить внимание дополнительной обработке категориальных признаков, улучшению метода feature engineering, а также возможной оптимизации модели (например, через подбор гиперпараметров) для повышения точности предсказаний на экстремальных значениях. Также стоит рассмотреть возможность использования других моделей, таких как градиентный бустинг или нейронные сети, для сравнения результатов и выбора наиболее эффективной модели."
2024-10-26 12:47:48 +04:00
]
}
],
"metadata": {
"kernelspec": {
2024-11-09 11:59:00 +04:00
"display_name": "aimenv",
2024-10-26 12:47:48 +04:00
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2024-11-09 11:59:00 +04:00
"version": "3.12.5"
2024-10-26 12:47:48 +04:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}