regresja liniowa

This commit is contained in:
Marcin Szczepański 2023-10-18 14:40:08 +02:00
parent f192e3fb2c
commit b52b84a378
2 changed files with 322 additions and 18 deletions

View File

@ -409,7 +409,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36, "execution_count": 51,
"id": "f7eade7c-def7-4944-8eea-7cba985e5bf5", "id": "f7eade7c-def7-4944-8eea-7cba985e5bf5",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -447,7 +447,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": 52,
"id": "2b232e81-9d0e-4817-ac0a-5f7b1d293666", "id": "2b232e81-9d0e-4817-ac0a-5f7b1d293666",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -493,19 +493,172 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 53,
"id": "e539d645-86c6-42c0-9059-7a3c310cc2a3", "id": "e539d645-86c6-42c0-9059-7a3c310cc2a3",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "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>cwiczenia</th>\n",
" <th>czas_min</th>\n",
" <th>wejscia</th>\n",
" <th>nieodwiedzone</th>\n",
" <th>czas_do_testu_godziny</th>\n",
" <th>test</th>\n",
" <th>y_pred</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td>12</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>20</td>\n",
" <td>20.00</td>\n",
" <td>26.151158</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>8</td>\n",
" <td>25</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>36</td>\n",
" <td>60.00</td>\n",
" <td>49.047952</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>14</td>\n",
" <td>48</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>33</td>\n",
" <td>92.86</td>\n",
" <td>86.549335</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>11</td>\n",
" <td>37</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>42</td>\n",
" <td>65.34</td>\n",
" <td>68.249528</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>29</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>22</td>\n",
" <td>42.35</td>\n",
" <td>44.274682</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>13.14</td>\n",
" <td>14.251876</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>16</td>\n",
" <td>36</td>\n",
" <td>7</td>\n",
" <td>1</td>\n",
" <td>47</td>\n",
" <td>85.13</td>\n",
" <td>81.315003</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>18</td>\n",
" <td>55</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>39</td>\n",
" <td>98.33</td>\n",
" <td>104.035514</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>20</td>\n",
" <td>48</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>45</td>\n",
" <td>100.00</td>\n",
" <td>103.310027</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>10</td>\n",
" <td>42</td>\n",
" <td>7</td>\n",
" <td>1</td>\n",
" <td>37</td>\n",
" <td>70.00</td>\n",
" <td>69.964925</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [ "text/plain": [
"array([ 26.15115779, 49.04795183, 86.54933494, 68.24952796,\n", " cwiczenia czas_min wejscia nieodwiedzone czas_do_testu_godziny test \\\n",
" 44.27468217, 14.25187619, 81.31500261, 104.03551406,\n", "0 4 12 1 1 20 20.00 \n",
" 103.31002749, 69.96492497])" "1 8 25 3 3 36 60.00 \n",
"2 14 48 3 1 33 92.86 \n",
"3 11 37 5 0 42 65.34 \n",
"4 5 29 2 0 22 42.35 \n",
"5 2 5 1 4 5 13.14 \n",
"6 16 36 7 1 47 85.13 \n",
"7 18 55 5 0 39 98.33 \n",
"8 20 48 4 0 45 100.00 \n",
"9 10 42 7 1 37 70.00 \n",
"\n",
" y_pred \n",
"0 26.151158 \n",
"1 49.047952 \n",
"2 86.549335 \n",
"3 68.249528 \n",
"4 44.274682 \n",
"5 14.251876 \n",
"6 81.315003 \n",
"7 104.035514 \n",
"8 103.310027 \n",
"9 69.964925 "
] ]
}, },
"execution_count": 49, "execution_count": 53,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -513,8 +666,7 @@
"source": [ "source": [
"data_with_y_pred = data.copy()\n", "data_with_y_pred = data.copy()\n",
"data_with_y_pred['y_pred'] = y_pred\n", "data_with_y_pred['y_pred'] = y_pred\n",
"data_with_y_pred\n", "data_with_y_pred"
"y_pred"
] ]
}, },
{ {

View File

@ -409,7 +409,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36, "execution_count": 51,
"id": "f7eade7c-def7-4944-8eea-7cba985e5bf5", "id": "f7eade7c-def7-4944-8eea-7cba985e5bf5",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -447,7 +447,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": 52,
"id": "2b232e81-9d0e-4817-ac0a-5f7b1d293666", "id": "2b232e81-9d0e-4817-ac0a-5f7b1d293666",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -493,19 +493,172 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 49, "execution_count": 53,
"id": "e539d645-86c6-42c0-9059-7a3c310cc2a3", "id": "e539d645-86c6-42c0-9059-7a3c310cc2a3",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "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>cwiczenia</th>\n",
" <th>czas_min</th>\n",
" <th>wejscia</th>\n",
" <th>nieodwiedzone</th>\n",
" <th>czas_do_testu_godziny</th>\n",
" <th>test</th>\n",
" <th>y_pred</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td>12</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>20</td>\n",
" <td>20.00</td>\n",
" <td>26.151158</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>8</td>\n",
" <td>25</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>36</td>\n",
" <td>60.00</td>\n",
" <td>49.047952</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>14</td>\n",
" <td>48</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>33</td>\n",
" <td>92.86</td>\n",
" <td>86.549335</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>11</td>\n",
" <td>37</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>42</td>\n",
" <td>65.34</td>\n",
" <td>68.249528</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>29</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>22</td>\n",
" <td>42.35</td>\n",
" <td>44.274682</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>13.14</td>\n",
" <td>14.251876</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>16</td>\n",
" <td>36</td>\n",
" <td>7</td>\n",
" <td>1</td>\n",
" <td>47</td>\n",
" <td>85.13</td>\n",
" <td>81.315003</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>18</td>\n",
" <td>55</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>39</td>\n",
" <td>98.33</td>\n",
" <td>104.035514</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>20</td>\n",
" <td>48</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>45</td>\n",
" <td>100.00</td>\n",
" <td>103.310027</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>10</td>\n",
" <td>42</td>\n",
" <td>7</td>\n",
" <td>1</td>\n",
" <td>37</td>\n",
" <td>70.00</td>\n",
" <td>69.964925</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [ "text/plain": [
"array([ 26.15115779, 49.04795183, 86.54933494, 68.24952796,\n", " cwiczenia czas_min wejscia nieodwiedzone czas_do_testu_godziny test \\\n",
" 44.27468217, 14.25187619, 81.31500261, 104.03551406,\n", "0 4 12 1 1 20 20.00 \n",
" 103.31002749, 69.96492497])" "1 8 25 3 3 36 60.00 \n",
"2 14 48 3 1 33 92.86 \n",
"3 11 37 5 0 42 65.34 \n",
"4 5 29 2 0 22 42.35 \n",
"5 2 5 1 4 5 13.14 \n",
"6 16 36 7 1 47 85.13 \n",
"7 18 55 5 0 39 98.33 \n",
"8 20 48 4 0 45 100.00 \n",
"9 10 42 7 1 37 70.00 \n",
"\n",
" y_pred \n",
"0 26.151158 \n",
"1 49.047952 \n",
"2 86.549335 \n",
"3 68.249528 \n",
"4 44.274682 \n",
"5 14.251876 \n",
"6 81.315003 \n",
"7 104.035514 \n",
"8 103.310027 \n",
"9 69.964925 "
] ]
}, },
"execution_count": 49, "execution_count": 53,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -513,8 +666,7 @@
"source": [ "source": [
"data_with_y_pred = data.copy()\n", "data_with_y_pred = data.copy()\n",
"data_with_y_pred['y_pred'] = y_pred\n", "data_with_y_pred['y_pred'] = y_pred\n",
"data_with_y_pred\n", "data_with_y_pred"
"y_pred"
] ]
}, },
{ {