{ "cells": [ { "cell_type": "code", "execution_count": 142, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 143, "metadata": {}, "outputs": [], "source": [ "train_dataset = pd.read_csv(\"J:/Desktop/Projects/mieszkania5/train/train.tsv\", sep = \"\\t\", header=None)" ] }, { "cell_type": "code", "execution_count": 163, "metadata": {}, "outputs": [], "source": [ "test_dataset = pd.read_csv(\"J:/Desktop/Projects/mieszkania5/test-A/in.tsv\", sep = \"\\t\", header=None)" ] }, { "cell_type": "code", "execution_count": 144, "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": 144, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset[4].value_counts()" ] }, { "cell_type": "code", "execution_count": 145, "metadata": {}, "outputs": [], "source": [ "pd.set_option(\"display.max_columns\", None)" ] }, { "cell_type": "code", "execution_count": 146, "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": 146, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset.describe()" ] }, { "cell_type": "code", "execution_count": 147, "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": 147, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset.head(1)" ] }, { "cell_type": "code", "execution_count": 148, "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": 148, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_dataset[3].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 15,8, (2)" ] }, { "cell_type": "code", "execution_count": 149, "metadata": {}, "outputs": [], "source": [ "filtered= train_dataset[[0,8,15,2]]" ] }, { "cell_type": "code", "execution_count": 150, "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": 150, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered[15].value_counts()" ] }, { "cell_type": "code", "execution_count": 151, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\s433445\\AppData\\Local\\temp\\ipykernel_3048\\4107925475.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})" ] }, { "cell_type": "code", "execution_count": 152, "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ł
...............
2542507600.09431 zł
2543342400.053.504NaN
2544335000.055.254280 zł
2545260000.0622NaN
25461990000.0392NaNNaN
\n", "

2547 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", "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", "2546 1990000.0 392 NaN NaN\n", "\n", "[2547 rows x 4 columns]" ] }, "execution_count": 152, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered" ] }, { "cell_type": "code", "execution_count": 153, "metadata": {}, "outputs": [], "source": [ "string = [\"> 10\", \"suterena\", \"poddasze\"]\n", "filtered = filtered[~filtered[15].isin(string)]\n", "filtered = filtered[~filtered[15].isna()]" ] }, { "cell_type": "code", "execution_count": 154, "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": 154, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered[15].value_counts()\n" ] }, { "cell_type": "code", "execution_count": 155, "metadata": {}, "outputs": [], "source": [ "filtered[15] = filtered[15].apply(int)" ] }, { "cell_type": "code", "execution_count": 156, "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": 156, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered[8].value_counts()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def check_value(number):\n", " try:\n", " return float(number)\n", " except:\n", " return str(number)\n", " \n", "def check_str(value):\n", " if isinstance(value,float):\n", " return 1\n", " else:\n", " return 0\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "filtered[8] = filtered[8].apply(check_value)\n", "\n", "filtered[\"isinstance\"] = filtered[15].apply(check_str)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "filtered = filtered[filtered[\"isinstance\"]==0]" ] }, { "cell_type": "code", "execution_count": null, "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", "
08152isinstance
0309000.043.441390 zł0
1314900.042.61NaN0
2249000.044.32300 zł0
3419000.088.01490 zł0
4499000.077.07850 zł0
..................
2541383680.070.40NaN0
2542507600.094.031 zł0
2543342400.053.54NaN0
2544335000.055.254280 zł0
2545260000.062.02NaN0
\n", "

2410 rows × 5 columns

\n", "
" ], "text/plain": [ " 0 8 15 2 isinstance\n", "0 309000.0 43.44 1 390 zł 0\n", "1 314900.0 42.6 1 NaN 0\n", "2 249000.0 44.3 2 300 zł 0\n", "3 419000.0 88.0 1 490 zł 0\n", "4 499000.0 77.0 7 850 zł 0\n", "... ... ... .. ... ...\n", "2541 383680.0 70.4 0 NaN 0\n", "2542 507600.0 94.0 3 1 zł 0\n", "2543 342400.0 53.5 4 NaN 0\n", "2544 335000.0 55.25 4 280 zł 0\n", "2545 260000.0 62.0 2 NaN 0\n", "\n", "[2410 rows x 5 columns]" ] }, "execution_count": 115, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered" ] }, { "cell_type": "code", "execution_count": 158, "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": 158, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def check_value(number):\n", " try:\n", " return float(number)\n", " except:\n", " return str(number)\n", " \n", "def check_str(value):\n", " if isinstance(value,float):\n", " return 1\n", " else:\n", " return 0" ] }, { "cell_type": "code", "execution_count": 172, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\s433445\\AppData\\Local\\temp\\ipykernel_3048\\588287806.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[8] = filtered[8].apply(check_value)\n" ] } ], "source": [ "filtered[8] = filtered[8].apply(check_value)\n", "filtered[\"check\"] = filtered[8].apply(check_str)" ] }, { "cell_type": "code", "execution_count": 174, "metadata": {}, "outputs": [], "source": [ "filtered = filtered[filtered[\"check\"]==1]" ] }, { "cell_type": "code", "execution_count": 175, "metadata": {}, "outputs": [], "source": [ "filtered = filtered[[0, 15, 8]]" ] }, { "cell_type": "code", "execution_count": 188, "metadata": {}, "outputs": [], "source": [ "from sklearn.linear_model import LinearRegression\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "execution_count": 169, "metadata": {}, "outputs": [], "source": [ "from sklearn.preprocessing import StandardScaler" ] }, { "cell_type": "code", "execution_count": 189, "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": 190, "metadata": {}, "outputs": [], "source": [ "reg = LinearRegression()" ] }, { "cell_type": "code", "execution_count": 194, "metadata": {}, "outputs": [], "source": [ "reg.fit(X_train, y_train)\n", "results = reg.predict(X_test)" ] }, { "cell_type": "code", "execution_count": 195, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 588386.57221532],\n", " [ 347185.77610695],\n", " [ 333667.85491179],\n", " [ 350580.90494961],\n", " [ 483551.82037238],\n", " [ 248402.31355669],\n", " [ 295901.04373419],\n", " [ 323316.55226325],\n", " [ 514285.10329076],\n", " [ 569442.34898305],\n", " [ 299242.73507231],\n", " [ 381314.18786798],\n", " [ 394953.7443501 ],\n", " [ 892738.5148359 ],\n", " [ 272138.69489957],\n", " [ 378488.55823341],\n", " [ 302083.12498475],\n", " [ 439267.54263911],\n", " [ 377860.01791385],\n", " [ 305395.29576713],\n", " [ 262051.02670974],\n", " [ 419504.94601791],\n", " [ 317934.53105975],\n", " [ 747521.51913496],\n", " [ 266848.78842728],\n", " [ 231279.0665647 ],\n", " [ 343488.33557891],\n", " [ 268743.56605691],\n", " [ 415383.55851754],\n", " [ 248464.90773216],\n", " [ 521090.12125395],\n", " [ 389142.17256733],\n", " [ 488384.7062526 ],\n", " [ 543565.8688937 ],\n", " [ 787076.2329331 ],\n", " [ 461387.54108894],\n", " [ 343790.64726429],\n", " [1332628.97166205],\n", " [ 330121.57022644],\n", " [ 247314.70210211],\n", " [ 375146.86689529],\n", " [ 227824.89661056],\n", " [ 230348.21455975],\n", " [ 343064.38860658],\n", " [ 231279.0665647 ],\n", " [ 394257.00624813],\n", " [ 234021.73813899],\n", " [ 360674.17674638],\n", " [ 272197.73601105],\n", " [ 340395.51842163],\n", " [ 350610.42550535],\n", " [ 521075.36097608],\n", " [ 288535.68323385],\n", " [ 453467.44165838],\n", " [ 293757.39192372],\n", " [ 899504.85557242],\n", " [ 420196.08051295],\n", " [ 351019.61219981],\n", " [ 425627.986157 ],\n", " [ 593569.60367853],\n", " [ 548354.47394031],\n", " [ 207365.56188738],\n", " [ 289914.39915993],\n", " [ 469547.35802941],\n", " [ 882523.60775218],\n", " [ 354005.55434801],\n", " [ 347185.77610695],\n", " [ 251767.92184361],\n", " [1005309.13664698],\n", " [ 222300.8762353 ],\n", " [ 225165.18309654],\n", " [ 856623.21071403],\n", " [ 416679.31638334],\n", " [ 358643.00355193],\n", " [ 650710.18866767],\n", " [ 452907.09912123],\n", " [ 360795.81203333],\n", " [ 387081.47881714],\n", " [ 349806.81239429],\n", " [ 470638.52254798],\n", " [ 476732.04213132],\n", " [ 474988.42034439],\n", " [ 345866.10129235],\n", " [ 364264.74226534],\n", " [ 181162.85316385],\n", " [ 363947.67030209],\n", " [ 461787.57111248],\n", " [ 616581.77690664],\n", " [ 377919.05902532],\n", " [ 306038.59636457],\n", " [ 707747.45171172],\n", " [ 248284.23133373],\n", " [ 385240.13869206],\n", " [ 279041.43120091],\n", " [ 413322.86476735],\n", " [ 415422.23574421],\n", " [ 387870.33165033],\n", " [ 405821.10870219],\n", " [ 423801.40630978],\n", " [ 352656.35897767],\n", " [ 306267.1066606 ],\n", " [ 409435.59116995],\n", " [ 456302.22796389],\n", " [ 265318.91665851],\n", " [ 415383.55851754],\n", " [ 308829.10183646],\n", " [ 265318.91665851],\n", " [ 298780.11087331],\n", " [ 466635.21727057],\n", " [ 446087.32088017],\n", " [ 456302.22796389],\n", " [ 607004.56681341],\n", " [ 343692.92892614],\n", " [ 455317.9384544 ],\n", " [ 306788.77197108],\n", " [ 296992.20825276],\n", " [ 483610.86148386],\n", " [ 267053.38177451],\n", " [ 787046.71237736],\n", " [ 347215.29666269],\n", " [ 429052.63555539],\n", " [ 423801.40630978],\n", " [ 527895.13921713],\n", " [ 515088.71640181],\n", " [ 231279.0665647 ],\n", " [ 360840.09286694],\n", " [ 296962.68769702],\n", " [ 290756.68949766],\n", " [ 342859.79525934],\n", " [ 347156.25555121],\n", " [ 657894.87276958],\n", " [ 306267.1066606 ],\n", " [ 231279.0665647 ],\n", " [ 350634.34245415],\n", " [ 248776.37608848],\n", " [ 283761.83846511],\n", " [ 469532.59775154],\n", " [ 357400.68319067],\n", " [ 576997.54255276],\n", " [ 387110.99937288],\n", " [ 371191.39551548],\n", " [ 547882.69307037],\n", " [ 255323.36319989],\n", " [ 473366.43384441],\n", " [ 531441.42390248],\n", " [ 580422.19195116],\n", " [ 504099.71676278],\n", " [ 328416.62566617],\n", " [ 341759.47406984],\n", " [ 299447.32841954],\n", " [ 372555.35116369],\n", " [ 725683.4684857 ],\n", " [ 238098.84480575],\n", " [1375623.09513646],\n", " [ 299447.32841954],\n", " [ 809664.45918887],\n", " [ 361916.49710764],\n", " [ 371040.23967279],\n", " [ 388133.96610904],\n", " [ 418778.6873602 ],\n", " [ 390384.49292859],\n", " [ 780256.45469204],\n", " [ 371158.32189575],\n", " [ 265377.95776999],\n", " [ 384679.7961549 ],\n", " [ 467691.25762646],\n", " [ 354005.55434801],\n", " [ 301629.65745668],\n", " [ 355013.7608063 ],\n", " [ 906392.83159589],\n", " [ 251708.88073213],\n", " [ 350838.93580138],\n", " [ 339956.81117143],\n", " [ 194861.45075744],\n", " [ 350713.74745044],\n", " [ 279017.51425211],\n", " [ 369539.88845975],\n", " [ 538939.62690366],\n", " [ 736375.7600463 ],\n", " [ 265022.20858007],\n", " [ 335796.74644438],\n", " [ 535177.5416572 ],\n", " [ 315814.79619808],\n", " [ 283747.07818724],\n", " [ 275957.77071456],\n", " [ 562082.59208965],\n", " [ 279017.51425211],\n", " [ 440957.72692151],\n", " [ 514285.10329076],\n", " [ 367733.67249735],\n", " [ 480186.21208546],\n", " [ 258801.45010283],\n", " [ 241683.80671778],\n", " [ 923442.27719853],\n", " [ 497410.7304796 ],\n", " [ 422437.45066157],\n", " [ 351603.87168577],\n", " [ 555174.25218137],\n", " [ 380232.18002035],\n", " [ 319877.14258698],\n", " [ 485627.27440044],\n", " [ 459815.43902951],\n", " [ 520787.80956856],\n", " [ 309691.756059 ],\n", " [ 284458.57656708],\n", " [ 354005.55434801],\n", " [ 317018.43933267],\n", " [ 701843.76519774],\n", " [ 559553.67053352],\n", " [ 339016.80249555],\n", " [ 262445.45312633],\n", " [ 482042.31248842],\n", " [ 641132.97857445],\n", " [ 523209.85611561],\n", " [ 393394.35202559],\n", " [ 319906.66314272],\n", " [ 360854.85314481],\n", " [ 442662.67148177],\n", " [ 323316.55226325],\n", " [1089148.12817839],\n", " [ 268773.08661265],\n", " [ 446813.57953789],\n", " [ 231249.54600896],\n", " [ 169871.54183943],\n", " [ 135743.1300784 ],\n", " [ 388664.78809046],\n", " [ 282178.52919179],\n", " [ 482042.31248842],\n", " [ 698448.63635508],\n", " [ 343692.92892614],\n", " [ 302871.97781794],\n", " [ 381284.66731224],\n", " [ 787046.71237736],\n", " [ 480829.5126829 ],\n", " [ 182935.99550652],\n", " [ 456302.22796389],\n", " [ 231537.09741647],\n", " [ 238098.84480575],\n", " [ 299417.8078638 ],\n", " [ 394924.22379436],\n", " [ 409221.84115178],\n", " [ 387110.99937288],\n", " [ 240115.25772233],\n", " [ 262294.29728364],\n", " [ 263424.13902888],\n", " [ 317845.96939253],\n", " [ 353976.03379227],\n", " [ 169871.54183943],\n", " [ 367615.59027439],\n", " [ 377767.90318263],\n", " [ 455059.90760263],\n", " [ 381284.66731224],\n", " [ 555262.81384859],\n", " [ 306296.62721634],\n", " [ 189551.18040035],\n", " [ 218881.83044384],\n", " [ 323301.79198538],\n", " [ 286202.19835402],\n", " [ 500675.06736438],\n", " [ 512891.62708681],\n", " [ 385634.56510865],\n", " [1428105.86703687],\n", " [ 335592.15309715],\n", " [ 637011.59107407],\n", " [ 302077.52137781],\n", " [ 215564.05605452],\n", " [ 442633.15092603],\n", " [ 251708.88073213],\n", " [ 299565.4106425 ],\n", " [ 373100.93342297],\n", " [ 507981.38675324],\n", " [ 416172.41135072],\n", " [ 392907.81087778],\n", " [ 654090.55723246],\n", " [ 270478.03117291],\n", " [ 408652.3419437 ],\n", " [ 401729.24175755],\n", " [ 294688.24392867],\n", " [ 684779.55931722],\n", " [ 319877.14258698],\n", " [ 329317.95711538],\n", " [ 282471.68420624],\n", " [ 323331.31254112],\n", " [ 367674.63138587],\n", " [ 233280.7192034 ],\n", " [ 264369.7513117 ],\n", " [ 401744.00203542],\n", " [ 328650.73956914],\n", " [ 322673.25166581],\n", " [ 641800.19612068],\n", " [ 292657.07073422],\n", " [ 531373.22612007],\n", " [ 385391.29453475],\n", " [ 420824.62083251],\n", " [ 403463.70687355],\n", " [ 461470.49914922],\n", " [ 514255.58273502],\n", " [ 311055.71170721],\n", " [ 270205.24004327],\n", " [ 435146.15513874],\n", " [ 238098.84480575],\n", " [ 403721.73772533],\n", " [ 268743.56605691],\n", " [ 895540.22752167],\n", " [ 238069.32425001],\n", " [ 279047.03480784],\n", " [ 377178.04008974],\n", " [ 922555.70602719],\n", " [1012099.39433229],\n", " [ 401773.52259116],\n", " [ 583832.08107168],\n", " [ 331432.08837011],\n", " [ 383656.82941875],\n", " [ 493986.0810812 ],\n", " [ 212207.60443853],\n", " [2195111.56553086],\n", " [ 476050.06430722],\n", " [ 189960.36709481],\n", " [ 372297.32031192],\n", " [ 275592.86485371],\n", " [ 211783.6574662 ],\n", " [ 460803.28160299],\n", " [ 401862.08425838],\n", " [ 462137.71669546],\n", " [ 413308.10448948],\n", " [ 480200.97236333],\n", " [ 307251.39617009],\n", " [ 569442.34898305],\n", " [ 361522.07069104],\n", " [ 251708.88073213],\n", " [ 323301.79198538],\n", " [ 266751.07008913],\n", " [ 497410.7304796 ],\n", " [ 316570.57541154],\n", " [ 322133.27301347],\n", " [ 272197.73601105],\n", " [ 255104.00957479],\n", " [ 416172.41135072],\n", " [ 221005.1183695 ],\n", " [ 429008.35472178],\n", " [ 600229.06940596],\n", " [1245077.77932473],\n", " [ 343692.92892614],\n", " [ 329187.1651575 ],\n", " [ 291672.78122473],\n", " [ 388445.43446536],\n", " [ 848424.71654689],\n", " [ 364264.74226534],\n", " [ 357863.30738967],\n", " [ 159490.71863515],\n", " [ 340614.87204673],\n", " [ 473244.79855745],\n", " [ 440670.17551399],\n", " [ 437260.28639347],\n", " [ 350580.90494961],\n", " [ 245571.08031518],\n", " [ 420927.9427776 ],\n", " [ 378064.61126108],\n", " [ 439252.78236124],\n", " [ 391499.57439596],\n", " [ 353976.03379227],\n", " [ 394924.22379436],\n", " [ 606337.34926718],\n", " [ 374435.36851545],\n", " [ 325557.92241186],\n", " [ 340395.51842163],\n", " [ 380617.44976601],\n", " [ 608436.72024404],\n", " [ 399727.58911884],\n", " [ 466517.13504761],\n", " [1151919.60855186],\n", " [ 500675.06736438],\n", " [ 282383.12253903],\n", " [ 358150.85879719],\n", " [ 487065.031438 ],\n", " [ 394227.48569239],\n", " [ 279996.20015465],\n", " [ 369661.52374671],\n", " [ 602912.69986878],\n", " [ 548383.99449605],\n", " [ 349762.53156068],\n", " [ 252906.92025978],\n", " [ 549065.97232016],\n", " [ 930291.57599533],\n", " [ 515171.67446209],\n", " [ 235643.72463897],\n", " [ 296514.82377589],\n", " [ 273775.44167742],\n", " [ 343746.36643068],\n", " [ 343790.64726429],\n", " [ 317018.43933267],\n", " [ 377889.53846958],\n", " [ 487717.48870637],\n", " [ 279017.51425211],\n", " [ 356694.78841776],\n", " [ 466635.21727057],\n", " [ 572238.45806188],\n", " [ 412738.60528139],\n", " [ 342426.69161608],\n", " [ 364264.74226534],\n", " [ 308995.01795702],\n", " [ 680634.25486805],\n", " [ 419884.61215664],\n", " [ 442662.67148177],\n", " [ 562880.60159376],\n", " [ 579043.47602507],\n", " [ 344297.55229691],\n", " [ 360932.20759815],\n", " [ 478466.50724733],\n", " [ 527924.65977287],\n", " [ 238766.06235199],\n", " [ 261885.11058918],\n", " [ 405139.13087808],\n", " [ 308283.51957718],\n", " [ 378503.31851128],\n", " [2393089.72786879],\n", " [ 319877.14258698],\n", " [ 261923.78781585],\n", " [ 217580.4689711 ],\n", " [ 536161.83116668],\n", " [ 452225.12129712],\n", " [ 295598.73204881],\n", " [ 599488.05047038],\n", " [ 595455.22463722],\n", " [ 462137.71669546],\n", " [ 422120.37869832],\n", " [ 849053.25686645],\n", " [ 326210.37968023],\n", " [ 248776.37608848],\n", " [ 408534.25972074],\n", " [ 387451.98828494],\n", " [ 278958.47314063],\n", " [ 272168.21545531],\n", " [ 326755.96193952],\n", " [ 136834.29459696],\n", " [ 452907.09912123],\n", " [ 293294.76772472],\n", " [ 366369.71684913],\n", " [ 837513.07136119],\n", " [ 308078.92622995],\n", " [ 306267.1066606 ],\n", " [ 345792.299903 ],\n", " [ 292716.1118457 ],\n", " [ 647226.49815779],\n", " [ 452931.01607003],\n", " [ 356256.08116756],\n", " [ 267379.6104087 ],\n", " [ 616552.2563509 ],\n", " [ 306092.03386911],\n", " [ 384724.07698851],\n", " [ 282383.12253903],\n", " [ 183481.57776581],\n", " [ 258558.17952893],\n", " [ 268743.56605691],\n", " [ 230597.08874059],\n", " [ 236447.33775003],\n", " [ 414209.43593869],\n", " [ 230339.05788882],\n", " [ 349216.9493014 ],\n", " [ 388104.4455533 ],\n", " [ 524470.48981874],\n", " [ 258528.65897319],\n", " [ 422188.57648073],\n", " [ 514285.10329076],\n", " [ 221005.1183695 ],\n", " [ 347215.29666269],\n", " [ 378586.27657156],\n", " [ 375799.32416366],\n", " [ 399985.61997061],\n", " [ 309662.23550326],\n", " [ 215549.29577665],\n", " [ 435901.93435219],\n", " [ 364264.74226534],\n", " [ 142767.50166669],\n", " [ 374518.32657573],\n", " [ 360795.81203333],\n", " [ 574254.87097846],\n", " [ 732352.09088407],\n", " [ 258528.65897319],\n", " [ 394408.16209082],\n", " [ 285579.26164139],\n", " [ 465835.1572235 ],\n", " [ 747521.51913496],\n", " [ 254066.28256076],\n", " [ 437533.07752311],\n", " [ 261256.57026961],\n", " [ 340107.96701412],\n", " [ 340395.51842163],\n", " [ 417293.09642503],\n", " [ 306788.77197108],\n", " [ 450511.02006593],\n", " [ 217609.98952684],\n", " [ 435326.83153717],\n", " [ 296022.67902114],\n", " [ 297937.82053558],\n", " [ 344487.38536627],\n", " [ 694994.46640094],\n", " [ 287483.19594195],\n", " [ 232832.85528227],\n", " [ 299565.4106425 ],\n", " [ 585780.29620585],\n", " [ 351686.82974605],\n", " [ 379891.19110829],\n", " [ 418876.40569835],\n", " [ 493825.76856758],\n", " [ 373631.75540439],\n", " [ 336941.34846749],\n", " [ 226543.89902263],\n", " [ 508337.13594317],\n", " [ 379837.75360375],\n", " [ 698419.11579934],\n", " [ 405806.34842432],\n", " [ 421219.04724911],\n", " [ 472699.21629817],\n", " [ 626796.68399035],\n", " [ 282178.52919179],\n", " [ 625462.24889788],\n", " [ 194861.45075744],\n", " [ 486279.73166881],\n", " [ 336941.34846749],\n", " [ 333667.85491179],\n", " [ 551156.18662608],\n", " [ 300114.54596578],\n", " [ 703163.44001234],\n", " [ 346245.76743107],\n", " [ 424044.67688368],\n", " [ 375146.86689529],\n", " [ 231279.0665647 ],\n", " [ 403039.75990122],\n", " [ 323287.03170751],\n", " [ 232939.73029135],\n", " [ 299296.17257685],\n", " [ 447436.51625051],\n", " [ 357430.20374641],\n", " [ 336887.91096295],\n", " [ 429023.11499965],\n", " [ 353976.03379227],\n", " [ 381815.48929366],\n", " [ 419421.98795763],\n", " [ 360469.58339915],\n", " [ 459712.11708442],\n", " [ 787046.71237736],\n", " [ 493796.24801184],\n", " [ 562023.55097817],\n", " [ 326726.44138378],\n", " [ 675246.63005761],\n", " [ 834814.68062051],\n", " [ 558657.94269125],\n", " [ 551867.68500593],\n", " [ 367630.35055226],\n", " [ 340010.24867597],\n", " [ 271593.11264028],\n", " [ 497206.13713237],\n", " [ 396658.68891037],\n", " [ 357892.82794541],\n", " [ 746128.04293101],\n", " [ 306267.1066606 ],\n", " [ 590637.09903487],\n", " [ 275592.86485371],\n", " [ 422651.20067973],\n", " [1185366.04248879],\n", " [ 350669.46661683],\n", " [ 135743.1300784 ],\n", " [ 334910.17527305],\n", " [ 360825.33258907],\n", " [ 330038.61216615],\n", " [ 446087.32088017],\n", " [ 374402.29489571],\n", " [ 347215.29666269],\n", " [ 394612.75543805],\n", " [ 616552.2563509 ],\n", " [ 824570.25298105],\n", " [ 446057.80032443],\n", " [ 422914.83513844],\n", " [ 218988.70545292],\n", " [ 393930.77761394],\n", " [ 660895.57519565],\n", " [ 345807.06018087],\n", " [ 364338.54365469],\n", " [ 583802.56051594],\n", " [ 303456.2373039 ],\n", " [ 360795.81203333],\n", " [ 493825.76856758],\n", " [ 290601.98059097],\n", " [ 368341.8489321 ],\n", " [ 435857.65351858],\n", " [ 203795.36025323],\n", " [ 231030.19238385],\n", " [ 200545.78364632],\n", " [ 510860.45389236],\n", " [ 211910.89636009],\n", " [ 544988.86565339],\n", " [ 401349.57561883],\n", " [ 449452.92916709],\n", " [ 333546.21962483],\n", " [ 323779.17646225],\n", " [ 313116.4054574 ],\n", " [ 380587.92921027],\n", " [ 381314.18786798],\n", " [ 392098.59415979],\n", " [ 279017.51425211],\n", " [ 435813.37268497],\n", " [ 295818.08567391],\n", " [ 470000.82555749],\n", " [ 200545.78364632],\n", " [ 344487.38536627],\n", " [ 197121.13424792],\n", " [ 200682.17921114],\n", " [ 467672.94428459],\n", " [ 462137.71669546],\n", " [ 473541.5066359 ],\n", " [ 181162.85316385],\n", " [ 423537.77185107],\n", " [ 183481.57776581],\n", " [ 339956.81117143],\n", " [ 366378.87352007],\n", " [ 462137.71669546],\n", " [ 306267.1066606 ],\n", " [ 361877.81988097],\n", " [ 453559.5563896 ],\n", " [ 258801.45010283],\n", " [ 873809.0518815 ],\n", " [ 257179.46360285],\n", " [ 238039.80369427],\n", " [ 507465.3250497 ],\n", " [ 361142.40455232],\n", " [ 268402.57714485],\n", " [ 319936.18369846],\n", " [ 268743.56605691],\n", " [ 377889.53846958],\n", " [ 220853.96252681],\n", " [ 272426.24630708],\n", " [ 532766.70232403],\n", " [ 381255.1467565 ],\n", " [ 691569.81700254],\n", " [ 517709.75268916],\n", " [ 360854.85314481],\n", " [ 410698.27541602],\n", " [ 928245.64252301],\n", " [ 336941.34846749],\n", " [ 217580.4689711 ],\n", " [ 309039.29879063],\n", " [ 718644.33661954],\n", " [ 729063.83705049],\n", " [ 237553.26254647],\n", " [ 289149.46327554],\n", " [ 399054.76796567],\n", " [ 456272.70740815],\n", " [ 272168.21545531],\n", " [ 328742.85430035],\n", " [ 601115.6405773 ],\n", " [ 323301.79198538],\n", " [ 569851.53567751],\n", " [ 858669.14418635],\n", " [ 654090.55723246],\n", " [ 217580.4689711 ],\n", " [ 484974.81713207],\n", " [ 238098.84480575],\n", " [ 329317.95711538],\n", " [ 241582.53531563],\n", " [ 272168.21545531],\n", " [ 258801.45010283],\n", " [ 529259.09486535],\n", " [ 449452.92916709],\n", " [ 370207.10600599],\n", " [ 316482.01374432],\n", " [ 411004.14016539],\n", " [ 361877.81988097],\n", " [ 357400.68319067],\n", " [ 378283.96488618],\n", " [ 338509.89746294],\n", " [ 452931.01607003],\n", " [ 292598.02962274],\n", " [ 299038.14172508],\n", " [ 404457.15305397],\n", " [ 234021.73813899],\n", " [ 455694.05152913],\n", " [ 555203.77273711],\n", " [ 349421.54264863],\n", " [ 491121.77421996],\n", " [ 516354.95371188],\n", " [ 356081.00837607],\n", " [ 224400.24721216],\n", " [ 336941.34846749],\n", " [ 598197.89621152],\n", " [ 379564.96247411],\n", " [ 298901.74616026],\n", " [ 278958.47314063],\n", " [ 486976.46977078],\n", " [ 310403.25443884],\n", " [1008007.52738766],\n", " [ 341077.49624574],\n", " [ 348798.605936 ],\n", " [ 353308.81624603],\n", " [ 933716.22539373],\n", " [ 838224.56974104],\n", " [ 384679.7961549 ],\n", " [ 487065.031438 ],\n", " [ 577679.52037686],\n", " [ 367733.67249735],\n", " [ 435813.37268497],\n", " [ 846423.06390818],\n", " [ 846423.06390818],\n", " [ 378586.27657156],\n", " [ 546376.7382504 ],\n", " [ 281632.94693251],\n", " [1819561.13807363],\n", " [ 415354.0379618 ],\n", " [ 444056.14768572],\n", " [ 366369.71684913],\n", " [ 457666.1836121 ],\n", " [ 483551.82037238],\n", " [ 674813.52641434],\n", " [ 609761.99866558],\n", " [ 347171.01582908],\n", " [ 364279.50254321],\n", " [ 188869.20257624],\n", " [ 251738.40128787],\n", " [ 596092.92162772],\n", " [ 263969.72128817],\n", " [ 248328.51216734],\n", " [ 630888.55093499],\n", " [ 434532.37509704],\n", " [ 566563.28184394],\n", " [ 428993.59444391],\n", " [ 459697.35680655],\n", " [ 391529.0949517 ],\n", " [ 292657.07073422],\n", " [ 425530.26781884],\n", " [ 558628.42213551],\n", " [ 984669.12552537],\n", " [ 483669.90259534],\n", " [ 281715.90499279],\n", " [ 401714.48147968],\n", " [ 466561.41588122],\n", " [ 497410.7304796 ],\n", " [ 268743.56605691],\n", " [ 269766.53279307],\n", " [ 439418.6984818 ],\n", " [ 439282.30291698],\n", " [ 343162.10694473],\n", " [ 188231.50558575],\n", " [ 350669.46661683],\n", " [ 585848.49398826],\n", " [ 943263.91493121],\n", " [ 336970.86902323],\n", " [ 335636.43393076],\n", " [ 930262.05543959],\n", " [ 341033.21541213],\n", " [ 323360.83309686],\n", " [ 279026.67092304],\n", " [ 437153.41138438],\n", " [ 295097.43062313],\n", " [ 398363.63347063],\n", " [ 602411.3984431 ],\n", " [ 423967.32243034],\n", " [ 352202.8914496 ],\n", " [ 219641.16272129],\n", " [ 524529.53093021],\n", " [ 545080.9803846 ],\n", " [ 270750.82230255],\n", " [ 429023.11499965],\n", " [ 235341.41295359],\n", " [ 705019.5404153 ],\n", " [ 466531.89532548],\n", " [ 283124.14147461],\n", " [ 304849.71350785],\n", " [ 493825.76856758],\n", " [ 326785.48249526],\n", " [ 497410.7304796 ],\n", " [ 316511.53430006],\n", " [ 742762.43464409],\n", " [ 316482.01374432],\n", " [ 371158.32189575],\n", " [ 355740.01946401],\n", " [ 512005.05591547],\n", " [ 378586.27657156],\n", " [ 285111.03383545],\n", " [ 586613.42987265],\n", " [ 309721.27661474],\n", " [ 392869.13365111],\n", " [ 243598.94823221],\n", " [ 357907.58822328],\n", " [ 463151.52676069],\n", " [ 884545.6242757 ],\n", " [ 306267.1066606 ],\n", " [ 326755.96193952],\n", " [ 521119.64180969],\n", " [ 339766.97810207],\n", " [ 215018.47379524],\n", " [ 526341.35049956],\n", " [ 351248.12249585],\n", " [ 480156.69152972],\n", " [ 524500.01037447],\n", " [ 633645.98278715]])" ] }, "execution_count": 195, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results" ] }, { "cell_type": "code", "execution_count": 198, "metadata": {}, "outputs": [], "source": [ "from sklearn.metrics import r2_score" ] }, { "cell_type": "code", "execution_count": 200, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5703042723573604" ] }, "execution_count": 200, "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 }