2709 lines
122 KiB
Plaintext
2709 lines
122 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"id": "CvmiakWDcuyf"
|
||
},
|
||
"source": [
|
||
"# Лабораторная работа №2\n",
|
||
"## по предмету \"Системы искусственного интеллекта\"\n",
|
||
"\n",
|
||
"В данной лабораторной работе вы будете работать с набором данных, который содержит информацию о технических характеристиках ноутбуков и их цену.\n",
|
||
"Целью работы является изучение теоретических основ методов машинного обучения.\n",
|
||
"\n",
|
||
"В наборе данных для лабораторной работы содержится абор характеристик мобильных телефонов, включая мощность аккумулятора, характеристики камеры, поддержку сети, память, размеры экрана и другие атрибуты. Столбец «price_range» классифицирует телефоны по ценовым диапазонам (этот столбец необходимо предсказать)."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"id": "YEZ0T1uwj34v"
|
||
},
|
||
"source": [
|
||
"### Задание 1\n",
|
||
"\n",
|
||
"Выгрузите данные из датасета. Изучите колонки, проверьте наличие пропусков. Постройте матрицу корреляции между признаками и целевой переменной. Сделайте выводы, что показывает эта матрица."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 2,
|
||
"metadata": {
|
||
"id": "91NHysjQj26f"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>battery_power</th>\n",
|
||
" <th>blue</th>\n",
|
||
" <th>clock_speed</th>\n",
|
||
" <th>dual_sim</th>\n",
|
||
" <th>fc</th>\n",
|
||
" <th>four_g</th>\n",
|
||
" <th>int_memory</th>\n",
|
||
" <th>m_dep</th>\n",
|
||
" <th>mobile_wt</th>\n",
|
||
" <th>n_cores</th>\n",
|
||
" <th>...</th>\n",
|
||
" <th>px_height</th>\n",
|
||
" <th>px_width</th>\n",
|
||
" <th>ram</th>\n",
|
||
" <th>sc_h</th>\n",
|
||
" <th>sc_w</th>\n",
|
||
" <th>talk_time</th>\n",
|
||
" <th>three_g</th>\n",
|
||
" <th>touch_screen</th>\n",
|
||
" <th>wifi</th>\n",
|
||
" <th>price_range</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>842</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2.2</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>0.6</td>\n",
|
||
" <td>188</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>20</td>\n",
|
||
" <td>756</td>\n",
|
||
" <td>2549</td>\n",
|
||
" <td>9</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>19</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>1021</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0.5</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>53</td>\n",
|
||
" <td>0.7</td>\n",
|
||
" <td>136</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>905</td>\n",
|
||
" <td>1988</td>\n",
|
||
" <td>2631</td>\n",
|
||
" <td>17</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>563</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0.5</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>41</td>\n",
|
||
" <td>0.9</td>\n",
|
||
" <td>145</td>\n",
|
||
" <td>5</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>1263</td>\n",
|
||
" <td>1716</td>\n",
|
||
" <td>2603</td>\n",
|
||
" <td>11</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>9</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>615</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>2.5</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>10</td>\n",
|
||
" <td>0.8</td>\n",
|
||
" <td>131</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>1216</td>\n",
|
||
" <td>1786</td>\n",
|
||
" <td>2769</td>\n",
|
||
" <td>16</td>\n",
|
||
" <td>8</td>\n",
|
||
" <td>11</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>1821</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1.2</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>13</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>44</td>\n",
|
||
" <td>0.6</td>\n",
|
||
" <td>141</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>...</td>\n",
|
||
" <td>1208</td>\n",
|
||
" <td>1212</td>\n",
|
||
" <td>1411</td>\n",
|
||
" <td>8</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>15</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"<p>5 rows × 21 columns</p>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" battery_power blue clock_speed dual_sim fc four_g int_memory m_dep \\\n",
|
||
"0 842 0 2.2 0 1 0 7 0.6 \n",
|
||
"1 1021 1 0.5 1 0 1 53 0.7 \n",
|
||
"2 563 1 0.5 1 2 1 41 0.9 \n",
|
||
"3 615 1 2.5 0 0 0 10 0.8 \n",
|
||
"4 1821 1 1.2 0 13 1 44 0.6 \n",
|
||
"\n",
|
||
" mobile_wt n_cores ... px_height px_width ram sc_h sc_w talk_time \\\n",
|
||
"0 188 2 ... 20 756 2549 9 7 19 \n",
|
||
"1 136 3 ... 905 1988 2631 17 3 7 \n",
|
||
"2 145 5 ... 1263 1716 2603 11 2 9 \n",
|
||
"3 131 6 ... 1216 1786 2769 16 8 11 \n",
|
||
"4 141 2 ... 1208 1212 1411 8 2 15 \n",
|
||
"\n",
|
||
" three_g touch_screen wifi price_range \n",
|
||
"0 0 0 1 1 \n",
|
||
"1 1 1 0 2 \n",
|
||
"2 1 1 0 2 \n",
|
||
"3 1 0 0 2 \n",
|
||
"4 1 1 0 1 \n",
|
||
"\n",
|
||
"[5 rows x 21 columns]"
|
||
]
|
||
},
|
||
"execution_count": 2,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"import pandas as pd\n",
|
||
"\n",
|
||
"df = pd.read_csv('AIS2.csv')\n",
|
||
"\n",
|
||
"df.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 3,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"battery_power 0\n",
|
||
"blue 0\n",
|
||
"clock_speed 0\n",
|
||
"dual_sim 0\n",
|
||
"fc 0\n",
|
||
"four_g 0\n",
|
||
"int_memory 0\n",
|
||
"m_dep 0\n",
|
||
"mobile_wt 0\n",
|
||
"n_cores 0\n",
|
||
"pc 0\n",
|
||
"px_height 0\n",
|
||
"px_width 0\n",
|
||
"ram 0\n",
|
||
"sc_h 0\n",
|
||
"sc_w 0\n",
|
||
"talk_time 0\n",
|
||
"three_g 0\n",
|
||
"touch_screen 0\n",
|
||
"wifi 0\n",
|
||
"price_range 0\n",
|
||
"dtype: int64"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"battery_power 0\n",
|
||
"blue 0\n",
|
||
"clock_speed 0\n",
|
||
"dual_sim 0\n",
|
||
"fc 0\n",
|
||
"four_g 0\n",
|
||
"int_memory 0\n",
|
||
"m_dep 0\n",
|
||
"mobile_wt 0\n",
|
||
"n_cores 0\n",
|
||
"pc 0\n",
|
||
"px_height 0\n",
|
||
"px_width 0\n",
|
||
"ram 0\n",
|
||
"sc_h 0\n",
|
||
"sc_w 0\n",
|
||
"talk_time 0\n",
|
||
"three_g 0\n",
|
||
"touch_screen 0\n",
|
||
"wifi 0\n",
|
||
"price_range 0\n",
|
||
"dtype: int64"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"battery_power 0\n",
|
||
"blue 1010\n",
|
||
"clock_speed 0\n",
|
||
"dual_sim 981\n",
|
||
"fc 474\n",
|
||
"four_g 957\n",
|
||
"int_memory 0\n",
|
||
"m_dep 0\n",
|
||
"mobile_wt 0\n",
|
||
"n_cores 0\n",
|
||
"pc 101\n",
|
||
"px_height 2\n",
|
||
"px_width 0\n",
|
||
"ram 0\n",
|
||
"sc_h 0\n",
|
||
"sc_w 180\n",
|
||
"talk_time 0\n",
|
||
"three_g 477\n",
|
||
"touch_screen 994\n",
|
||
"wifi 986\n",
|
||
"price_range 500\n",
|
||
"dtype: int64"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
}
|
||
],
|
||
"source": [
|
||
"display(df.isnull().sum())\n",
|
||
"display(df.isna().sum())\n",
|
||
"display(df.eq(0).sum())"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"price_range 1.000000\n",
|
||
"ram 0.917046\n",
|
||
"battery_power 0.200723\n",
|
||
"px_width 0.165818\n",
|
||
"px_height 0.148858\n",
|
||
"int_memory 0.044435\n",
|
||
"sc_w 0.038711\n",
|
||
"pc 0.033599\n",
|
||
"three_g 0.023611\n",
|
||
"sc_h 0.022986\n",
|
||
"fc 0.021998\n",
|
||
"talk_time 0.021859\n",
|
||
"blue 0.020573\n",
|
||
"wifi 0.018785\n",
|
||
"dual_sim 0.017444\n",
|
||
"four_g 0.014772\n",
|
||
"n_cores 0.004399\n",
|
||
"m_dep 0.000853\n",
|
||
"clock_speed -0.006606\n",
|
||
"mobile_wt -0.030302\n",
|
||
"touch_screen -0.030411\n",
|
||
"Name: price_range, dtype: float64"
|
||
]
|
||
},
|
||
"execution_count": 4,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"df.corr()['price_range'].sort_values(ascending=False)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"id": "Ch5WytHwlGpd"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<div>\n",
|
||
"<style scoped>\n",
|
||
" .dataframe tbody tr th:only-of-type {\n",
|
||
" vertical-align: middle;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe tbody tr th {\n",
|
||
" vertical-align: top;\n",
|
||
" }\n",
|
||
"\n",
|
||
" .dataframe thead th {\n",
|
||
" text-align: right;\n",
|
||
" }\n",
|
||
"</style>\n",
|
||
"<table border=\"1\" class=\"dataframe\">\n",
|
||
" <thead>\n",
|
||
" <tr style=\"text-align: right;\">\n",
|
||
" <th></th>\n",
|
||
" <th>battery_power</th>\n",
|
||
" <th>blue</th>\n",
|
||
" <th>clock_speed</th>\n",
|
||
" <th>dual_sim</th>\n",
|
||
" <th>fc</th>\n",
|
||
" <th>four_g</th>\n",
|
||
" <th>int_memory</th>\n",
|
||
" <th>m_dep</th>\n",
|
||
" <th>mobile_wt</th>\n",
|
||
" <th>n_cores</th>\n",
|
||
" <th>pc</th>\n",
|
||
" <th>px_height</th>\n",
|
||
" <th>px_width</th>\n",
|
||
" <th>ram</th>\n",
|
||
" <th>sc_h</th>\n",
|
||
" <th>sc_w</th>\n",
|
||
" <th>talk_time</th>\n",
|
||
" <th>three_g</th>\n",
|
||
" <th>touch_screen</th>\n",
|
||
" <th>wifi</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>842</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>2.2</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>0.6</td>\n",
|
||
" <td>188</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>20</td>\n",
|
||
" <td>756</td>\n",
|
||
" <td>2549</td>\n",
|
||
" <td>9</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>19</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>1021</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0.5</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>53</td>\n",
|
||
" <td>0.7</td>\n",
|
||
" <td>136</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>905</td>\n",
|
||
" <td>1988</td>\n",
|
||
" <td>2631</td>\n",
|
||
" <td>17</td>\n",
|
||
" <td>3</td>\n",
|
||
" <td>7</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>563</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0.5</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>41</td>\n",
|
||
" <td>0.9</td>\n",
|
||
" <td>145</td>\n",
|
||
" <td>5</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>1263</td>\n",
|
||
" <td>1716</td>\n",
|
||
" <td>2603</td>\n",
|
||
" <td>11</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>9</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>615</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>2.5</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>10</td>\n",
|
||
" <td>0.8</td>\n",
|
||
" <td>131</td>\n",
|
||
" <td>6</td>\n",
|
||
" <td>9</td>\n",
|
||
" <td>1216</td>\n",
|
||
" <td>1786</td>\n",
|
||
" <td>2769</td>\n",
|
||
" <td>16</td>\n",
|
||
" <td>8</td>\n",
|
||
" <td>11</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>0</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>1821</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1.2</td>\n",
|
||
" <td>0</td>\n",
|
||
" <td>13</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>44</td>\n",
|
||
" <td>0.6</td>\n",
|
||
" <td>141</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>14</td>\n",
|
||
" <td>1208</td>\n",
|
||
" <td>1212</td>\n",
|
||
" <td>1411</td>\n",
|
||
" <td>8</td>\n",
|
||
" <td>2</td>\n",
|
||
" <td>15</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>1</td>\n",
|
||
" <td>0</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>"
|
||
],
|
||
"text/plain": [
|
||
" battery_power blue clock_speed dual_sim fc four_g int_memory m_dep \\\n",
|
||
"0 842 0 2.2 0 1 0 7 0.6 \n",
|
||
"1 1021 1 0.5 1 0 1 53 0.7 \n",
|
||
"2 563 1 0.5 1 2 1 41 0.9 \n",
|
||
"3 615 1 2.5 0 0 0 10 0.8 \n",
|
||
"4 1821 1 1.2 0 13 1 44 0.6 \n",
|
||
"\n",
|
||
" mobile_wt n_cores pc px_height px_width ram sc_h sc_w talk_time \\\n",
|
||
"0 188 2 2 20 756 2549 9 7 19 \n",
|
||
"1 136 3 6 905 1988 2631 17 3 7 \n",
|
||
"2 145 5 6 1263 1716 2603 11 2 9 \n",
|
||
"3 131 6 9 1216 1786 2769 16 8 11 \n",
|
||
"4 141 2 14 1208 1212 1411 8 2 15 \n",
|
||
"\n",
|
||
" three_g touch_screen wifi \n",
|
||
"0 0 0 1 \n",
|
||
"1 1 1 0 \n",
|
||
"2 1 1 0 \n",
|
||
"3 1 0 0 \n",
|
||
"4 1 1 0 "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"array([[ 1.38919326, 1.011314 , -1.25918898, ..., -1.78870765,\n",
|
||
" -1.00878862, -1.02532046],\n",
|
||
" [ 0.07840603, 1.011314 , -1.25918898, ..., -1.78870765,\n",
|
||
" -1.00878862, 0.97530483],\n",
|
||
" [-1.02457347, -0.98881258, 1.18747125, ..., 0.55906285,\n",
|
||
" 0.99128795, 0.97530483],\n",
|
||
" ...,\n",
|
||
" [ 1.10374308, -0.98881258, 0.5758062 , ..., 0.55906285,\n",
|
||
" 0.99128795, 0.97530483],\n",
|
||
" [-1.21867959, 1.011314 , 1.43213728, ..., 0.55906285,\n",
|
||
" -1.00878862, -1.02532046],\n",
|
||
" [-0.39429947, -0.98881258, 1.6768033 , ..., 0.55906285,\n",
|
||
" -1.00878862, -1.02532046]], shape=(1600, 20))"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
}
|
||
],
|
||
"source": [
|
||
"from sklearn.model_selection import train_test_split\n",
|
||
"from sklearn.preprocessing import StandardScaler\n",
|
||
"\n",
|
||
"X = df.drop('price_range', axis=1)\n",
|
||
"y = df['price_range']\n",
|
||
"\n",
|
||
"X_train, X_test, y_train, y_test = train_test_split(\n",
|
||
" X, y, test_size=0.2, random_state=42, stratify=y\n",
|
||
")\n",
|
||
"\n",
|
||
"display(X.head())\n",
|
||
"\n",
|
||
"scaler = StandardScaler() # С minmax хуже (x - mean) / std\n",
|
||
"X_train_scaled = scaler.fit_transform(X_train)\n",
|
||
"X_test_scaled = scaler.transform(X_test)\n",
|
||
"\n",
|
||
"display(X_train_scaled)\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### Задание 2\n",
|
||
"\n",
|
||
"Реализуйте с алгоритм логистической регрессии для многоклассовой классификации."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 19,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<style>#sk-container-id-7 {\n",
|
||
" /* Definition of color scheme common for light and dark mode */\n",
|
||
" --sklearn-color-text: #000;\n",
|
||
" --sklearn-color-text-muted: #666;\n",
|
||
" --sklearn-color-line: gray;\n",
|
||
" /* Definition of color scheme for unfitted estimators */\n",
|
||
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
||
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
||
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
||
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
||
" /* Definition of color scheme for fitted estimators */\n",
|
||
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
||
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
||
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
||
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
||
"\n",
|
||
" /* Specific color for light theme */\n",
|
||
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
||
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
||
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
||
" --sklearn-color-icon: #696969;\n",
|
||
"\n",
|
||
" @media (prefers-color-scheme: dark) {\n",
|
||
" /* Redefinition of color scheme for dark theme */\n",
|
||
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
||
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
||
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
||
" --sklearn-color-icon: #878787;\n",
|
||
" }\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 pre {\n",
|
||
" padding: 0;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 input.sk-hidden--visually {\n",
|
||
" border: 0;\n",
|
||
" clip: rect(1px 1px 1px 1px);\n",
|
||
" clip: rect(1px, 1px, 1px, 1px);\n",
|
||
" height: 1px;\n",
|
||
" margin: -1px;\n",
|
||
" overflow: hidden;\n",
|
||
" padding: 0;\n",
|
||
" position: absolute;\n",
|
||
" width: 1px;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-dashed-wrapped {\n",
|
||
" border: 1px dashed var(--sklearn-color-line);\n",
|
||
" margin: 0 0.4em 0.5em 0.4em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" padding-bottom: 0.4em;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-container {\n",
|
||
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
||
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
||
" so we also need the `!important` here to be able to override the\n",
|
||
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
||
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
||
" display: inline-block !important;\n",
|
||
" position: relative;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-text-repr-fallback {\n",
|
||
" display: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"div.sk-parallel-item,\n",
|
||
"div.sk-serial,\n",
|
||
"div.sk-item {\n",
|
||
" /* draw centered vertical line to link estimators */\n",
|
||
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
||
" background-size: 2px 100%;\n",
|
||
" background-repeat: no-repeat;\n",
|
||
" background-position: center center;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Parallel-specific style estimator block */\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-parallel-item::after {\n",
|
||
" content: \"\";\n",
|
||
" width: 100%;\n",
|
||
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
||
" flex-grow: 1;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-parallel {\n",
|
||
" display: flex;\n",
|
||
" align-items: stretch;\n",
|
||
" justify-content: center;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" position: relative;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-parallel-item {\n",
|
||
" display: flex;\n",
|
||
" flex-direction: column;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-parallel-item:first-child::after {\n",
|
||
" align-self: flex-end;\n",
|
||
" width: 50%;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-parallel-item:last-child::after {\n",
|
||
" align-self: flex-start;\n",
|
||
" width: 50%;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-parallel-item:only-child::after {\n",
|
||
" width: 0;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Serial-specific style estimator block */\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-serial {\n",
|
||
" display: flex;\n",
|
||
" flex-direction: column;\n",
|
||
" align-items: center;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" padding-right: 1em;\n",
|
||
" padding-left: 1em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"\n",
|
||
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
||
"clickable and can be expanded/collapsed.\n",
|
||
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
||
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
||
"*/\n",
|
||
"\n",
|
||
"/* Pipeline and ColumnTransformer style (default) */\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-toggleable {\n",
|
||
" /* Default theme specific background. It is overwritten whether we have a\n",
|
||
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Toggleable label */\n",
|
||
"#sk-container-id-7 label.sk-toggleable__label {\n",
|
||
" cursor: pointer;\n",
|
||
" display: flex;\n",
|
||
" width: 100%;\n",
|
||
" margin-bottom: 0;\n",
|
||
" padding: 0.5em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" text-align: center;\n",
|
||
" align-items: start;\n",
|
||
" justify-content: space-between;\n",
|
||
" gap: 0.5em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 label.sk-toggleable__label .caption {\n",
|
||
" font-size: 0.6rem;\n",
|
||
" font-weight: lighter;\n",
|
||
" color: var(--sklearn-color-text-muted);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 label.sk-toggleable__label-arrow:before {\n",
|
||
" /* Arrow on the left of the label */\n",
|
||
" content: \"▸\";\n",
|
||
" float: left;\n",
|
||
" margin-right: 0.25em;\n",
|
||
" color: var(--sklearn-color-icon);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 label.sk-toggleable__label-arrow:hover:before {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Toggleable content - dropdown */\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-toggleable__content {\n",
|
||
" display: none;\n",
|
||
" text-align: left;\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-toggleable__content.fitted {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-toggleable__content pre {\n",
|
||
" margin: 0.2em;\n",
|
||
" border-radius: 0.25em;\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-toggleable__content.fitted pre {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
||
" /* Expand drop-down */\n",
|
||
" display: block;\n",
|
||
" width: 100%;\n",
|
||
" overflow: visible;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
||
" content: \"▾\";\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Pipeline/ColumnTransformer-specific style */\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator-specific style */\n",
|
||
"\n",
|
||
"/* Colorize estimator box */\n",
|
||
"#sk-container-id-7 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-label label.sk-toggleable__label,\n",
|
||
"#sk-container-id-7 div.sk-label label {\n",
|
||
" /* The background is the default theme color */\n",
|
||
" color: var(--sklearn-color-text-on-default-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover, darken the color of the background */\n",
|
||
"#sk-container-id-7 div.sk-label:hover label.sk-toggleable__label {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Label box, darken color on hover, fitted */\n",
|
||
"#sk-container-id-7 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator label */\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-label label {\n",
|
||
" font-family: monospace;\n",
|
||
" font-weight: bold;\n",
|
||
" display: inline-block;\n",
|
||
" line-height: 1.2em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-label-container {\n",
|
||
" text-align: center;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator-specific */\n",
|
||
"#sk-container-id-7 div.sk-estimator {\n",
|
||
" font-family: monospace;\n",
|
||
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
||
" border-radius: 0.25em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" margin-bottom: 0.5em;\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-estimator.fitted {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* on hover */\n",
|
||
"#sk-container-id-7 div.sk-estimator:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 div.sk-estimator.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
||
"\n",
|
||
"/* Common style for \"i\" and \"?\" */\n",
|
||
"\n",
|
||
".sk-estimator-doc-link,\n",
|
||
"a:link.sk-estimator-doc-link,\n",
|
||
"a:visited.sk-estimator-doc-link {\n",
|
||
" float: right;\n",
|
||
" font-size: smaller;\n",
|
||
" line-height: 1em;\n",
|
||
" font-family: monospace;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" border-radius: 1em;\n",
|
||
" height: 1em;\n",
|
||
" width: 1em;\n",
|
||
" text-decoration: none !important;\n",
|
||
" margin-left: 0.5em;\n",
|
||
" text-align: center;\n",
|
||
" /* unfitted */\n",
|
||
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-unfitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link.fitted,\n",
|
||
"a:link.sk-estimator-doc-link.fitted,\n",
|
||
"a:visited.sk-estimator-doc-link.fitted {\n",
|
||
" /* fitted */\n",
|
||
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-fitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover */\n",
|
||
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
||
".sk-estimator-doc-link:hover,\n",
|
||
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
||
".sk-estimator-doc-link:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
||
".sk-estimator-doc-link.fitted:hover,\n",
|
||
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
||
".sk-estimator-doc-link.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Span, style for the box shown on hovering the info icon */\n",
|
||
".sk-estimator-doc-link span {\n",
|
||
" display: none;\n",
|
||
" z-index: 9999;\n",
|
||
" position: relative;\n",
|
||
" font-weight: normal;\n",
|
||
" right: .2ex;\n",
|
||
" padding: .5ex;\n",
|
||
" margin: .5ex;\n",
|
||
" width: min-content;\n",
|
||
" min-width: 20ex;\n",
|
||
" max-width: 50ex;\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" box-shadow: 2pt 2pt 4pt #999;\n",
|
||
" /* unfitted */\n",
|
||
" background: var(--sklearn-color-unfitted-level-0);\n",
|
||
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link.fitted span {\n",
|
||
" /* fitted */\n",
|
||
" background: var(--sklearn-color-fitted-level-0);\n",
|
||
" border: var(--sklearn-color-fitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link:hover span {\n",
|
||
" display: block;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
||
"\n",
|
||
"#sk-container-id-7 a.estimator_doc_link {\n",
|
||
" float: right;\n",
|
||
" font-size: 1rem;\n",
|
||
" line-height: 1em;\n",
|
||
" font-family: monospace;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" border-radius: 1rem;\n",
|
||
" height: 1rem;\n",
|
||
" width: 1rem;\n",
|
||
" text-decoration: none;\n",
|
||
" /* unfitted */\n",
|
||
" color: var(--sklearn-color-unfitted-level-1);\n",
|
||
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 a.estimator_doc_link.fitted {\n",
|
||
" /* fitted */\n",
|
||
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-fitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover */\n",
|
||
"#sk-container-id-7 a.estimator_doc_link:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-7 a.estimator_doc_link.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table summary {\n",
|
||
" padding: .5rem;\n",
|
||
" font-family: monospace;\n",
|
||
" cursor: pointer;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table details[open] {\n",
|
||
" padding-left: 0.1rem;\n",
|
||
" padding-right: 0.1rem;\n",
|
||
" padding-bottom: 0.3rem;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table {\n",
|
||
" margin-left: auto !important;\n",
|
||
" margin-right: auto !important;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:nth-child(odd) {\n",
|
||
" background-color: #fff;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:nth-child(even) {\n",
|
||
" background-color: #f6f6f6;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:hover {\n",
|
||
" background-color: #e0e0e0;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table table td {\n",
|
||
" border: 1px solid rgba(106, 105, 104, 0.232);\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td {\n",
|
||
" color:rgb(255, 94, 0);\n",
|
||
" text-align: left;\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td.value pre {\n",
|
||
" color:rgb(255, 94, 0) !important;\n",
|
||
" background-color: transparent !important;\n",
|
||
"}\n",
|
||
"\n",
|
||
".default td {\n",
|
||
" color: black;\n",
|
||
" text-align: left;\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td i,\n",
|
||
".default td i {\n",
|
||
" color: black;\n",
|
||
"}\n",
|
||
"\n",
|
||
".copy-paste-icon {\n",
|
||
" background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTIwOCAwTDMzMi4xIDBjMTIuNyAwIDI0LjkgNS4xIDMzLjkgMTQuMWw2Ny45IDY3LjljOSA5IDE0LjEgMjEuMiAxNC4xIDMzLjlMNDQ4IDMzNmMwIDI2LjUtMjEuNSA0OC00OCA0OGwtMTkyIDBjLTI2LjUgMC00OC0yMS41LTQ4LTQ4bDAtMjg4YzAtMjYuNSAyMS41LTQ4IDQ4LTQ4ek00OCAxMjhsODAgMCAwIDY0LTY0IDAgMCAyNTYgMTkyIDAgMC0zMiA2NCAwIDAgNDhjMCAyNi41LTIxLjUgNDgtNDggNDhMNDggNTEyYy0yNi41IDAtNDgtMjEuNS00OC00OEwwIDE3NmMwLTI2LjUgMjEuNS00OCA0OC00OHoiLz48L3N2Zz4=);\n",
|
||
" background-repeat: no-repeat;\n",
|
||
" background-size: 14px 14px;\n",
|
||
" background-position: 0;\n",
|
||
" display: inline-block;\n",
|
||
" width: 14px;\n",
|
||
" height: 14px;\n",
|
||
" cursor: pointer;\n",
|
||
"}\n",
|
||
"</style><body><div id=\"sk-container-id-7\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LogisticRegression(max_iter=1000, random_state=42)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-7\" type=\"checkbox\" checked><label for=\"sk-estimator-id-7\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>LogisticRegression</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.7/modules/generated/sklearn.linear_model.LogisticRegression.html\">?<span>Documentation for LogisticRegression</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\" data-param-prefix=\"\">\n",
|
||
" <div class=\"estimator-table\">\n",
|
||
" <details>\n",
|
||
" <summary>Parameters</summary>\n",
|
||
" <table class=\"parameters-table\">\n",
|
||
" <tbody>\n",
|
||
" \n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('penalty',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">penalty </td>\n",
|
||
" <td class=\"value\">'l2'</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('dual',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">dual </td>\n",
|
||
" <td class=\"value\">False</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('tol',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">tol </td>\n",
|
||
" <td class=\"value\">0.0001</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('C',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">C </td>\n",
|
||
" <td class=\"value\">1.0</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('fit_intercept',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">fit_intercept </td>\n",
|
||
" <td class=\"value\">True</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('intercept_scaling',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">intercept_scaling </td>\n",
|
||
" <td class=\"value\">1</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('class_weight',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">class_weight </td>\n",
|
||
" <td class=\"value\">None</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"user-set\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('random_state',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">random_state </td>\n",
|
||
" <td class=\"value\">42</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('solver',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">solver </td>\n",
|
||
" <td class=\"value\">'lbfgs'</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"user-set\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('max_iter',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">max_iter </td>\n",
|
||
" <td class=\"value\">1000</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('multi_class',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">multi_class </td>\n",
|
||
" <td class=\"value\">'deprecated'</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('verbose',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">verbose </td>\n",
|
||
" <td class=\"value\">0</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('warm_start',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">warm_start </td>\n",
|
||
" <td class=\"value\">False</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('n_jobs',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">n_jobs </td>\n",
|
||
" <td class=\"value\">None</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('l1_ratio',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">l1_ratio </td>\n",
|
||
" <td class=\"value\">None</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
" </tbody>\n",
|
||
" </table>\n",
|
||
" </details>\n",
|
||
" </div>\n",
|
||
" </div></div></div></div></div><script>function copyToClipboard(text, element) {\n",
|
||
" // Get the parameter prefix from the closest toggleable content\n",
|
||
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
|
||
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
|
||
" const fullParamName = paramPrefix ? `${paramPrefix}${text}` : text;\n",
|
||
"\n",
|
||
" const originalStyle = element.style;\n",
|
||
" const computedStyle = window.getComputedStyle(element);\n",
|
||
" const originalWidth = computedStyle.width;\n",
|
||
" const originalHTML = element.innerHTML.replace('Copied!', '');\n",
|
||
"\n",
|
||
" navigator.clipboard.writeText(fullParamName)\n",
|
||
" .then(() => {\n",
|
||
" element.style.width = originalWidth;\n",
|
||
" element.style.color = 'green';\n",
|
||
" element.innerHTML = \"Copied!\";\n",
|
||
"\n",
|
||
" setTimeout(() => {\n",
|
||
" element.innerHTML = originalHTML;\n",
|
||
" element.style = originalStyle;\n",
|
||
" }, 2000);\n",
|
||
" })\n",
|
||
" .catch(err => {\n",
|
||
" console.error('Failed to copy:', err);\n",
|
||
" element.style.color = 'red';\n",
|
||
" element.innerHTML = \"Failed!\";\n",
|
||
" setTimeout(() => {\n",
|
||
" element.innerHTML = originalHTML;\n",
|
||
" element.style = originalStyle;\n",
|
||
" }, 2000);\n",
|
||
" });\n",
|
||
" return false;\n",
|
||
"}\n",
|
||
"\n",
|
||
"document.querySelectorAll('.fa-regular.fa-copy').forEach(function(element) {\n",
|
||
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
|
||
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
|
||
" const paramName = element.parentElement.nextElementSibling.textContent.trim();\n",
|
||
" const fullParamName = paramPrefix ? `${paramPrefix}${paramName}` : paramName;\n",
|
||
"\n",
|
||
" element.setAttribute('title', fullParamName);\n",
|
||
"});\n",
|
||
"</script></body>"
|
||
],
|
||
"text/plain": [
|
||
"LogisticRegression(max_iter=1000, random_state=42)"
|
||
]
|
||
},
|
||
"execution_count": 19,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"from sklearn.linear_model import LogisticRegression\n",
|
||
"\n",
|
||
"model = LogisticRegression(\n",
|
||
" max_iter=1000,\n",
|
||
" random_state=42\n",
|
||
")\n",
|
||
"\n",
|
||
"model.fit(X_train_scaled, y_train)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 21,
|
||
"metadata": {
|
||
"id": "nwDuPoSHlKDP"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Точность модели: 0.965\n",
|
||
"[[98 2 0 0]\n",
|
||
" [ 1 96 3 0]\n",
|
||
" [ 0 2 94 4]\n",
|
||
" [ 0 0 2 98]]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"from sklearn.metrics import confusion_matrix, accuracy_score\n",
|
||
"\n",
|
||
"y_pred = model.predict(X_test_scaled)\n",
|
||
"\n",
|
||
"print(\"Точность модели:\", accuracy_score(y_test, y_pred))\n",
|
||
"print(confusion_matrix(y_test, y_pred))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"id": "eWc9D163lKPB"
|
||
},
|
||
"source": [
|
||
"### Задание 3\n",
|
||
"\n",
|
||
"Реализуйте алгоритм Наивный Байес."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 15,
|
||
"metadata": {
|
||
"id": "LRuuj9PDli5A"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<style>#sk-container-id-5 {\n",
|
||
" /* Definition of color scheme common for light and dark mode */\n",
|
||
" --sklearn-color-text: #000;\n",
|
||
" --sklearn-color-text-muted: #666;\n",
|
||
" --sklearn-color-line: gray;\n",
|
||
" /* Definition of color scheme for unfitted estimators */\n",
|
||
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
||
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
||
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
||
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
||
" /* Definition of color scheme for fitted estimators */\n",
|
||
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
||
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
||
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
||
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
||
"\n",
|
||
" /* Specific color for light theme */\n",
|
||
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
||
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
||
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
||
" --sklearn-color-icon: #696969;\n",
|
||
"\n",
|
||
" @media (prefers-color-scheme: dark) {\n",
|
||
" /* Redefinition of color scheme for dark theme */\n",
|
||
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
||
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
||
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
||
" --sklearn-color-icon: #878787;\n",
|
||
" }\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 pre {\n",
|
||
" padding: 0;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 input.sk-hidden--visually {\n",
|
||
" border: 0;\n",
|
||
" clip: rect(1px 1px 1px 1px);\n",
|
||
" clip: rect(1px, 1px, 1px, 1px);\n",
|
||
" height: 1px;\n",
|
||
" margin: -1px;\n",
|
||
" overflow: hidden;\n",
|
||
" padding: 0;\n",
|
||
" position: absolute;\n",
|
||
" width: 1px;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-dashed-wrapped {\n",
|
||
" border: 1px dashed var(--sklearn-color-line);\n",
|
||
" margin: 0 0.4em 0.5em 0.4em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" padding-bottom: 0.4em;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-container {\n",
|
||
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
||
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
||
" so we also need the `!important` here to be able to override the\n",
|
||
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
||
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
||
" display: inline-block !important;\n",
|
||
" position: relative;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-text-repr-fallback {\n",
|
||
" display: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"div.sk-parallel-item,\n",
|
||
"div.sk-serial,\n",
|
||
"div.sk-item {\n",
|
||
" /* draw centered vertical line to link estimators */\n",
|
||
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
||
" background-size: 2px 100%;\n",
|
||
" background-repeat: no-repeat;\n",
|
||
" background-position: center center;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Parallel-specific style estimator block */\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-parallel-item::after {\n",
|
||
" content: \"\";\n",
|
||
" width: 100%;\n",
|
||
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
||
" flex-grow: 1;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-parallel {\n",
|
||
" display: flex;\n",
|
||
" align-items: stretch;\n",
|
||
" justify-content: center;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" position: relative;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-parallel-item {\n",
|
||
" display: flex;\n",
|
||
" flex-direction: column;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-parallel-item:first-child::after {\n",
|
||
" align-self: flex-end;\n",
|
||
" width: 50%;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-parallel-item:last-child::after {\n",
|
||
" align-self: flex-start;\n",
|
||
" width: 50%;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-parallel-item:only-child::after {\n",
|
||
" width: 0;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Serial-specific style estimator block */\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-serial {\n",
|
||
" display: flex;\n",
|
||
" flex-direction: column;\n",
|
||
" align-items: center;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" padding-right: 1em;\n",
|
||
" padding-left: 1em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"\n",
|
||
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
||
"clickable and can be expanded/collapsed.\n",
|
||
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
||
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
||
"*/\n",
|
||
"\n",
|
||
"/* Pipeline and ColumnTransformer style (default) */\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-toggleable {\n",
|
||
" /* Default theme specific background. It is overwritten whether we have a\n",
|
||
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Toggleable label */\n",
|
||
"#sk-container-id-5 label.sk-toggleable__label {\n",
|
||
" cursor: pointer;\n",
|
||
" display: flex;\n",
|
||
" width: 100%;\n",
|
||
" margin-bottom: 0;\n",
|
||
" padding: 0.5em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" text-align: center;\n",
|
||
" align-items: start;\n",
|
||
" justify-content: space-between;\n",
|
||
" gap: 0.5em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 label.sk-toggleable__label .caption {\n",
|
||
" font-size: 0.6rem;\n",
|
||
" font-weight: lighter;\n",
|
||
" color: var(--sklearn-color-text-muted);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 label.sk-toggleable__label-arrow:before {\n",
|
||
" /* Arrow on the left of the label */\n",
|
||
" content: \"▸\";\n",
|
||
" float: left;\n",
|
||
" margin-right: 0.25em;\n",
|
||
" color: var(--sklearn-color-icon);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 label.sk-toggleable__label-arrow:hover:before {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Toggleable content - dropdown */\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-toggleable__content {\n",
|
||
" display: none;\n",
|
||
" text-align: left;\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-toggleable__content.fitted {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-toggleable__content pre {\n",
|
||
" margin: 0.2em;\n",
|
||
" border-radius: 0.25em;\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-toggleable__content.fitted pre {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
||
" /* Expand drop-down */\n",
|
||
" display: block;\n",
|
||
" width: 100%;\n",
|
||
" overflow: visible;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
||
" content: \"▾\";\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Pipeline/ColumnTransformer-specific style */\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator-specific style */\n",
|
||
"\n",
|
||
"/* Colorize estimator box */\n",
|
||
"#sk-container-id-5 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-label label.sk-toggleable__label,\n",
|
||
"#sk-container-id-5 div.sk-label label {\n",
|
||
" /* The background is the default theme color */\n",
|
||
" color: var(--sklearn-color-text-on-default-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover, darken the color of the background */\n",
|
||
"#sk-container-id-5 div.sk-label:hover label.sk-toggleable__label {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Label box, darken color on hover, fitted */\n",
|
||
"#sk-container-id-5 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator label */\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-label label {\n",
|
||
" font-family: monospace;\n",
|
||
" font-weight: bold;\n",
|
||
" display: inline-block;\n",
|
||
" line-height: 1.2em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-label-container {\n",
|
||
" text-align: center;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator-specific */\n",
|
||
"#sk-container-id-5 div.sk-estimator {\n",
|
||
" font-family: monospace;\n",
|
||
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
||
" border-radius: 0.25em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" margin-bottom: 0.5em;\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-estimator.fitted {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* on hover */\n",
|
||
"#sk-container-id-5 div.sk-estimator:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 div.sk-estimator.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
||
"\n",
|
||
"/* Common style for \"i\" and \"?\" */\n",
|
||
"\n",
|
||
".sk-estimator-doc-link,\n",
|
||
"a:link.sk-estimator-doc-link,\n",
|
||
"a:visited.sk-estimator-doc-link {\n",
|
||
" float: right;\n",
|
||
" font-size: smaller;\n",
|
||
" line-height: 1em;\n",
|
||
" font-family: monospace;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" border-radius: 1em;\n",
|
||
" height: 1em;\n",
|
||
" width: 1em;\n",
|
||
" text-decoration: none !important;\n",
|
||
" margin-left: 0.5em;\n",
|
||
" text-align: center;\n",
|
||
" /* unfitted */\n",
|
||
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-unfitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link.fitted,\n",
|
||
"a:link.sk-estimator-doc-link.fitted,\n",
|
||
"a:visited.sk-estimator-doc-link.fitted {\n",
|
||
" /* fitted */\n",
|
||
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-fitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover */\n",
|
||
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
||
".sk-estimator-doc-link:hover,\n",
|
||
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
||
".sk-estimator-doc-link:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
||
".sk-estimator-doc-link.fitted:hover,\n",
|
||
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
||
".sk-estimator-doc-link.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Span, style for the box shown on hovering the info icon */\n",
|
||
".sk-estimator-doc-link span {\n",
|
||
" display: none;\n",
|
||
" z-index: 9999;\n",
|
||
" position: relative;\n",
|
||
" font-weight: normal;\n",
|
||
" right: .2ex;\n",
|
||
" padding: .5ex;\n",
|
||
" margin: .5ex;\n",
|
||
" width: min-content;\n",
|
||
" min-width: 20ex;\n",
|
||
" max-width: 50ex;\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" box-shadow: 2pt 2pt 4pt #999;\n",
|
||
" /* unfitted */\n",
|
||
" background: var(--sklearn-color-unfitted-level-0);\n",
|
||
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link.fitted span {\n",
|
||
" /* fitted */\n",
|
||
" background: var(--sklearn-color-fitted-level-0);\n",
|
||
" border: var(--sklearn-color-fitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link:hover span {\n",
|
||
" display: block;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
||
"\n",
|
||
"#sk-container-id-5 a.estimator_doc_link {\n",
|
||
" float: right;\n",
|
||
" font-size: 1rem;\n",
|
||
" line-height: 1em;\n",
|
||
" font-family: monospace;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" border-radius: 1rem;\n",
|
||
" height: 1rem;\n",
|
||
" width: 1rem;\n",
|
||
" text-decoration: none;\n",
|
||
" /* unfitted */\n",
|
||
" color: var(--sklearn-color-unfitted-level-1);\n",
|
||
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 a.estimator_doc_link.fitted {\n",
|
||
" /* fitted */\n",
|
||
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-fitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover */\n",
|
||
"#sk-container-id-5 a.estimator_doc_link:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-5 a.estimator_doc_link.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table summary {\n",
|
||
" padding: .5rem;\n",
|
||
" font-family: monospace;\n",
|
||
" cursor: pointer;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table details[open] {\n",
|
||
" padding-left: 0.1rem;\n",
|
||
" padding-right: 0.1rem;\n",
|
||
" padding-bottom: 0.3rem;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table {\n",
|
||
" margin-left: auto !important;\n",
|
||
" margin-right: auto !important;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:nth-child(odd) {\n",
|
||
" background-color: #fff;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:nth-child(even) {\n",
|
||
" background-color: #f6f6f6;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:hover {\n",
|
||
" background-color: #e0e0e0;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table table td {\n",
|
||
" border: 1px solid rgba(106, 105, 104, 0.232);\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td {\n",
|
||
" color:rgb(255, 94, 0);\n",
|
||
" text-align: left;\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td.value pre {\n",
|
||
" color:rgb(255, 94, 0) !important;\n",
|
||
" background-color: transparent !important;\n",
|
||
"}\n",
|
||
"\n",
|
||
".default td {\n",
|
||
" color: black;\n",
|
||
" text-align: left;\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td i,\n",
|
||
".default td i {\n",
|
||
" color: black;\n",
|
||
"}\n",
|
||
"\n",
|
||
".copy-paste-icon {\n",
|
||
" background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTIwOCAwTDMzMi4xIDBjMTIuNyAwIDI0LjkgNS4xIDMzLjkgMTQuMWw2Ny45IDY3LjljOSA5IDE0LjEgMjEuMiAxNC4xIDMzLjlMNDQ4IDMzNmMwIDI2LjUtMjEuNSA0OC00OCA0OGwtMTkyIDBjLTI2LjUgMC00OC0yMS41LTQ4LTQ4bDAtMjg4YzAtMjYuNSAyMS41LTQ4IDQ4LTQ4ek00OCAxMjhsODAgMCAwIDY0LTY0IDAgMCAyNTYgMTkyIDAgMC0zMiA2NCAwIDAgNDhjMCAyNi41LTIxLjUgNDgtNDggNDhMNDggNTEyYy0yNi41IDAtNDgtMjEuNS00OC00OEwwIDE3NmMwLTI2LjUgMjEuNS00OCA0OC00OHoiLz48L3N2Zz4=);\n",
|
||
" background-repeat: no-repeat;\n",
|
||
" background-size: 14px 14px;\n",
|
||
" background-position: 0;\n",
|
||
" display: inline-block;\n",
|
||
" width: 14px;\n",
|
||
" height: 14px;\n",
|
||
" cursor: pointer;\n",
|
||
"}\n",
|
||
"</style><body><div id=\"sk-container-id-5\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>GaussianNB()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-5\" type=\"checkbox\" checked><label for=\"sk-estimator-id-5\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>GaussianNB</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.7/modules/generated/sklearn.naive_bayes.GaussianNB.html\">?<span>Documentation for GaussianNB</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\" data-param-prefix=\"\">\n",
|
||
" <div class=\"estimator-table\">\n",
|
||
" <details>\n",
|
||
" <summary>Parameters</summary>\n",
|
||
" <table class=\"parameters-table\">\n",
|
||
" <tbody>\n",
|
||
" \n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('priors',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">priors </td>\n",
|
||
" <td class=\"value\">None</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('var_smoothing',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">var_smoothing </td>\n",
|
||
" <td class=\"value\">1e-09</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
" </tbody>\n",
|
||
" </table>\n",
|
||
" </details>\n",
|
||
" </div>\n",
|
||
" </div></div></div></div></div><script>function copyToClipboard(text, element) {\n",
|
||
" // Get the parameter prefix from the closest toggleable content\n",
|
||
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
|
||
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
|
||
" const fullParamName = paramPrefix ? `${paramPrefix}${text}` : text;\n",
|
||
"\n",
|
||
" const originalStyle = element.style;\n",
|
||
" const computedStyle = window.getComputedStyle(element);\n",
|
||
" const originalWidth = computedStyle.width;\n",
|
||
" const originalHTML = element.innerHTML.replace('Copied!', '');\n",
|
||
"\n",
|
||
" navigator.clipboard.writeText(fullParamName)\n",
|
||
" .then(() => {\n",
|
||
" element.style.width = originalWidth;\n",
|
||
" element.style.color = 'green';\n",
|
||
" element.innerHTML = \"Copied!\";\n",
|
||
"\n",
|
||
" setTimeout(() => {\n",
|
||
" element.innerHTML = originalHTML;\n",
|
||
" element.style = originalStyle;\n",
|
||
" }, 2000);\n",
|
||
" })\n",
|
||
" .catch(err => {\n",
|
||
" console.error('Failed to copy:', err);\n",
|
||
" element.style.color = 'red';\n",
|
||
" element.innerHTML = \"Failed!\";\n",
|
||
" setTimeout(() => {\n",
|
||
" element.innerHTML = originalHTML;\n",
|
||
" element.style = originalStyle;\n",
|
||
" }, 2000);\n",
|
||
" });\n",
|
||
" return false;\n",
|
||
"}\n",
|
||
"\n",
|
||
"document.querySelectorAll('.fa-regular.fa-copy').forEach(function(element) {\n",
|
||
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
|
||
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
|
||
" const paramName = element.parentElement.nextElementSibling.textContent.trim();\n",
|
||
" const fullParamName = paramPrefix ? `${paramPrefix}${paramName}` : paramName;\n",
|
||
"\n",
|
||
" element.setAttribute('title', fullParamName);\n",
|
||
"});\n",
|
||
"</script></body>"
|
||
],
|
||
"text/plain": [
|
||
"GaussianNB()"
|
||
]
|
||
},
|
||
"execution_count": 15,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"from sklearn.naive_bayes import GaussianNB\n",
|
||
"\n",
|
||
"model = GaussianNB()\n",
|
||
"\n",
|
||
"model.fit(X_train, y_train)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 16,
|
||
"metadata": {
|
||
"id": "amg6aqULlovg"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Точность модели: 0.8100\n",
|
||
"[[90 10 0 0]\n",
|
||
" [ 7 69 24 0]\n",
|
||
" [ 0 18 73 9]\n",
|
||
" [ 0 0 8 92]]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"y_pred = model.predict(X_test)\n",
|
||
"\n",
|
||
"accuracy = accuracy_score(y_test, y_pred)\n",
|
||
"print(f\"Точность модели: {accuracy:.4f}\")\n",
|
||
"\n",
|
||
"print(confusion_matrix(y_test, y_pred))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"id": "RYFhErkHlmFV"
|
||
},
|
||
"source": [
|
||
"### Задание 4\n",
|
||
"\n",
|
||
"Реализуйте алгоритм kNN."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 17,
|
||
"metadata": {
|
||
"id": "fUQ70y9Plq9u"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<style>#sk-container-id-6 {\n",
|
||
" /* Definition of color scheme common for light and dark mode */\n",
|
||
" --sklearn-color-text: #000;\n",
|
||
" --sklearn-color-text-muted: #666;\n",
|
||
" --sklearn-color-line: gray;\n",
|
||
" /* Definition of color scheme for unfitted estimators */\n",
|
||
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
||
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
||
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
||
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
||
" /* Definition of color scheme for fitted estimators */\n",
|
||
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
||
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
||
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
||
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
||
"\n",
|
||
" /* Specific color for light theme */\n",
|
||
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
||
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
||
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
||
" --sklearn-color-icon: #696969;\n",
|
||
"\n",
|
||
" @media (prefers-color-scheme: dark) {\n",
|
||
" /* Redefinition of color scheme for dark theme */\n",
|
||
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
||
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
||
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
||
" --sklearn-color-icon: #878787;\n",
|
||
" }\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 pre {\n",
|
||
" padding: 0;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 input.sk-hidden--visually {\n",
|
||
" border: 0;\n",
|
||
" clip: rect(1px 1px 1px 1px);\n",
|
||
" clip: rect(1px, 1px, 1px, 1px);\n",
|
||
" height: 1px;\n",
|
||
" margin: -1px;\n",
|
||
" overflow: hidden;\n",
|
||
" padding: 0;\n",
|
||
" position: absolute;\n",
|
||
" width: 1px;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-dashed-wrapped {\n",
|
||
" border: 1px dashed var(--sklearn-color-line);\n",
|
||
" margin: 0 0.4em 0.5em 0.4em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" padding-bottom: 0.4em;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-container {\n",
|
||
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
||
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
||
" so we also need the `!important` here to be able to override the\n",
|
||
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
||
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
||
" display: inline-block !important;\n",
|
||
" position: relative;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-text-repr-fallback {\n",
|
||
" display: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"div.sk-parallel-item,\n",
|
||
"div.sk-serial,\n",
|
||
"div.sk-item {\n",
|
||
" /* draw centered vertical line to link estimators */\n",
|
||
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
||
" background-size: 2px 100%;\n",
|
||
" background-repeat: no-repeat;\n",
|
||
" background-position: center center;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Parallel-specific style estimator block */\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-parallel-item::after {\n",
|
||
" content: \"\";\n",
|
||
" width: 100%;\n",
|
||
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
||
" flex-grow: 1;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-parallel {\n",
|
||
" display: flex;\n",
|
||
" align-items: stretch;\n",
|
||
" justify-content: center;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" position: relative;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-parallel-item {\n",
|
||
" display: flex;\n",
|
||
" flex-direction: column;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-parallel-item:first-child::after {\n",
|
||
" align-self: flex-end;\n",
|
||
" width: 50%;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-parallel-item:last-child::after {\n",
|
||
" align-self: flex-start;\n",
|
||
" width: 50%;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-parallel-item:only-child::after {\n",
|
||
" width: 0;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Serial-specific style estimator block */\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-serial {\n",
|
||
" display: flex;\n",
|
||
" flex-direction: column;\n",
|
||
" align-items: center;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" padding-right: 1em;\n",
|
||
" padding-left: 1em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"\n",
|
||
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
||
"clickable and can be expanded/collapsed.\n",
|
||
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
||
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
||
"*/\n",
|
||
"\n",
|
||
"/* Pipeline and ColumnTransformer style (default) */\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-toggleable {\n",
|
||
" /* Default theme specific background. It is overwritten whether we have a\n",
|
||
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Toggleable label */\n",
|
||
"#sk-container-id-6 label.sk-toggleable__label {\n",
|
||
" cursor: pointer;\n",
|
||
" display: flex;\n",
|
||
" width: 100%;\n",
|
||
" margin-bottom: 0;\n",
|
||
" padding: 0.5em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" text-align: center;\n",
|
||
" align-items: start;\n",
|
||
" justify-content: space-between;\n",
|
||
" gap: 0.5em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 label.sk-toggleable__label .caption {\n",
|
||
" font-size: 0.6rem;\n",
|
||
" font-weight: lighter;\n",
|
||
" color: var(--sklearn-color-text-muted);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 label.sk-toggleable__label-arrow:before {\n",
|
||
" /* Arrow on the left of the label */\n",
|
||
" content: \"▸\";\n",
|
||
" float: left;\n",
|
||
" margin-right: 0.25em;\n",
|
||
" color: var(--sklearn-color-icon);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 label.sk-toggleable__label-arrow:hover:before {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Toggleable content - dropdown */\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-toggleable__content {\n",
|
||
" display: none;\n",
|
||
" text-align: left;\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-toggleable__content.fitted {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-toggleable__content pre {\n",
|
||
" margin: 0.2em;\n",
|
||
" border-radius: 0.25em;\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-toggleable__content.fitted pre {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
||
" /* Expand drop-down */\n",
|
||
" display: block;\n",
|
||
" width: 100%;\n",
|
||
" overflow: visible;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
||
" content: \"▾\";\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Pipeline/ColumnTransformer-specific style */\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator-specific style */\n",
|
||
"\n",
|
||
"/* Colorize estimator box */\n",
|
||
"#sk-container-id-6 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-label label.sk-toggleable__label,\n",
|
||
"#sk-container-id-6 div.sk-label label {\n",
|
||
" /* The background is the default theme color */\n",
|
||
" color: var(--sklearn-color-text-on-default-background);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover, darken the color of the background */\n",
|
||
"#sk-container-id-6 div.sk-label:hover label.sk-toggleable__label {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Label box, darken color on hover, fitted */\n",
|
||
"#sk-container-id-6 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator label */\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-label label {\n",
|
||
" font-family: monospace;\n",
|
||
" font-weight: bold;\n",
|
||
" display: inline-block;\n",
|
||
" line-height: 1.2em;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-label-container {\n",
|
||
" text-align: center;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Estimator-specific */\n",
|
||
"#sk-container-id-6 div.sk-estimator {\n",
|
||
" font-family: monospace;\n",
|
||
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
||
" border-radius: 0.25em;\n",
|
||
" box-sizing: border-box;\n",
|
||
" margin-bottom: 0.5em;\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-estimator.fitted {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* on hover */\n",
|
||
"#sk-container-id-6 div.sk-estimator:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 div.sk-estimator.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
||
"\n",
|
||
"/* Common style for \"i\" and \"?\" */\n",
|
||
"\n",
|
||
".sk-estimator-doc-link,\n",
|
||
"a:link.sk-estimator-doc-link,\n",
|
||
"a:visited.sk-estimator-doc-link {\n",
|
||
" float: right;\n",
|
||
" font-size: smaller;\n",
|
||
" line-height: 1em;\n",
|
||
" font-family: monospace;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" border-radius: 1em;\n",
|
||
" height: 1em;\n",
|
||
" width: 1em;\n",
|
||
" text-decoration: none !important;\n",
|
||
" margin-left: 0.5em;\n",
|
||
" text-align: center;\n",
|
||
" /* unfitted */\n",
|
||
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-unfitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link.fitted,\n",
|
||
"a:link.sk-estimator-doc-link.fitted,\n",
|
||
"a:visited.sk-estimator-doc-link.fitted {\n",
|
||
" /* fitted */\n",
|
||
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-fitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover */\n",
|
||
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
||
".sk-estimator-doc-link:hover,\n",
|
||
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
||
".sk-estimator-doc-link:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
||
".sk-estimator-doc-link.fitted:hover,\n",
|
||
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
||
".sk-estimator-doc-link.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* Span, style for the box shown on hovering the info icon */\n",
|
||
".sk-estimator-doc-link span {\n",
|
||
" display: none;\n",
|
||
" z-index: 9999;\n",
|
||
" position: relative;\n",
|
||
" font-weight: normal;\n",
|
||
" right: .2ex;\n",
|
||
" padding: .5ex;\n",
|
||
" margin: .5ex;\n",
|
||
" width: min-content;\n",
|
||
" min-width: 20ex;\n",
|
||
" max-width: 50ex;\n",
|
||
" color: var(--sklearn-color-text);\n",
|
||
" box-shadow: 2pt 2pt 4pt #999;\n",
|
||
" /* unfitted */\n",
|
||
" background: var(--sklearn-color-unfitted-level-0);\n",
|
||
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link.fitted span {\n",
|
||
" /* fitted */\n",
|
||
" background: var(--sklearn-color-fitted-level-0);\n",
|
||
" border: var(--sklearn-color-fitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".sk-estimator-doc-link:hover span {\n",
|
||
" display: block;\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
||
"\n",
|
||
"#sk-container-id-6 a.estimator_doc_link {\n",
|
||
" float: right;\n",
|
||
" font-size: 1rem;\n",
|
||
" line-height: 1em;\n",
|
||
" font-family: monospace;\n",
|
||
" background-color: var(--sklearn-color-background);\n",
|
||
" border-radius: 1rem;\n",
|
||
" height: 1rem;\n",
|
||
" width: 1rem;\n",
|
||
" text-decoration: none;\n",
|
||
" /* unfitted */\n",
|
||
" color: var(--sklearn-color-unfitted-level-1);\n",
|
||
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 a.estimator_doc_link.fitted {\n",
|
||
" /* fitted */\n",
|
||
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
||
" color: var(--sklearn-color-fitted-level-1);\n",
|
||
"}\n",
|
||
"\n",
|
||
"/* On hover */\n",
|
||
"#sk-container-id-6 a.estimator_doc_link:hover {\n",
|
||
" /* unfitted */\n",
|
||
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
||
" color: var(--sklearn-color-background);\n",
|
||
" text-decoration: none;\n",
|
||
"}\n",
|
||
"\n",
|
||
"#sk-container-id-6 a.estimator_doc_link.fitted:hover {\n",
|
||
" /* fitted */\n",
|
||
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table summary {\n",
|
||
" padding: .5rem;\n",
|
||
" font-family: monospace;\n",
|
||
" cursor: pointer;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table details[open] {\n",
|
||
" padding-left: 0.1rem;\n",
|
||
" padding-right: 0.1rem;\n",
|
||
" padding-bottom: 0.3rem;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table {\n",
|
||
" margin-left: auto !important;\n",
|
||
" margin-right: auto !important;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:nth-child(odd) {\n",
|
||
" background-color: #fff;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:nth-child(even) {\n",
|
||
" background-color: #f6f6f6;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table .parameters-table tr:hover {\n",
|
||
" background-color: #e0e0e0;\n",
|
||
"}\n",
|
||
"\n",
|
||
".estimator-table table td {\n",
|
||
" border: 1px solid rgba(106, 105, 104, 0.232);\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td {\n",
|
||
" color:rgb(255, 94, 0);\n",
|
||
" text-align: left;\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td.value pre {\n",
|
||
" color:rgb(255, 94, 0) !important;\n",
|
||
" background-color: transparent !important;\n",
|
||
"}\n",
|
||
"\n",
|
||
".default td {\n",
|
||
" color: black;\n",
|
||
" text-align: left;\n",
|
||
"}\n",
|
||
"\n",
|
||
".user-set td i,\n",
|
||
".default td i {\n",
|
||
" color: black;\n",
|
||
"}\n",
|
||
"\n",
|
||
".copy-paste-icon {\n",
|
||
" background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTIwOCAwTDMzMi4xIDBjMTIuNyAwIDI0LjkgNS4xIDMzLjkgMTQuMWw2Ny45IDY3LjljOSA5IDE0LjEgMjEuMiAxNC4xIDMzLjlMNDQ4IDMzNmMwIDI2LjUtMjEuNSA0OC00OCA0OGwtMTkyIDBjLTI2LjUgMC00OC0yMS41LTQ4LTQ4bDAtMjg4YzAtMjYuNSAyMS41LTQ4IDQ4LTQ4ek00OCAxMjhsODAgMCAwIDY0LTY0IDAgMCAyNTYgMTkyIDAgMC0zMiA2NCAwIDAgNDhjMCAyNi41LTIxLjUgNDgtNDggNDhMNDggNTEyYy0yNi41IDAtNDgtMjEuNS00OC00OEwwIDE3NmMwLTI2LjUgMjEuNS00OCA0OC00OHoiLz48L3N2Zz4=);\n",
|
||
" background-repeat: no-repeat;\n",
|
||
" background-size: 14px 14px;\n",
|
||
" background-position: 0;\n",
|
||
" display: inline-block;\n",
|
||
" width: 14px;\n",
|
||
" height: 14px;\n",
|
||
" cursor: pointer;\n",
|
||
"}\n",
|
||
"</style><body><div id=\"sk-container-id-6\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>KNeighborsClassifier(n_neighbors=16)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-6\" type=\"checkbox\" checked><label for=\"sk-estimator-id-6\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>KNeighborsClassifier</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.7/modules/generated/sklearn.neighbors.KNeighborsClassifier.html\">?<span>Documentation for KNeighborsClassifier</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\" data-param-prefix=\"\">\n",
|
||
" <div class=\"estimator-table\">\n",
|
||
" <details>\n",
|
||
" <summary>Parameters</summary>\n",
|
||
" <table class=\"parameters-table\">\n",
|
||
" <tbody>\n",
|
||
" \n",
|
||
" <tr class=\"user-set\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('n_neighbors',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">n_neighbors </td>\n",
|
||
" <td class=\"value\">16</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('weights',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">weights </td>\n",
|
||
" <td class=\"value\">'uniform'</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('algorithm',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">algorithm </td>\n",
|
||
" <td class=\"value\">'auto'</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('leaf_size',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">leaf_size </td>\n",
|
||
" <td class=\"value\">30</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('p',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">p </td>\n",
|
||
" <td class=\"value\">2</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('metric',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">metric </td>\n",
|
||
" <td class=\"value\">'minkowski'</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('metric_params',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">metric_params </td>\n",
|
||
" <td class=\"value\">None</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
"\n",
|
||
" <tr class=\"default\">\n",
|
||
" <td><i class=\"copy-paste-icon\"\n",
|
||
" onclick=\"copyToClipboard('n_jobs',\n",
|
||
" this.parentElement.nextElementSibling)\"\n",
|
||
" ></i></td>\n",
|
||
" <td class=\"param\">n_jobs </td>\n",
|
||
" <td class=\"value\">None</td>\n",
|
||
" </tr>\n",
|
||
" \n",
|
||
" </tbody>\n",
|
||
" </table>\n",
|
||
" </details>\n",
|
||
" </div>\n",
|
||
" </div></div></div></div></div><script>function copyToClipboard(text, element) {\n",
|
||
" // Get the parameter prefix from the closest toggleable content\n",
|
||
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
|
||
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
|
||
" const fullParamName = paramPrefix ? `${paramPrefix}${text}` : text;\n",
|
||
"\n",
|
||
" const originalStyle = element.style;\n",
|
||
" const computedStyle = window.getComputedStyle(element);\n",
|
||
" const originalWidth = computedStyle.width;\n",
|
||
" const originalHTML = element.innerHTML.replace('Copied!', '');\n",
|
||
"\n",
|
||
" navigator.clipboard.writeText(fullParamName)\n",
|
||
" .then(() => {\n",
|
||
" element.style.width = originalWidth;\n",
|
||
" element.style.color = 'green';\n",
|
||
" element.innerHTML = \"Copied!\";\n",
|
||
"\n",
|
||
" setTimeout(() => {\n",
|
||
" element.innerHTML = originalHTML;\n",
|
||
" element.style = originalStyle;\n",
|
||
" }, 2000);\n",
|
||
" })\n",
|
||
" .catch(err => {\n",
|
||
" console.error('Failed to copy:', err);\n",
|
||
" element.style.color = 'red';\n",
|
||
" element.innerHTML = \"Failed!\";\n",
|
||
" setTimeout(() => {\n",
|
||
" element.innerHTML = originalHTML;\n",
|
||
" element.style = originalStyle;\n",
|
||
" }, 2000);\n",
|
||
" });\n",
|
||
" return false;\n",
|
||
"}\n",
|
||
"\n",
|
||
"document.querySelectorAll('.fa-regular.fa-copy').forEach(function(element) {\n",
|
||
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
|
||
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
|
||
" const paramName = element.parentElement.nextElementSibling.textContent.trim();\n",
|
||
" const fullParamName = paramPrefix ? `${paramPrefix}${paramName}` : paramName;\n",
|
||
"\n",
|
||
" element.setAttribute('title', fullParamName);\n",
|
||
"});\n",
|
||
"</script></body>"
|
||
],
|
||
"text/plain": [
|
||
"KNeighborsClassifier(n_neighbors=16)"
|
||
]
|
||
},
|
||
"execution_count": 17,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"from sklearn.neighbors import KNeighborsClassifier\n",
|
||
"\n",
|
||
"knn = KNeighborsClassifier(n_neighbors=16)\n",
|
||
"knn.fit(X_train_scaled, y_train)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 18,
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Accuracy: 0.56\n",
|
||
"[[72 28 0 0]\n",
|
||
" [31 44 25 0]\n",
|
||
" [ 5 27 47 21]\n",
|
||
" [ 0 5 34 61]]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"y_pred = knn.predict(X_test_scaled)\n",
|
||
"\n",
|
||
"print(\"Accuracy:\", accuracy_score(y_test, y_pred))\n",
|
||
"print(confusion_matrix(y_test, y_pred))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"id": "ssFzfn1Pl4AI"
|
||
},
|
||
"source": [
|
||
"### Задание 5\n",
|
||
"\n",
|
||
"Сделайте выводы о результатах обучения."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"Логистическая регрессия хорошо подходит для линейно разделимых данных, что, вероятно, имело место в данном случае. Наивный Байес хуже справился с задачей из-за нарушения предположения о независимости признаков. Например, такие параметры, как оперативная память и размер экрана, могут быть коррелированы, что снижает качество прогноза. Метод KNN, вероятно, не подходит для данной задачи из-за большой разности в корреляции цены в зависимости от параметра."
|
||
]
|
||
}
|
||
],
|
||
"metadata": {
|
||
"colab": {
|
||
"provenance": []
|
||
},
|
||
"kernelspec": {
|
||
"display_name": "Python 3",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.12.6"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 0
|
||
}
|