{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Wczytanie datasetów" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "train_dataset = pd.read_csv(\"./train.tsv\", sep = \"\\t\", header=None)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "test_dataset = pd.read_csv(\"./in.tsv\", sep = \"\\t\", header=None)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Data exploration " ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
012345678910111213141516171819202122232425
0309000.0do zamieszkania390 złspółdzielcze własnościowe7113https://www.otodom.pl/oferta/niezalezny-uklad-...2NaN43.44wtórny4.0blokNaNNaNNiezależny Układ W Nowoczesnym Wydaniu1NaNgazoweplastikoweNaNNaNNaNcegłaPolecamy na sprzedaż dwupokojowe mieszkanie p...NaNtelewizja kablowa, internet, meble, piwnica, g...
\n", "
" ], "text/plain": [ " 0 1 2 3 4 \\\n", "0 309000.0 do zamieszkania 390 zł spółdzielcze własnościowe 7113 \n", "\n", " 5 6 7 8 9 \\\n", "0 https://www.otodom.pl/oferta/niezalezny-uklad-... 2 NaN 43.44 wtórny \n", "\n", " 10 11 12 13 14 15 16 17 \\\n", "0 4.0 blok NaN NaN Niezależny Układ W Nowoczesnym Wydaniu 1 NaN gazowe \n", "\n", " 18 19 20 21 22 \\\n", "0 plastikowe NaN NaN NaN cegła \n", "\n", " 23 24 \\\n", "0 Polecamy na sprzedaż dwupokojowe mieszkanie p... NaN \n", "\n", " 25 \n", "0 telewizja kablowa, internet, meble, piwnica, g... " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset.head(1)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4\n", "7000 42\n", "6750 42\n", "7100 37\n", "7500 29\n", "7800 20\n", " ..\n", "9674 1\n", "7565 1\n", "8352 1\n", "7511 1\n", "5077 1\n", "Name: count, Length: 1452, dtype: int64" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset[4].value_counts()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "pd.set_option(\"display.max_columns\", None)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
04710121316192024
count2.547000e+032547.0000000.02316.0000000.00.00.01768.0000000.00.0
mean4.210372e+057201.618767NaN5.015112NaNNaNNaN2011.436086NaNNaN
std2.663796e+051737.605837NaN2.797598NaNNaNNaN610.162290NaNNaN
min4.500000e+0436.000000NaN1.000000NaNNaNNaN50.000000NaNNaN
25%2.990000e+056200.000000NaN4.000000NaNNaNNaN1976.000000NaNNaN
50%3.590000e+057000.000000NaN4.000000NaNNaNNaN2011.000000NaNNaN
75%4.570000e+057868.000000NaN5.000000NaNNaNNaN2019.000000NaNNaN
max6.000000e+0623005.000000NaN21.000000NaNNaNNaN20120.000000NaNNaN
\n", "
" ], "text/plain": [ " 0 4 7 10 12 13 16 \\\n", "count 2.547000e+03 2547.000000 0.0 2316.000000 0.0 0.0 0.0 \n", "mean 4.210372e+05 7201.618767 NaN 5.015112 NaN NaN NaN \n", "std 2.663796e+05 1737.605837 NaN 2.797598 NaN NaN NaN \n", "min 4.500000e+04 36.000000 NaN 1.000000 NaN NaN NaN \n", "25% 2.990000e+05 6200.000000 NaN 4.000000 NaN NaN NaN \n", "50% 3.590000e+05 7000.000000 NaN 4.000000 NaN NaN NaN \n", "75% 4.570000e+05 7868.000000 NaN 5.000000 NaN NaN NaN \n", "max 6.000000e+06 23005.000000 NaN 21.000000 NaN NaN NaN \n", "\n", " 19 20 24 \n", "count 1768.000000 0.0 0.0 \n", "mean 2011.436086 NaN NaN \n", "std 610.162290 NaN NaN \n", "min 50.000000 NaN NaN \n", "25% 1976.000000 NaN NaN \n", "50% 2011.000000 NaN NaN \n", "75% 2019.000000 NaN NaN \n", "max 20120.000000 NaN NaN " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset.describe()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3\n", "pełna własność 1515\n", "spółdzielcze własnościowe 158\n", "spółdzielcze wł. z KW 131\n", "udział 15\n", "Name: count, dtype: int64" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset[3].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Odfiltrowanie wartości liczbowych" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "filtered= train_dataset[[0,8,15,2]]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
08152
0309000.043.441390 zł
\n", "
" ], "text/plain": [ " 0 8 15 2 \n", "0 309000.0 43.44 1 390 zł" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered.head(1)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "15\n", "1 569\n", "parter 452\n", "2 419\n", "4 357\n", "3 321\n", "5 117\n", "6 51\n", "7 42\n", "8 32\n", "10 29\n", "> 10 24\n", "9 21\n", "suterena 5\n", "poddasze 3\n", "Name: count, dtype: int64" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered[15].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Zamiana wsyztskich wartości na wartosći liczbowe, odfiltrowanie wartości trudnych do zamiany oraz usunięcie brakujących wartości" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\s433445\\AppData\\Local\\temp\\ipykernel_7796\\2098381410.py:1: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " filtered[15] = filtered[15].replace({\"parter\": 0})\n" ] } ], "source": [ "filtered[15] = filtered[15].replace({\"parter\": 0})\n", "string = [\"> 10\", \"suterena\", \"poddasze\"]\n", "filtered = filtered[~filtered[15].isin(string)]\n", "filtered = filtered[~filtered[15].isna()]" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
08152
0309000.043.441390 zł
1314900.042.601NaN
2249000.044.302300 zł
3419000.0881490 zł
4499000.0777850 zł
...............
2541383680.070.400NaN
2542507600.09431 zł
2543342400.053.504NaN
2544335000.055.254280 zł
2545260000.0622NaN
\n", "

2410 rows × 4 columns

\n", "
" ], "text/plain": [ " 0 8 15 2 \n", "0 309000.0 43.44 1 390 zł\n", "1 314900.0 42.60 1 NaN\n", "2 249000.0 44.30 2 300 zł\n", "3 419000.0 88 1 490 zł\n", "4 499000.0 77 7 850 zł\n", "... ... ... .. ...\n", "2541 383680.0 70.40 0 NaN\n", "2542 507600.0 94 3 1 zł\n", "2543 342400.0 53.50 4 NaN\n", "2544 335000.0 55.25 4 280 zł\n", "2545 260000.0 62 2 NaN\n", "\n", "[2410 rows x 4 columns]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "15\n", "1 569\n", "0 452\n", "2 419\n", "4 357\n", "3 321\n", "5 117\n", "6 51\n", "7 42\n", "8 32\n", "10 29\n", "9 21\n", "Name: count, dtype: int64" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered[15].value_counts()\n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "filtered[15] = filtered[15].apply(int)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8\n", "38 59\n", "48 40\n", "50 35\n", "53 28\n", "43 26\n", " ..\n", "33.79 1\n", "42.60 1\n", "47.82 1\n", "53.09 1\n", "55.25 1\n", "Name: count, Length: 1084, dtype: int64" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered[8].value_counts()" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "def check_value(number):\n", " try:\n", " return float(number)\n", " except:\n", " return str(np.nan)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
08152
0309000.043.441390 zł
1314900.042.601NaN
2249000.044.302300 zł
3419000.088.001490 zł
4499000.077.007850 zł
...............
2541383680.070.400NaN
2542507600.094.0031 zł
2543342400.053.504NaN
2544335000.055.254280 zł
2545260000.062.002NaN
\n", "

2410 rows × 4 columns

\n", "
" ], "text/plain": [ " 0 8 15 2 \n", "0 309000.0 43.44 1 390 zł\n", "1 314900.0 42.60 1 NaN\n", "2 249000.0 44.30 2 300 zł\n", "3 419000.0 88.00 1 490 zł\n", "4 499000.0 77.00 7 850 zł\n", "... ... ... .. ...\n", "2541 383680.0 70.40 0 NaN\n", "2542 507600.0 94.00 3 1 zł\n", "2543 342400.0 53.50 4 NaN\n", "2544 335000.0 55.25 4 280 zł\n", "2545 260000.0 62.00 2 NaN\n", "\n", "[2410 rows x 4 columns]" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "filtered[8] = filtered[8].apply(check_value)\n", "filtered = filtered[~filtered[8].isna()]" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [], "source": [ "filtered = filtered[[0, 15, 8]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Model" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "from sklearn.linear_model import LinearRegression\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "from sklearn.preprocessing import StandardScaler" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "X = filtered.drop(0,axis=1)\n", "y = filtered[[0]]\n", "\n", "scaler = StandardScaler()\n", "trans_data = scaler.fit_transform(X)\n", "\n", "X_train, X_test, y_train, y_test = train_test_split(trans_data,y, test_size=0.33)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [], "source": [ "reg = LinearRegression()" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "reg.fit(X_train, y_train)\n", "results = reg.predict(X_test)" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "import pickle" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Zapis jako pkl" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [], "source": [ "pickle.dump(reg, open(\"model.pkl\", \"wb\"))" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 593653.27660188],\n", " [ 347445.92747813],\n", " [ 405167.78785587],\n", " [ 536368.93860499],\n", " [ 285944.97361261],\n", " [ 424034.91112136],\n", " [ 272900.72398813],\n", " [ 475401.99674084],\n", " [ 314256.66427135],\n", " [ 499602.00468798],\n", " [ 319442.70363808],\n", " [ 345408.47997727],\n", " [ 324469.23238515],\n", " [ 443182.15703217],\n", " [ 250637.45215307],\n", " [ 209585.7569203 ],\n", " [ 270014.46501481],\n", " [ 347445.92747813],\n", " [ 200395.07888311],\n", " [ 341165.63081938],\n", " [ 358551.3301064 ],\n", " [ 335193.80097933],\n", " [ 614485.48015284],\n", " [ 426332.58063066],\n", " [ 683415.56543175],\n", " [ 568532.08996689],\n", " [ 269911.64274191],\n", " [ 330600.57284487],\n", " [ 340303.25136243],\n", " [ 203970.63870921],\n", " [ 443440.26815648],\n", " [ 343360.47805578],\n", " [1329699.64270264],\n", " [ 620229.65392608],\n", " [ 312930.52914428],\n", " [ 314256.66427135],\n", " [ 539430.38706659],\n", " [ 327534.90261501],\n", " [ 445735.82678165],\n", " [ 593552.5652131 ],\n", " [ 200904.96847936],\n", " [ 390845.64791458],\n", " [ 309151.43565651],\n", " [ 319541.30414273],\n", " [ 483778.54013134],\n", " [ 406679.66689186],\n", " [ 295877.4190811 ],\n", " [ 256561.03718286],\n", " [ 524622.47993419],\n", " [ 269861.28704753],\n", " [1478921.21612892],\n", " [ 350791.7203533 ],\n", " [ 479690.97982487],\n", " [ 550662.73437289],\n", " [ 289240.41079339],\n", " [ 672183.21812545],\n", " [ 655845.64220431],\n", " [ 538408.49698997],\n", " [ 354085.04664996],\n", " [ 656867.53228093],\n", " [1157759.4853077 ],\n", " [ 383569.69446848],\n", " [ 432510.05501651],\n", " [ 381147.19116528],\n", " [ 256561.03718286],\n", " [ 308387.6567042 ],\n", " [ 352934.10101118],\n", " [ 232562.45201327],\n", " [ 537896.4965096 ],\n", " [ 467438.85332607],\n", " [ 837615.42279484],\n", " [ 204992.52878583],\n", " [ 418853.09352288],\n", " [ 388803.97864547],\n", " [ 732128.26991297],\n", " [ 963910.65682254],\n", " [ 108998.18810747],\n", " [ 387528.19921279],\n", " [ 287196.63064015],\n", " [ 202443.0808046 ],\n", " [ 276045.09408575],\n", " [ 329040.44899862],\n", " [ 448619.97487084],\n", " [ 163632.36673436],\n", " [ 623091.79049426],\n", " [ 924084.38532806],\n", " [ 259674.95222298],\n", " [ 357253.53915271],\n", " [ 571597.76019675],\n", " [ 243287.02060745],\n", " [ 374508.07199344],\n", " [ 757196.98996944],\n", " [ 334171.91090272],\n", " [ 345839.66970574],\n", " [ 361741.83413015],\n", " [ 169886.43010385],\n", " [ 212419.5493151 ],\n", " [1100061.74733508],\n", " [ 809023.60949078],\n", " [ 465213.55103217],\n", " [ 409739.00446933],\n", " [ 375733.49573174],\n", " [ 668097.7687031 ],\n", " [ 992837.17023455],\n", " [ 824341.40621943],\n", " [ 791662.0326089 ],\n", " [ 405526.61036896],\n", " [ 262692.37764257],\n", " [ 609354.01824874],\n", " [ 652779.97197445],\n", " [ 249668.02865497],\n", " [ 420207.57282333],\n", " [ 612520.39986737],\n", " [ 336263.93586621],\n", " [ 435523.25866785],\n", " [ 336060.40220454],\n", " [ 599756.2728882 ],\n", " [ 308129.54557989],\n", " [ 304558.20752204],\n", " [ 426078.6912746 ],\n", " [ 316810.33402083],\n", " [ 328451.8595346 ],\n", " [ 427124.70375635],\n", " [ 998452.28844564],\n", " [ 700777.14231363],\n", " [ 249924.02889515],\n", " [ 281323.40130476],\n", " [ 349104.65182902],\n", " [ 737283.8542222 ],\n", " [ 108232.29827104],\n", " [ 638484.06532243],\n", " [ 630825.1669581 ],\n", " [ 256561.03718286],\n", " [ 652882.79424735],\n", " [ 274942.39325724],\n", " [ 415741.28936689],\n", " [ 348594.76223277],\n", " [ 339710.44013016],\n", " [ 262692.37764257],\n", " [ 396462.8770098 ],\n", " [ 336217.80194008],\n", " [ 208563.86684368],\n", " [ 431617.22050204],\n", " [ 429039.42834743],\n", " [ 641344.09100648],\n", " [ 194394.90486968],\n", " [ 451709.76750583],\n", " [ 236650.01231974],\n", " [ 422452.77575411],\n", " [ 475553.063824 ],\n", " [ 262692.37764257],\n", " [1148566.69638638],\n", " [ 512342.00926201],\n", " [ 294573.29547504],\n", " [ 306089.9871949 ],\n", " [ 279336.30949828],\n", " [ 355872.82656301],\n", " [ 348467.81755474],\n", " [ 496284.55598619],\n", " [ 431849.0983371 ],\n", " [ 317832.22409745],\n", " [ 685969.23518123],\n", " [ 293424.46072039],\n", " [ 334432.13291115],\n", " [ 747752.42257619],\n", " [ 268226.68510176],\n", " [ 366851.28451325],\n", " [ 448619.97487084],\n", " [ 499602.00468798],\n", " [ 353675.86844248],\n", " [ 336390.88054424],\n", " [ 341830.80926704],\n", " [ 501645.78484122],\n", " [ 298175.08859039],\n", " [ 116276.25243771],\n", " [ 379103.41101204],\n", " [ 228888.29168252],\n", " [ 635420.5059767 ],\n", " [ 330213.4061584 ],\n", " [ 348467.81755474],\n", " [ 286126.49575328],\n", " [ 385893.59726703],\n", " [ 195806.07251689],\n", " [ 505733.34514769],\n", " [ 479178.97934449],\n", " [ 518318.06087031],\n", " [ 379871.4117326 ],\n", " [ 319493.05933247],\n", " [ 192046.879666 ],\n", " [1035724.89019064],\n", " [ 539940.27666284],\n", " [ 297203.55420816],\n", " [ 351785.26625653],\n", " [ 336929.11431387],\n", " [ 316810.33402083],\n", " [ 390847.75879871],\n", " [ 640628.55686444],\n", " [ 512114.35319521],\n", " [ 937233.56810956],\n", " [ 312470.99524242],\n", " [ 426078.6912746 ],\n", " [ 294855.52900448],\n", " [ 387784.19945298],\n", " [ 390388.22489685],\n", " [ 367768.24143284],\n", " [ 409483.00422915],\n", " [ 247880.24874192],\n", " [ 229625.83734557],\n", " [ 287732.75352566],\n", " [ 231693.73990394],\n", " [1115379.54406373],\n", " [ 169582.1850534 ],\n", " [ 689800.79524752],\n", " [ 448033.49629095],\n", " [ 258604.8173361 ],\n", " [ 292811.74885124],\n", " [ 302768.31672486],\n", " [ 362457.3682722 ],\n", " [ 447527.82846296],\n", " [ 230291.01579323],\n", " [ 531259.48822189],\n", " [ 295877.4190811 ],\n", " [ 341828.69838291],\n", " [ 247880.24874192],\n", " [ 404478.48700308],\n", " [ 341830.80926704],\n", " [1492963.23342489],\n", " [ 463095.29277941],\n", " [ 202948.74863259],\n", " [ 257582.92725948],\n", " [ 403305.5298433 ],\n", " [ 499602.00468798],\n", " [ 625207.93786289],\n", " [ 449385.86470727],\n", " [ 370424.73345522],\n", " [ 651171.60331795],\n", " [ 369505.6656515 ],\n", " [ 534325.15845175],\n", " [ 442420.48896399],\n", " [ 310173.32573313],\n", " [ 688139.9600125 ],\n", " [ 305577.98671453],\n", " [ 325745.01181783],\n", " [ 369912.73297485],\n", " [ 475553.063824 ],\n", " [ 311195.21580974],\n", " [ 402005.62800549],\n", " [ 293424.46072039],\n", " [ 471979.61488203],\n", " [1004581.51802122],\n", " [ 791841.44386544],\n", " [ 312217.10588636],\n", " [ 691074.46379607],\n", " [ 511320.1191854 ],\n", " [ 257582.92725948],\n", " [ 476625.30959501],\n", " [ 529370.99692007],\n", " [ 241499.2406944 ],\n", " [ 258604.8173361 ],\n", " [ 567000.31029403],\n", " [ 915226.2965147 ],\n", " [ 692096.35387269],\n", " [ 425056.80119798],\n", " [ 527355.56094021],\n", " [ 533303.26837513],\n", " [ 206778.19781476],\n", " [ 346502.73726928],\n", " [ 464627.07245228],\n", " [ 294855.52900448],\n", " [ 344128.47877634],\n", " [ 433737.58963892],\n", " [ 607848.47186513],\n", " [ 217244.65528462],\n", " [ 186609.06182733],\n", " [ 423932.08884846],\n", " [ 550559.91209999],\n", " [ 286583.91877101],\n", " [ 374328.6607369 ],\n", " [ 330213.4061584 ],\n", " [ 250816.86340962],\n", " [ 323576.39787069],\n", " [ 334760.50036673],\n", " [ 264736.15779581],\n", " [ 377317.74198311],\n", " [ 174127.16837761],\n", " [ 351533.4877846 ],\n", " [ 363785.61428339],\n", " [ 786046.91439781],\n", " [ 505733.34514769],\n", " [ 448543.3858872 ],\n", " [ 346143.91475619],\n", " [ 266465.13847797],\n", " [1011549.00464863],\n", " [ 355104.82584245],\n", " [ 620334.5870831 ],\n", " [ 270856.94383489],\n", " [ 161997.76478859],\n", " [ 212651.42715015],\n", " [ 297409.19875396],\n", " [ 298457.32211984],\n", " [ 479690.97982487],\n", " [ 571188.58198928],\n", " [ 255539.14710624],\n", " [ 453648.61450204],\n", " [ 618573.04045931],\n", " [ 370424.73345522],\n", " [ 284439.427229 ],\n", " [ 396972.76660604],\n", " [ 286174.74056354],\n", " [1070448.04395441],\n", " [ 223371.77397608],\n", " [ 315788.44394421],\n", " [ 366085.39467681],\n", " [ 415303.76698603],\n", " [ 502667.67491784],\n", " [ 306597.76590702],\n", " [ 733456.51592417],\n", " [ 769963.22783273],\n", " [ 192379.46888983],\n", " [ 281686.44558609],\n", " [ 731412.73577093],\n", " [ 703586.8123033 ],\n", " [ 418496.38189392],\n", " [ 204581.23969423],\n", " [ 260648.59748933],\n", " [ 560367.52377458],\n", " [ 170269.37502206],\n", " [ 373488.29280095],\n", " [ 745734.87571221],\n", " [ 326513.01253839],\n", " [ 512342.00926201],\n", " [ 289496.41103358],\n", " [ 341828.69838291],\n", " [ 409739.00446933],\n", " [ 343542.00019645],\n", " [ 541113.23382262],\n", " [ 386635.36469833],\n", " [ 771751.00774578],\n", " [ 384208.63962688],\n", " [ 318090.33522176],\n", " [ 394421.20774069],\n", " [ 347445.92747813],\n", " [ 371444.51264772],\n", " [ 110223.61184576],\n", " [ 282730.34718372],\n", " [ 218778.54584161],\n", " [ 444462.1582331 ],\n", " [ 290439.60124243],\n", " [ 266263.71570042],\n", " [ 298505.5669301 ],\n", " [ 281607.74571832],\n", " [ 380891.19092509],\n", " [ 141677.561718 ],\n", " [ 351660.43246263],\n", " [ 258604.8173361 ],\n", " [ 386812.66507075],\n", " [ 411603.37336603],\n", " [ 255539.14710624],\n", " [ 373155.70357712],\n", " [ 275351.57146471],\n", " [ 450077.27644419],\n", " [ 361231.94453391],\n", " [ 338331.83842458],\n", " [ 553730.51548687],\n", " [ 419441.68298689],\n", " [ 549310.36595657],\n", " [ 220564.21487054],\n", " [ 524213.30172672],\n", " [ 342850.58845953],\n", " [ 279537.73227583],\n", " [ 245711.63479478],\n", " [ 493732.99712083],\n", " [ 281684.33470197],\n", " [ 288218.52071677],\n", " [ 646142.96368675],\n", " [ 450075.16556006],\n", " [ 348467.81755474],\n", " [ 335193.80097933],\n", " [ 653801.86205107],\n", " [ 421203.22961069],\n", " [ 486839.98859294],\n", " [ 743666.97315385],\n", " [1687753.14123477],\n", " [ 372466.40272433],\n", " [ 740627.53621325],\n", " [ 424034.91112136],\n", " [ 318420.81356146],\n", " [ 177928.27338639],\n", " [ 470754.19114374],\n", " [ 255539.14710624],\n", " [ 432641.22146279],\n", " [ 370424.73345522],\n", " [ 318854.11417407],\n", " [ 348623.10640616],\n", " [ 791662.0326089 ],\n", " [ 915226.2965147 ],\n", " [ 379998.35641063],\n", " [ 108998.18810747],\n", " [ 283111.18121781],\n", " [ 233098.57489877],\n", " [ 348467.81755474],\n", " [ 292428.80393303],\n", " [ 345863.79211087],\n", " [1648436.75933653],\n", " [ 331108.35155699],\n", " [ 380889.08004096],\n", " [ 403664.35235639],\n", " [1031131.66205617],\n", " [1244558.92618062],\n", " [ 271036.35509143],\n", " [ 694628.01210117],\n", " [ 486583.98835276],\n", " [ 486610.22164201],\n", " [ 311604.39401722],\n", " [ 647648.51007036],\n", " [ 344892.25772864],\n", " [ 286174.74056354],\n", " [ 158017.24852327],\n", " [ 170269.37502206],\n", " [ 330600.57284487],\n", " [ 354082.93576583],\n", " [ 915226.2965147 ],\n", " [ 333585.43232283],\n", " [ 385613.47462171],\n", " [ 436289.14850428],\n", " [ 380125.30108866],\n", " [ 118930.63357596],\n", " [ 370422.6225711 ],\n", " [ 305324.09735847],\n", " [ 454287.55966044],\n", " [ 449055.38636757],\n", " [1110784.20504514],\n", " [ 218546.66800656],\n", " [ 233584.34208989],\n", " [ 906545.50807375],\n", " [ 391178.23713841],\n", " [1062021.14486953],\n", " [ 616273.26006589],\n", " [ 312980.88483867],\n", " [ 231081.02803479],\n", " [ 212651.42715015],\n", " [ 231540.56193665],\n", " [ 272900.72398813],\n", " [ 479944.86918093],\n", " [ 292306.08102325],\n", " [ 474710.58500393],\n", " [ 341500.33092734],\n", " [ 351533.4877846 ],\n", " [ 365829.39443663],\n", " [ 361741.83413015],\n", " [ 260318.11914963],\n", " [ 255287.36863431],\n", " [ 605296.91299977],\n", " [ 363785.61428339],\n", " [ 483518.3181229 ],\n", " [ 538918.38658622],\n", " [ 289851.01177841],\n", " [ 233584.34208989],\n", " [ 731412.73577093],\n", " [ 196055.7401047 ],\n", " [ 294599.52876429],\n", " [ 278314.41942167],\n", " [ 461307.51286636],\n", " [ 380816.71282557],\n", " [ 258604.8173361 ],\n", " [ 329066.68228787],\n", " [ 521915.63221742],\n", " [ 379026.8220284 ],\n", " [ 222325.76149433],\n", " [ 448033.49629095],\n", " [ 631847.05703472],\n", " [ 492916.75159001],\n", " [ 369400.73249448],\n", " [ 232818.45225346],\n", " [ 815154.94995049],\n", " [ 842466.76205362],\n", " [ 142699.45179462],\n", " [ 415612.23380473],\n", " [ 932229.0508835 ],\n", " [ 231540.56193665],\n", " [ 539430.38706659],\n", " [ 377317.74198311],\n", " [ 362124.77904837],\n", " [ 339710.44013016],\n", " [ 279207.25393613],\n", " [ 456714.28473189],\n", " [ 303024.31696505],\n", " [ 195112.54989585],\n", " [ 403664.35235639],\n", " [ 260902.48684539],\n", " [ 322659.4409511 ],\n", " [ 308129.54557989],\n", " [ 377317.74198311],\n", " [ 623166.26859378],\n", " [ 349441.4628211 ],\n", " [ 563938.86183243],\n", " [ 381578.38089375],\n", " [ 534325.15845175],\n", " [ 208999.27834041],\n", " [ 205323.00712553],\n", " [ 292306.08102325],\n", " [ 374328.6607369 ],\n", " [ 551938.51380557],\n", " [ 508282.79312892],\n", " [ 374125.12707523],\n", " [ 424034.91112136],\n", " [ 294522.93978065],\n", " [ 426231.86924189],\n", " [ 345660.2584492 ],\n", " [ 530753.8203939 ],\n", " [ 388547.97840529],\n", " [ 368124.9530618 ],\n", " [ 609277.4292651 ],\n", " [ 328810.68204769],\n", " [ 455186.72682728],\n", " [ 445659.23779801],\n", " [ 315788.44394421],\n", " [ 180431.58744148],\n", " [ 311882.40577841],\n", " [ 305580.09759866],\n", " [ 269835.05375827],\n", " [ 250945.91897177],\n", " [ 234352.34281045],\n", " [ 532281.37829851],\n", " [ 301365.59261415],\n", " [ 731412.73577093],\n", " [ 335550.51260829],\n", " [ 397484.76708642],\n", " [ 387834.55514737],\n", " [ 335193.80097933],\n", " [ 234297.76534781],\n", " [ 162610.47665774],\n", " [ 298046.03302824],\n", " [ 449055.38636757],\n", " [ 350995.25401497],\n", " [ 273664.50294043],\n", " [ 262692.37764257],\n", " [ 373333.00394954],\n", " [ 605450.09096706],\n", " [ 416378.12364116],\n", " [ 511348.46335878],\n", " [ 108232.29827104],\n", " [ 325491.12246177],\n", " [ 368892.95378236],\n", " [ 164094.01152034],\n", " [ 439022.22951031],\n", " [ 837615.42279484],\n", " [ 245074.8005205 ],\n", " [ 232562.45201327],\n", " [ 538918.38658622],\n", " [ 694628.01210117],\n", " [ 298457.32211984],\n", " [ 319620.0040105 ],\n", " [ 269835.05375827],\n", " [ 388193.37766045],\n", " [ 755411.32094052],\n", " [ 196311.74034489],\n", " [ 437030.91593558],\n", " [ 329550.33859486],\n", " [ 358170.4960723 ],\n", " [ 321915.56263567],\n", " [ 264014.29100138],\n", " [ 403101.99618163],\n", " [ 456714.28473189],\n", " [ 234043.87599175],\n", " [ 333915.91066253],\n", " [ 293271.2827531 ],\n", " [ 604019.02268297],\n", " [ 414257.75450428],\n", " [ 283520.35942528],\n", " [ 682651.78647944],\n", " [ 319212.93668715],\n", " [ 349669.11888791],\n", " [ 338229.01615168],\n", " [ 255539.14710624],\n", " [ 224724.1423924 ],\n", " [ 838355.07934202],\n", " [ 787578.69407068],\n", " [ 475553.063824 ],\n", " [ 341828.69838291],\n", " [ 885612.59313402],\n", " [ 291028.19070644],\n", " [ 306601.98767528],\n", " [ 329066.68228787],\n", " [ 347445.92747813],\n", " [ 332690.48692424],\n", " [ 367818.59712723],\n", " [ 296899.30915772],\n", " [ 319366.11465444],\n", " [ 331209.06294576],\n", " [ 160006.45121387],\n", " [ 578494.99049289],\n", " [ 331106.24067286],\n", " [ 325491.12246177],\n", " [ 270064.8207092 ],\n", " [ 307930.23368647],\n", " [ 371444.51264772],\n", " [ 260648.59748933],\n", " [ 427787.77131988],\n", " [ 367615.06346555],\n", " [ 302514.4273688 ],\n", " [ 310429.32597331],\n", " [ 448545.49677132],\n", " [ 299067.92310486],\n", " [ 424034.91112136],\n", " [ 348467.81755474],\n", " [ 620794.12098496],\n", " [ 225822.62145267],\n", " [ 302258.42712862],\n", " [ 274686.39301705],\n", " [ 339710.44013016],\n", " [ 289393.58876068],\n", " [ 167461.81591652],\n", " [ 341325.14143904],\n", " [ 641805.73579247],\n", " [ 210607.64699692],\n", " [ 294676.11774794],\n", " [ 837615.42279484],\n", " [ 332128.13074948],\n", " [ 309409.54678082],\n", " [ 426205.63595263],\n", " [ 378591.41053167],\n", " [ 465213.55103217],\n", " [ 196412.45173366],\n", " [ 503919.33194538],\n", " [ 353933.9795668 ],\n", " [ 261670.48756595],\n", " [ 262692.37764257],\n", " [ 430164.14069695],\n", " [ 517985.47164648],\n", " [ 350559.84251824],\n", " [ 349003.94044025],\n", " [ 362354.5459993 ],\n", " [ 200904.96847936],\n", " [ 179103.34143029],\n", " [ 912928.6270054 ],\n", " [ 302232.19383936],\n", " [ 365829.39443663],\n", " [ 277725.82995765],\n", " [ 487349.87818919],\n", " [ 455186.72682728],\n", " [ 531259.48822189],\n", " [1997172.63515345],\n", " [ 542008.1792212 ],\n", " [ 250945.91897177],\n", " [ 370422.6225711 ],\n", " [ 740093.52421187],\n", " [ 304556.09663791],\n", " [ 325235.12222159],\n", " [ 274942.39325724],\n", " [ 117908.74349934],\n", " [ 488802.95799428],\n", " [ 209561.63451517],\n", " [ 121508.42573058],\n", " [ 356642.93816769],\n", " [ 298943.08931095],\n", " [ 235628.12224313],\n", " [ 445989.71613772],\n", " [ 445989.71613772],\n", " [ 535347.04852837],\n", " [ 193246.07011503],\n", " [ 286966.86368922],\n", " [ 373488.29280095],\n", " [ 383033.57158297],\n", " [ 203382.0492452 ],\n", " [ 212038.71528101],\n", " [ 320742.60547589],\n", " [ 765877.77841038],\n", " [ 161028.34129049],\n", " [ 344128.47877634],\n", " [ 423932.08884846],\n", " [ 354341.04689014],\n", " [ 261563.4435248 ],\n", " [ 400624.91541579],\n", " [ 456714.28473189],\n", " [ 225925.44372557],\n", " [ 267285.60577704],\n", " [ 476883.42071932],\n", " [ 461565.62399067],\n", " [ 347395.57178374],\n", " [ 240221.35037759],\n", " [ 387657.25477495],\n", " [ 442726.84489856],\n", " [ 529727.70854903],\n", " [ 833785.97361268],\n", " [1609505.43324064],\n", " [ 391103.7590389 ],\n", " [ 476117.53088289],\n", " [ 339710.44013016],\n", " [ 404708.25395401],\n", " [ 255156.20218803],\n", " [ 312217.10588636],\n", " [ 477393.31031557],\n", " [ 339710.44013016],\n", " [ 407695.2243161 ],\n", " [ 379103.41101204],\n", " [ 358170.4960723 ],\n", " [ 340325.26288343],\n", " [ 343616.47829596],\n", " [ 209894.223739 ],\n", " [ 350203.13088928],\n", " [ 292811.74885124],\n", " [ 373258.52585002],\n", " [ 255539.14710624],\n", " [ 454670.50457866],\n", " [ 344997.19088567],\n", " [ 212421.66019923],\n", " [ 224800.73137605],\n", " [ 390845.64791458],\n", " [ 398351.36831162],\n", " [ 620284.23138872],\n", " [ 652193.49339457],\n", " [ 241549.59638879],\n", " [ 329578.68276825],\n", " [ 657095.18834773],\n", " [ 579307.01425546],\n", " [ 438588.9288977 ],\n", " [ 543005.94689269],\n", " [ 345914.14780526],\n", " [ 273922.61406474],\n", " [ 335193.80097933],\n", " [ 288218.52071677],\n", " [ 117908.74349934],\n", " [ 572361.53914906],\n", " [ 541419.58975719],\n", " [ 280865.97828702],\n", " [ 289750.30038964],\n", " [ 264736.15779581],\n", " [ 655845.64220431],\n", " [ 263198.04547057],\n", " [ 569553.98004351],\n", " [ 291284.19094663],\n", " [ 119952.52365258],\n", " [ 787578.69407068],\n", " [ 682651.78647944],\n", " [1686731.25115815],\n", " [ 200904.96847936],\n", " [ 183059.73529048],\n", " [ 431949.80972587],\n", " [ 400445.50415925],\n", " [ 158960.43873212],\n", " [ 176400.71548177],\n", " [ 601721.35317367],\n", " [ 273922.61406474],\n", " [ 524876.36929025],\n", " [ 372311.11387292],\n", " [ 854543.69906412],\n", " [ 745708.64242296],\n", " [ 332128.13074948],\n", " [ 245227.97848779],\n", " [ 270014.46501481],\n", " [ 292811.74885124],\n", " [ 548185.65360705],\n", " [ 990793.39008132],\n", " [ 475553.063824 ],\n", " [ 305223.3859697 ],\n", " [ 346424.03740151],\n", " [ 654823.75212769],\n", " [ 206931.37578204],\n", " [ 661486.99370465],\n", " [ 250945.91897177],\n", " [ 258604.8173361 ],\n", " [ 316810.33402083],\n", " [ 661235.21523272],\n", " [ 259626.70741272],\n", " [ 671673.3285292 ],\n", " [ 356715.30538308],\n", " [ 472032.08146054],\n", " [ 717116.8291189 ],\n", " [ 303030.64961743],\n", " [ 358680.38566855],\n", " [ 361897.12298157],\n", " [ 258604.8173361 ],\n", " [ 345918.36957351],\n", " [ 300470.64721557],\n", " [ 508028.90377286],\n", " [ 383674.6276255 ],\n", " [ 426689.29225962],\n", " [ 712519.37921618],\n", " [ 511348.46335878],\n", " [ 345150.36885295],\n", " [2265236.1887889 ],\n", " [ 354341.04689014],\n", " [ 272082.36757318],\n", " [ 294855.52900448],\n", " [ 268176.32940738],\n", " [ 363785.61428339],\n", " [ 324957.1104604 ],\n", " [ 241243.24045421],\n", " [ 369300.0211057 ],\n", " [ 469555.0006947 ],\n", " [ 406167.66641148],\n", " [ 467180.74220176],\n", " [ 188245.77465722],\n", " [ 258604.8173361 ]])" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import r2_score" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5878080999086976" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r2_score(y_test, results)" ] } ], "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.10.11" }, "vscode": { "interpreter": { "hash": "1b132c2ed43285dcf39f6d01712959169a14a721cf314fe69015adab49bb1fd1" } } }, "nbformat": 4, "nbformat_minor": 2 }