forked from filipg/aitech-eks-pub
1070 lines
120 KiB
Plaintext
1070 lines
120 KiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Regresja liniowa"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## import bibliotek"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 1,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"from pathlib import Path\n",
|
|||
|
"import seaborn as sns\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"from sklearn.linear_model import LinearRegression\n",
|
|||
|
"plt.rcParams['figure.figsize'] = [10, 5]"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zbiór \n",
|
|||
|
"\n",
|
|||
|
"https://git.wmi.amu.edu.pl/kubapok/mieszkania2-below1m-public"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## ładowanie zbioru train"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 2,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"DATA_DIR = Path('/home/kuba/Syncthing/przedmioty/2020-02/ISI/zajecia7_regresja_liniowa/mieszkania2')"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 3,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"with open(DATA_DIR / 'names') as f_names:\n",
|
|||
|
" names = f_names.read().rstrip('\\n').split('\\t')"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 4,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"mieszkania_train = pd.read_csv(DATA_DIR/'train/in.tsv', sep ='\\t', names=names)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 5,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>isNew</th>\n",
|
|||
|
" <th>rooms</th>\n",
|
|||
|
" <th>floor</th>\n",
|
|||
|
" <th>location</th>\n",
|
|||
|
" <th>sqrMetres</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>1</td>\n",
|
|||
|
" <td>Centrum</td>\n",
|
|||
|
" <td>78</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>2</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>62</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>15</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>4</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>14</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>15</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" isNew rooms floor location sqrMetres\n",
|
|||
|
"0 False 3 1 Centrum 78\n",
|
|||
|
"1 False 3 2 Sołacz 62\n",
|
|||
|
"2 False 3 0 Sołacz 15\n",
|
|||
|
"3 False 4 0 Sołacz 14\n",
|
|||
|
"4 False 3 0 Sołacz 15"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 5,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"mieszkania_train.head()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 6,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"with open(DATA_DIR/'train'/'expected.tsv','r') as train_exp_f:\n",
|
|||
|
" Y_train = np.array([float(x.rstrip('\\n')) for x in train_exp_f.readlines()])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 7,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"array([476118., 459531., 411557., ..., 320000., 364000., 209000.])"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 7,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"Y_train"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 8,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"mieszkania_train['price'] = Y_train"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 9,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"X_train = mieszkania_train['sqrMetres'].to_numpy()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Wizualizacja danych"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 10,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/html": [
|
|||
|
"<div>\n",
|
|||
|
"<style scoped>\n",
|
|||
|
" .dataframe tbody tr th:only-of-type {\n",
|
|||
|
" vertical-align: middle;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe tbody tr th {\n",
|
|||
|
" vertical-align: top;\n",
|
|||
|
" }\n",
|
|||
|
"\n",
|
|||
|
" .dataframe thead th {\n",
|
|||
|
" text-align: right;\n",
|
|||
|
" }\n",
|
|||
|
"</style>\n",
|
|||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|||
|
" <thead>\n",
|
|||
|
" <tr style=\"text-align: right;\">\n",
|
|||
|
" <th></th>\n",
|
|||
|
" <th>isNew</th>\n",
|
|||
|
" <th>rooms</th>\n",
|
|||
|
" <th>floor</th>\n",
|
|||
|
" <th>location</th>\n",
|
|||
|
" <th>sqrMetres</th>\n",
|
|||
|
" <th>price</th>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </thead>\n",
|
|||
|
" <tbody>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>0</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>1</td>\n",
|
|||
|
" <td>Centrum</td>\n",
|
|||
|
" <td>78</td>\n",
|
|||
|
" <td>476118.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>2</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>62</td>\n",
|
|||
|
" <td>459531.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>2</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>15</td>\n",
|
|||
|
" <td>411557.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>3</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>4</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>14</td>\n",
|
|||
|
" <td>496416.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>4</th>\n",
|
|||
|
" <td>False</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Sołacz</td>\n",
|
|||
|
" <td>15</td>\n",
|
|||
|
" <td>406032.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>...</th>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" <td>...</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1652</th>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" <td>2</td>\n",
|
|||
|
" <td>0</td>\n",
|
|||
|
" <td>Grunwald</td>\n",
|
|||
|
" <td>51</td>\n",
|
|||
|
" <td>299000.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1653</th>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" <td>2</td>\n",
|
|||
|
" <td>2</td>\n",
|
|||
|
" <td>Centrum</td>\n",
|
|||
|
" <td>53</td>\n",
|
|||
|
" <td>339000.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1654</th>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>4</td>\n",
|
|||
|
" <td>Stare</td>\n",
|
|||
|
" <td>65</td>\n",
|
|||
|
" <td>320000.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1655</th>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>1</td>\n",
|
|||
|
" <td>Nowe</td>\n",
|
|||
|
" <td>67</td>\n",
|
|||
|
" <td>364000.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" <tr>\n",
|
|||
|
" <th>1656</th>\n",
|
|||
|
" <td>True</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>3</td>\n",
|
|||
|
" <td>Grunwald</td>\n",
|
|||
|
" <td>50</td>\n",
|
|||
|
" <td>209000.0</td>\n",
|
|||
|
" </tr>\n",
|
|||
|
" </tbody>\n",
|
|||
|
"</table>\n",
|
|||
|
"<p>1657 rows × 6 columns</p>\n",
|
|||
|
"</div>"
|
|||
|
],
|
|||
|
"text/plain": [
|
|||
|
" isNew rooms floor location sqrMetres price\n",
|
|||
|
"0 False 3 1 Centrum 78 476118.0\n",
|
|||
|
"1 False 3 2 Sołacz 62 459531.0\n",
|
|||
|
"2 False 3 0 Sołacz 15 411557.0\n",
|
|||
|
"3 False 4 0 Sołacz 14 496416.0\n",
|
|||
|
"4 False 3 0 Sołacz 15 406032.0\n",
|
|||
|
"... ... ... ... ... ... ...\n",
|
|||
|
"1652 True 2 0 Grunwald 51 299000.0\n",
|
|||
|
"1653 True 2 2 Centrum 53 339000.0\n",
|
|||
|
"1654 True 3 4 Stare 65 320000.0\n",
|
|||
|
"1655 True 3 1 Nowe 67 364000.0\n",
|
|||
|
"1656 True 3 3 Grunwald 50 209000.0\n",
|
|||
|
"\n",
|
|||
|
"[1657 rows x 6 columns]"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 10,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"mieszkania_train"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 11,
|
|||
|
"metadata": {
|
|||
|
"scrolled": false
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<AxesSubplot:xlabel='sqrMetres', ylabel='price'>"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 11,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmEAAAFICAYAAAAYvikoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABIGUlEQVR4nO3dfZgU1Z0v8O9vhgEHGBx0cBAGYXgbeVExTDRIUEjAl4UrZpV7TbJiNMZr2M1Fs3qjCxezLCTZNc+Kuxvi4xKMxGRNMAoGNCouriyicYjI2zgMOiDDywDCwACDjMy5f1R3c7q6q6a6pqqruuv7eR6eYrqrq0+d6un6zXn5HVFKgYiIiIiyqyDoAhARERFFEYMwIiIiogAwCCMiIiIKAIMwIiIiogAwCCMiIiIKAIMwIiIiogDkZBAmIktF5KCIbHW4//8Uke0isk1EfuN3+YiIiIg6IrmYJ0xErgVwAsAypdToDvYdBuB3AL6ilDoqIhcppQ5mo5xEREREVnKyJUwp9RaAI/pjIjJERP4oIhtFZJ2IXBp76jsAfqaUOhp7LQMwIiIiClxOBmEWngLwPaXUWAAPAlgce3w4gOEisl5E3hGRGwMrIREREVFMl6AL4AUR6QngGgDLRST+cLfYtguAYQAmAqgAsE5ERiulmrNcTCIiIqKEvAjCYLToNSulxqR5rhHAO0qpNgANIlIHIyh7L4vlIyIiIkqSF92RSqnjMAKsGQAghitiT68AMCn2eBmM7smPgygnERERUVxOBmEi8h8ANgCoEpFGEfk2gG8C+LaIfABgG4Dpsd1fBfCpiGwHsBbAQ0qpT4MoNxEREVFcTqaoICIiIsp1OdkSRkRERJTrGIQRERERBSDnZkeWlZWpQYMGBV0MIiIiog5t3LjxsFKqT7rnci4IGzRoEGpqaoIuBhEREVGHRGS31XPsjiQiIiIKAIMwIiIiogAwCCMiIiIKAIMwIiIiogAwCCMiIiIKAIMwIiIiogD4FoS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fGmx+/UMPNj+tTWdYD86ePzvlp/vyjJhisd0qHsyMp9OI3vzCJf6ECCF3ZiNfHDmfLBYP1TukwCCNygV+o4cbrYy2Mf9REAeud0mGKCiIiIiKfMEUFERERUcgwCAsQB3cTERFFF4OwAHG2DBERUXRxYH6AOHiYKHc0HD6Jp9c34K7xlTmfpoKIwoEtYQHKl7xDRFHQ2ZZrDj8gIjMGYUSUd/wIeDqbNNjv4Qfr6g/hhsffwrr6Q74cn4i8xyCMiPKOHwGP3nLtJsjze+WHBatqUdfUggWran05PhF5j0EY5Q22BFCc3wGPmyDP7+EHc6eNQFV5CeZOG+HL8YnIe0zWSnnjhsffQl1TC6rKS/DqA9cGXRzKYxykT0ROMVkrRUIutwQEOWibA8Yz19muSSIigEEY5ZEJw/rg1QeuxYRhfYIuSsaCzBln9d4MLpxhvj8icotBWIC8uMnxRpkfzGOYsnldrcZPMbhwxu/xZ9nE7xOi7GKy1gDFb3IAMH/66MCOQcGLd2/FZfO6mt87jsmEnbGqv1zE7xOi7GIQFiAvbnK8UeanMFzXfAouyJkwfO6IooSzI4mIiIh8wtmRRERERCHDIIyIiIgoAAzCiChncPYeEeUTBmFElDOYNoOI8glnRxJRzuDsPSLKJ2wJI6Kc4fci2PmC3ba5hdcruhiEEYXQuvpDuOHxt7Cu/lDQRaEcxG7b3MLrFV0Mwog05uAnqL9QF6yqRV1TCxasqs3q+9I5YWydcFqmfFpKKQp4vaKLQRiRxhz8BPUX6txpI1BVXoK500Zk9X3DKKhgKIytE07L5HW3bRgD0nzCbvbo4sB8Is3caSOwYFVtIvgJaiB4Re/uuHrwBajo3T2r7xtGQa1nGMZJAEGViWtKEvmDyxZRJDQ
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 720x360 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"needs_background": "light"
|
|||
|
},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"sns.scatterplot(x='sqrMetres',y='price', data = mieszkania_train, linewidth = 0, s = 5)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"### Pytanie- Jaki jest baseline naszego systemu?"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Czym jest regresja liniowa?- przypadek jednowymiarowym\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/1.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/2.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/3.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/4.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## wzór na regresję w przypadku jednowymiarowym?\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"$Y = a*X_1 + b$\n",
|
|||
|
"\n",
|
|||
|
"$Y = w_1 * X_1 + w_0$"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zadanie - napisać funkcję predict_score(sqr_metres) która zwraca cenę mieszkania zgodnie z modelem regresji liniowej ( 5 minut) \n",
|
|||
|
"\n",
|
|||
|
"Należy samemu wymyślić współczynniki modelu"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 12,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"def predict_price(sqr_metres):\n",
|
|||
|
" pass"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 13,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"predict_price(20)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 14,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"predict_price(40)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 15,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"predict_price(55)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 16,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"predict_price(0)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 17,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"Y_train_predicted = predict_price(X_train)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Mierzenie błędu"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/6.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/5.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zadanie - napisać funkcję, która liczy błąd średniowadratowy na całym zbiorze (7 minut)\n",
|
|||
|
"\n",
|
|||
|
"rmse(Y_true, Y_predicted)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 18,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"def rmse(Y_true, Y_predicted):\n",
|
|||
|
" pass "
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 19,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"rmse(np.array([300_000, 250_000]), np.array([300_000, 250_000]))"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 20,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"rmse(np.array([305_000, 250_000]) ,np.array([300_000, 350_000]) )"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 21,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"rmse(np.array([300_000, 250_000]), np.array([330_000, 360_000]))"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zadanie - za pomocą rmse policzyć błąd dla baseline (3 minuty)\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zadanie - za pomocą rmse policzyc błąd dla predykcji (2 minuty)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Na jakim zbiorze najlepiej sprawdzać wyniki?\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/7.png)\n",
|
|||
|
"\n",
|
|||
|
"![a](obrazki/8.png)\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 22,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"mieszkania_dev = pd.read_csv(DATA_DIR/'dev-0'/'in.tsv', sep = '\\t', names = names)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 23,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"with open(DATA_DIR/'dev-0'/'expected.tsv','r') as dev_exp_f:\n",
|
|||
|
" Y_dev = np.array([float(x.rstrip('\\n')) for x in dev_exp_f.readlines()])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 24,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"mieszkania_dev['price'] = Y_dev"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 25,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"X_dev = mieszkania_dev['sqrMetres'].to_numpy()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 26,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<AxesSubplot:xlabel='sqrMetres', ylabel='price'>"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 26,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAncAAAE9CAYAAABp4UT1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAp+UlEQVR4nO3df5Sc1Xng+e8TiWAhA5aQ0BIJW+2xTPgx8Q96BQ6BeIxBSsJYTAIbzZkMWqIJG8Im2DvZBGZYswF81uzkhJg5CxnGGAT2GBTiGC0bgtsijhmGCBr/CD8UWUo6gIwimjTGCvYQhJ/9o26b6qZVKpp6u6re+n7OqVNVt9576763m9bDve9z38hMJEmSVA8/0u0OSJIkqXMM7iRJkmrE4E6SJKlGDO4kSZJqxOBOkiSpRgzuJEmSamR+tzvQK5YsWZIrV67sdjckSZIO6tFHH30+M5fO9JnBXbFy5UpGR0e73Q1JkqSDioinDvSZy7KSJEk1YnAnSZJUIwZ3kiRJNWJwJ0mSVCMGd5IkSTVicCdJklQjBneSJEk1YnAnSZJUIwZ3kiRJNWJwJ0mS1CFjz7/Ex+9+nLHnX+paHwzuJEmSOuSWB8e47aGnuOXBsa71wXvLSpIkdciFpw1Nee4GgztJkqQOGVqykKvWndTVPrgsK0mSVCMGd5IkSTVicCdJklQjBneSJEk1YnAnSZJUIwZ3kiRJNWJwJ0mSVCMGd5IkSTVicCdJklQjlQZ3EXFpRDweEU9ExEdL2eKIGImIneV5UdPxl0fErojYERFrmspPjojHymfXR0SU8kMj4s5Svi0iVjbV2VC+Y2dEbKjyPCVJknpFZcFdRJwE/AqwGngPcE5ErAIuA7Zm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|||
|
"text/plain": [
|
|||
|
"<Figure size 720x360 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"needs_background": "light"
|
|||
|
},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"sns.scatterplot(x='sqrMetres',y='price', data = mieszkania_dev, linewidth = 0, s = 5)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Zadanie - policzyć rmse dla predykcji ze zbioru deweloperskiego modelu baseline i naszego modelu regresji liniowej"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Przypadek wielowymiarowy"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 27,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<AxesSubplot:xlabel='floor', ylabel='price'>"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 27,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmEAAAFICAYAAAAYvikoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAyt0lEQVR4nO3de3zV9Z3v+/cnIcEI4aJCVKKAAhEExZJeqOOtBS8bptSxnoedTvHYdnuU6XjpTE87G8Z22LCnPbN31Tmt+vC4tXpmtraMrbSgVehoZSNtDQUrkAYQpEQkRLkFCCQk3/PHWunOjy4E57i+nwXf1/Px8PFJ1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dE9h06nImxpbwmy/vavXemAgDiIgkrwHNEpH/fPpkYW8rTQt7X7r0zFQAQFwvzC/BcJHznlDEaUFWR5EhU6uZMH6t5ixo1Z/pY764AACKwEIJ3H96X+vr60NDQ4N0NAACAYzKzlSGE+kL3MR0JAADggCQMAADAAUkYSgq1ugAAqSAJQ0mhVhcAIBXsjkRJ4fgaAEAqGAkrgCkxAABQbCRhBTAl5sfzuadiPQAgJpKwAryPr0nZ1HE1qqup1tRxNdHb/tunX1dTS5v+9unXo7ctMQLriecegAeSMJSUJeta1NTSpiXrWqK3fbi7OxNjYwTWD889AA8szC/g/qXr9czqbdrb3qn7brrEuztJ8VyYP37YQG3fu0Pjhw2M3rbEpgRPPPcAPJCEIWPzO/v12PLNuuXSkckd4j172jidPajK7Y245wBxxMdzD8ADSVgBKR+i3TMtI8nlTWn+4nVa2rhD23a365GbPxy1bd6I/aSc/ANIF0lYASm/GXtPy7z
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 720x360 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"needs_background": "light"
|
|||
|
},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"sns.scatterplot(x='floor',y='price', data = mieszkania_train, linewidth = 0, s = 5)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"$Y = w_1 * X_1 + w_2 * X_1 + w_3 * X_3 + w_0$"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zadanie. Napisać analogiczną funkcję predict_price(sqr_metres, floor), policzyć rmse dla takiego modelu ( 7 minut)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## jak dobrać najlepsze parametry?"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 28,
|
|||
|
"metadata": {
|
|||
|
"scrolled": true
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"<seaborn.axisgrid.FacetGrid at 0x7fbaa0c46760>"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 28,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAFuCAYAAAChovKPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAB7FklEQVR4nO29eZwkV3Xn+70RkVvtS1f1LnW3pO4CLYCQhIQFtBrZFsZPDDMau2WPPczAINtjS8YPBnkGMzyYBT3zQUifsY30ZA+DF8lYA0ZjQNhCNEK2BBINElpK3a1qtXqvpWvJyj0i7vvjRmTlvnVmVWbW/X4Q1RmZGXkjMuPEueee8ztCSolGo9FoOgdjrQeg0Wg0mvrQhluj0Wg6DG24NRqNpsPQhluj0Wg6DG24NRqNpsPQhluj0Wg6jI403EKIPxNCTAshXqjx9b8khHhJCPGiEOKvWj0+jUajaSWiE/O4hRDvBJaBL0spL6vy2kuArwD7pJTzQohxKeX0aoxTo9FoWkFHetxSyieAc7nbhBAXCSEeFUL8SAjxfSHEhPfUvwP+SEo5771XG22NRtPRdKThLsP9wO9IKd8KfBT4Y2/7bmC3EOIfhRBPCyFuWrMRajQaTROw1noAzUAI0Qe8HfgbIYS/OeT9tYBLgL3ANuD7QojLpJQLqzxMjUajaQpdYbhRM4cFKeWbSzx3AnhaSpkBjgohXkEZ8mdWcXwajUbTNLoiVCKlXEIZ5X8JIB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MAoid4ZQ29uNbpVtXW/XSLfPMLoixq3Tp9qb3qBaDMs13q5U29uRbpRtXW/
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 360x360 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"needs_background": "light"
|
|||
|
},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"sns.lmplot(x='sqrMetres',y='price', data = mieszkania_train)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 29,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"lm_model = LinearRegression()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 30,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"LinearRegression()"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 30,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"lm_model.fit(mieszkania_train[['isNew','rooms', 'floor', 'sqrMetres']], Y_train)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 31,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"Y_train_predicted = lm_model.predict(mieszkania_train[['isNew','rooms', 'floor', 'sqrMetres']])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 32,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"rmse(Y_train, Y_train_predicted)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 33,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"Y_dev_predicted = lm_model.predict(mieszkania_dev[['isNew','rooms', 'floor', 'sqrMetres']])"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 34,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"rmse(Y_dev, Y_dev_predicted)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 35,
|
|||
|
"metadata": {
|
|||
|
"scrolled": true
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"array([469449.27836213])"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 35,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"lm_model.predict(np.array(([[0, 4, 3, 70]])))"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 36,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"array([455982.54297977])"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 36,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"lm_model.predict(np.array(([[0, 4, 3, 60]])))"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 37,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"array([ 4522.65059749, 73763.4125433 , -78.83243119, 1346.67353824])"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 37,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"lm_model.coef_"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 38,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"80364.97780599026"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 38,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"lm_model.intercept_"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 39,
|
|||
|
"metadata": {
|
|||
|
"scrolled": true
|
|||
|
},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"text/plain": [
|
|||
|
"455982.5429800203"
|
|||
|
]
|
|||
|
},
|
|||
|
"execution_count": 39,
|
|||
|
"metadata": {},
|
|||
|
"output_type": "execute_result"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"0 * 4522.65059749 + 4* 73763.4125433 + 3 * (-78.83243119) + 60 * 1346.67353824 + 80364.97780599032"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 40,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"with open(DATA_DIR/'dev-0'/'out.tsv','w') as f_out_file:\n",
|
|||
|
" for line in Y_dev_predicted:\n",
|
|||
|
" f_out_file.write(str(line))\n",
|
|||
|
" f_out_file.write('\\n')"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Uwaga - regresja linowa działa dobrze tylko dla danych, gdzie występuje korelacja liniowa"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![a](obrazki/9.png)\n",
|
|||
|
"\n",
|
|||
|
"![a](obrazki/10.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Zadanie domowe\n",
|
|||
|
"Zadanie domowe, proszę wybrać jedno z dwóch:\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"- sforkować repozytorium <https://git.wmi.amu.edu.pl/kubapok/auta-public>\n",
|
|||
|
"- Opis zadadania znajduje się w README.md\n",
|
|||
|
"- stworzyć model regresji liniowej dla tego zbioru (można użyć gotowych bibliotek)\n",
|
|||
|
"- dodać skrypty z rozwiązaniem oraz predykcje dla dev-0 i test-A i sprawdzić czy ewaluacja jest poprawna za pomocą geval\n",
|
|||
|
"- wynik zaliczający to max 50_000 RMSE dla dev-0\n",
|
|||
|
"- termin 18.05, 50 punktów,Zadanie proszę oddać w MS TEAMS umieszczając link do repo (repo powinno mieć uprawnienia do odczytu dla użytkownika kubapok lub być publiczne).\n",
|
|||
|
"- punkty: 40, dla 3 najlepszych wyników na test-A: 70\n",
|
|||
|
"\n",
|
|||
|
"LUB:\n",
|
|||
|
"\n",
|
|||
|
"analogicznie dla <https://git.wmi.amu.edu.pl/kubapok/retroc2>\n",
|
|||
|
"- należy użyć wektoryzacji (np tf-dif)\n",
|
|||
|
"- wynik zaliczający to max 50 RMSE dla dev-0 \n",
|
|||
|
"- punkty: 60, dla 3 najlepszych wyników na test-A: 80,\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"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.8.5"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 4
|
|||
|
}
|