diff --git a/Lab1_zad2.ipynb b/Lab1_zad2.ipynb index ad185a9..dfa3eba 100644 --- a/Lab1_zad2.ipynb +++ b/Lab1_zad2.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"code","execution_count":232,"metadata":{"executionInfo":{"elapsed":422,"status":"ok","timestamp":1696951840697,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"veKEtGweNaXi"},"outputs":[],"source":["import pandas as pd\n","import numpy as np\n","import joblib\n"]},{"cell_type":"code","execution_count":191,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":4,"status":"ok","timestamp":1696952151344,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"w7poi-MONhxI","outputId":"379c3cbe-96bc-4d7e-d27f-dd56d02a817b"},"outputs":[],"source":["df_train = pd.read_csv('train.tsv', sep='\\t', header=None)"]},{"cell_type":"code","execution_count":192,"metadata":{"executionInfo":{"elapsed":226,"status":"ok","timestamp":1696952356655,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"8vT9n8oCPIhS"},"outputs":[],"source":["pd.set_option('display.max_columns', 500)"]},{"cell_type":"code","execution_count":193,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":643},"executionInfo":{"elapsed":254,"status":"ok","timestamp":1696952363298,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"hbfWxhoOOeQH","outputId":"3a4608d9-8d37-47c3-b28e-d64be0c43e2d"},"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"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \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...
1314900.0do wykończeniaNaNpełna własność7392https://www.otodom.pl/oferta/urokliwe-mieszkan...2NaN42.60pierwotny2.0blokNaNNaNUrokliwe mieszkanie 2 pokojowe Strzeszyn1NaNgazoweplastikoweNaNNaNNaNcegłaKameralne 2 pokojowe mieszkanie z aneksem kuc...NaNtelewizja kablowa, internet, telefon, drzwi / ...
2249000.0do remontu300 złpełna własność5621https://www.otodom.pl/oferta/mieszkanie-do-rem...2NaN44.30wtórny4.0blokNaNNaNMieszkanie do remontu ul. Klonowa, blisko tramwaj2NaNmiejskieplastikowe1960.0NaN2019-06-30cegłaOferta bezpośrednio od właściciela - bez pośr...NaNtelewizja kablowa, internet, telefon, domofon ...
3419000.0do zamieszkania490 złpełna własność4761https://www.otodom.pl/oferta/w-szeregowcu-4-po...4NaN88wtórny3.0szeregowiecNaNNaNW szeregowcu 4 pokoje z garażem1NaNgazoweplastikoweNaNNaNNaNcegłaDrodzy Państwo Zapraszam do zapoznania się z ...NaNtelewizja kablowa, internet, zmywarka, lodówka...
4499000.0NaN850 złNaN6481https://www.otodom.pl/oferta/komfortowe-przest...3NaN77wtórny16.0blokNaNNaNKomfortowe,Przestronne,3Pokoje, Armii Krajowej!!!7NaNNaNplastikoweNaNNaNNaNNaNBiuro Immohouse ma przyjemność proponować do ...NaNbalkon, piwnica, winda
\n","
"],"text/plain":[" 0 1 2 3 4 \\\n","0 309000.0 do zamieszkania 390 zł spółdzielcze własnościowe 7113 \n","1 314900.0 do wykończenia NaN pełna własność 7392 \n","2 249000.0 do remontu 300 zł pełna własność 5621 \n","3 419000.0 do zamieszkania 490 zł pełna własność 4761 \n","4 499000.0 NaN 850 zł NaN 6481 \n","\n"," 5 6 7 8 9 \\\n","0 https://www.otodom.pl/oferta/niezalezny-uklad-... 2 NaN 43.44 wtórny \n","1 https://www.otodom.pl/oferta/urokliwe-mieszkan... 2 NaN 42.60 pierwotny \n","2 https://www.otodom.pl/oferta/mieszkanie-do-rem... 2 NaN 44.30 wtórny \n","3 https://www.otodom.pl/oferta/w-szeregowcu-4-po... 4 NaN 88 wtórny \n","4 https://www.otodom.pl/oferta/komfortowe-przest... 3 NaN 77 wtórny \n","\n"," 10 11 12 13 \\\n","0 4.0 blok NaN NaN \n","1 2.0 blok NaN NaN \n","2 4.0 blok NaN NaN \n","3 3.0 szeregowiec NaN NaN \n","4 16.0 blok NaN NaN \n","\n"," 14 15 16 17 \\\n","0 Niezależny Układ W Nowoczesnym Wydaniu 1 NaN gazowe \n","1 Urokliwe mieszkanie 2 pokojowe Strzeszyn 1 NaN gazowe \n","2 Mieszkanie do remontu ul. Klonowa, blisko tramwaj 2 NaN miejskie \n","3 W szeregowcu 4 pokoje z garażem 1 NaN gazowe \n","4 Komfortowe,Przestronne,3Pokoje, Armii Krajowej!!! 7 NaN NaN \n","\n"," 18 19 20 21 22 \\\n","0 plastikowe NaN NaN NaN cegła \n","1 plastikowe NaN NaN NaN cegła \n","2 plastikowe 1960.0 NaN 2019-06-30 cegła \n","3 plastikowe NaN NaN NaN cegła \n","4 plastikowe NaN NaN NaN NaN \n","\n"," 23 24 \\\n","0 Polecamy na sprzedaż dwupokojowe mieszkanie p... NaN \n","1 Kameralne 2 pokojowe mieszkanie z aneksem kuc... NaN \n","2 Oferta bezpośrednio od właściciela - bez pośr... NaN \n","3 Drodzy Państwo Zapraszam do zapoznania się z ... NaN \n","4 Biuro Immohouse ma przyjemność proponować do ... NaN \n","\n"," 25 \n","0 telewizja kablowa, internet, meble, piwnica, g... \n","1 telewizja kablowa, internet, telefon, drzwi / ... \n","2 telewizja kablowa, internet, telefon, domofon ... \n","3 telewizja kablowa, internet, zmywarka, lodówka... \n","4 balkon, piwnica, winda "]},"execution_count":193,"metadata":{},"output_type":"execute_result"}],"source":["df_train.head()"]},{"cell_type":"markdown","metadata":{"id":"nt0TOLw5RAqS"},"source":["1,2,6, 8, 9 - to bedziemy w aplikacji używać\n"]},{"cell_type":"code","execution_count":194,"metadata":{},"outputs":[],"source":["df_train = df_train.iloc[:, [0, 1, 2, 6, 8, 9]]"]},{"cell_type":"code","execution_count":195,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1696952402833,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"QdXwQzPsOza0","outputId":"d5d231f0-da54-432f-9bd6-454d4063eaff"},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 2547 entries, 0 to 2546\n","Data columns (total 6 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 0 2547 non-null float64\n"," 1 1 1519 non-null object \n"," 2 2 929 non-null object \n"," 3 6 2547 non-null object \n"," 4 8 2547 non-null object \n"," 5 9 2547 non-null object \n","dtypes: float64(1), object(5)\n","memory usage: 119.5+ KB\n"]}],"source":["df_train.info()"]},{"cell_type":"code","execution_count":196,"metadata":{},"outputs":[],"source":["df_train.rename(columns={0: \"cena m\", 1: \"stan\", 2: \"czynsz\", 6: \"l pokoi\", 8: \"metraż\", 9: \"rynek\"}, inplace=True)"]},{"cell_type":"code","execution_count":197,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 2547 entries, 0 to 2546\n","Data columns (total 6 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 cena m 2547 non-null float64\n"," 1 stan 1519 non-null object \n"," 2 czynsz 929 non-null object \n"," 3 l pokoi 2547 non-null object \n"," 4 metraż 2547 non-null object \n"," 5 rynek 2547 non-null object \n","dtypes: float64(1), object(5)\n","memory usage: 119.5+ KB\n"]}],"source":["df_train.info()"]},{"cell_type":"markdown","metadata":{},"source":["Usunięcie kolumn, w których jest dużo pustych wartości"]},{"cell_type":"code","execution_count":198,"metadata":{"executionInfo":{"elapsed":249,"status":"ok","timestamp":1696953612119,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"x6jB9brYRSTJ"},"outputs":[],"source":["df_train.drop(columns = ['czynsz'], axis=1, inplace=True)"]},{"cell_type":"code","execution_count":199,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":608},"executionInfo":{"elapsed":339,"status":"ok","timestamp":1696953613765,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"NIzvOY2BQqTK","outputId":"ceaa0534-470a-4296-f51c-97f1b9904190"},"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","
cena mstanl pokoimetrażrynek
0309000.0do zamieszkania243.44wtórny
1314900.0do wykończenia242.60pierwotny
2249000.0do remontu244.30wtórny
3419000.0do zamieszkania488wtórny
4499000.0NaN377wtórny
\n","
"],"text/plain":[" cena m stan l pokoi metraż rynek\n","0 309000.0 do zamieszkania 2 43.44 wtórny\n","1 314900.0 do wykończenia 2 42.60 pierwotny\n","2 249000.0 do remontu 2 44.30 wtórny\n","3 419000.0 do zamieszkania 4 88 wtórny\n","4 499000.0 NaN 3 77 wtórny"]},"execution_count":199,"metadata":{},"output_type":"execute_result"}],"source":["df_train.head()"]},{"cell_type":"markdown","metadata":{},"source":["Uzupełnianie braków w danych "]},{"cell_type":"code","execution_count":200,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1696953649491,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"qNqxEsnNUZcH","outputId":"33ce3384-6b79-4795-c582-0d8fd8457943"},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 2547 entries, 0 to 2546\n","Data columns (total 5 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 cena m 2547 non-null float64\n"," 1 stan 1519 non-null object \n"," 2 l pokoi 2547 non-null object \n"," 3 metraż 2547 non-null object \n"," 4 rynek 2547 non-null object \n","dtypes: float64(1), object(4)\n","memory usage: 99.6+ KB\n"]}],"source":["df_train.info()"]},{"cell_type":"code","execution_count":201,"metadata":{"executionInfo":{"elapsed":245,"status":"ok","timestamp":1696953995554,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"5BTDYi_xUdGF"},"outputs":[],"source":["df_train['stan'].fillna('brak info', inplace=True)"]},{"cell_type":"code","execution_count":202,"metadata":{},"outputs":[],"source":["df_train = df_train[df_train['metraż'] != \"6 909\"]"]},{"cell_type":"code","execution_count":203,"metadata":{},"outputs":[],"source":["df_train = df_train[df_train['l pokoi'] != \"więcej niż 10\"]"]},{"cell_type":"code","execution_count":204,"metadata":{},"outputs":[],"source":["df_train['l pokoi'] = pd.to_numeric(df_train['l pokoi'])"]},{"cell_type":"code","execution_count":205,"metadata":{},"outputs":[],"source":["df_train['metraż'] = pd.to_numeric(df_train['metraż'])"]},{"cell_type":"code","execution_count":206,"metadata":{},"outputs":[],"source":["X_train = df_train.drop(columns = [\"cena m\"])\n","y_train = df_train[\"cena m\"]"]},{"cell_type":"code","execution_count":207,"metadata":{"executionInfo":{"elapsed":240,"status":"ok","timestamp":1696955504933,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"LW2CpZn6V5sl"},"outputs":[],"source":["number_cols = X_train.select_dtypes(exclude=[object]).columns\n","object_cols = X_train.select_dtypes(include=[object]).columns"]},{"cell_type":"code","execution_count":208,"metadata":{"executionInfo":{"elapsed":6,"status":"ok","timestamp":1696954577003,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"DJOcANTvXMjl"},"outputs":[],"source":["from sklearn.compose import ColumnTransformer\n","from sklearn.preprocessing import OneHotEncoder\n","from sklearn.preprocessing import StandardScaler\n","from sklearn.pipeline import make_pipeline"]},{"cell_type":"code","execution_count":209,"metadata":{"executionInfo":{"elapsed":240,"status":"ok","timestamp":1696955508626,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"5nvY10OHXjEw"},"outputs":[],"source":["ct = ColumnTransformer([\n"," (number_cols, StandardScaler()),\n"," (object_cols, OneHotEncoder())\n"," ],remainder='passthrough')\n"]},{"cell_type":"code","execution_count":210,"metadata":{"executionInfo":{"elapsed":529,"status":"ok","timestamp":1696954626952,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"wcGvPEZzYDPZ"},"outputs":[],"source":["from sklearn.linear_model import Ridge"]},{"cell_type":"code","execution_count":211,"metadata":{"executionInfo":{"elapsed":343,"status":"ok","timestamp":1696955511401,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"4z3w4bzbYseK"},"outputs":[],"source":["scaler = StandardScaler()\n","encoder = OneHotEncoder()\n","# putting numeric columns to scaler and categorical to encoder\n","num_transformer = make_pipeline(scaler)\n","cat_transformer = make_pipeline(encoder)\n","\n","# getting together our scaler and encoder with preprocessor\n","preprocessor = ColumnTransformer(\n"," transformers=[('num', num_transformer, number_cols),\n"," ('cat', cat_transformer, object_cols)])"]},{"cell_type":"code","execution_count":212,"metadata":{"executionInfo":{"elapsed":354,"status":"ok","timestamp":1696955513049,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"QXvbFrmXYLtR"},"outputs":[],"source":["clf = Ridge(alpha=1.0)"]},{"cell_type":"code","execution_count":213,"metadata":{"executionInfo":{"elapsed":428,"status":"ok","timestamp":1696955515987,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"pytR_osgX5Lb"},"outputs":[],"source":["model1 = make_pipeline(preprocessor, clf)"]},{"cell_type":"code","execution_count":214,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":608},"executionInfo":{"elapsed":233,"status":"ok","timestamp":1696955309653,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"vzR7OGK8Z-lD","outputId":"6aa1623d-b9fb-46ad-a200-f185708542ac"},"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","
stanl pokoimetrażrynek
0do zamieszkania243.44wtórny
1do wykończenia242.60pierwotny
2do remontu244.30wtórny
3do zamieszkania488.00wtórny
4brak info377.00wtórny
\n","
"],"text/plain":[" stan l pokoi metraż rynek\n","0 do zamieszkania 2 43.44 wtórny\n","1 do wykończenia 2 42.60 pierwotny\n","2 do remontu 2 44.30 wtórny\n","3 do zamieszkania 4 88.00 wtórny\n","4 brak info 3 77.00 wtórny"]},"execution_count":214,"metadata":{},"output_type":"execute_result"}],"source":["X_train.head()"]},{"cell_type":"code","execution_count":215,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":7,"status":"ok","timestamp":1696955419804,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"vcg92-RtbLSH","outputId":"457f8462-c2d8-4721-a19a-fb855998472c"},"outputs":[{"data":{"text/plain":["0 309000.0\n","1 314900.0\n","2 249000.0\n","3 419000.0\n","4 499000.0\n"," ... \n","2541 383680.0\n","2542 507600.0\n","2543 342400.0\n","2544 335000.0\n","2545 260000.0\n","Name: cena m, Length: 2540, dtype: float64"]},"execution_count":215,"metadata":{},"output_type":"execute_result"}],"source":["y_train"]},{"cell_type":"markdown","metadata":{"id":"GY_ZQICKc__t"},"source":["## Model Ridge - regresja liniowa"]},{"cell_type":"code","execution_count":216,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":191},"executionInfo":{"elapsed":236,"status":"ok","timestamp":1696955526976,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"cFvgBYD5YYz7","outputId":"008e021f-cb56-4458-99e8-ca95df32e68d"},"outputs":[{"data":{"text/html":["
Pipeline(steps=[('columntransformer',\n","                 ColumnTransformer(transformers=[('num',\n","                                                  Pipeline(steps=[('standardscaler',\n","                                                                   StandardScaler())]),\n","                                                  Index(['l pokoi', 'metraż'], dtype='object')),\n","                                                 ('cat',\n","                                                  Pipeline(steps=[('onehotencoder',\n","                                                                   OneHotEncoder())]),\n","                                                  Index(['stan', 'rynek'], dtype='object'))])),\n","                ('ridge', Ridge())])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
"],"text/plain":["Pipeline(steps=[('columntransformer',\n"," ColumnTransformer(transformers=[('num',\n"," Pipeline(steps=[('standardscaler',\n"," StandardScaler())]),\n"," Index(['l pokoi', 'metraż'], dtype='object')),\n"," ('cat',\n"," Pipeline(steps=[('onehotencoder',\n"," OneHotEncoder())]),\n"," Index(['stan', 'rynek'], dtype='object'))])),\n"," ('ridge', Ridge())])"]},"execution_count":216,"metadata":{},"output_type":"execute_result"}],"source":["model1.fit(X_train, y_train)"]},{"cell_type":"code","execution_count":217,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":451,"status":"ok","timestamp":1696955647207,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"M7X8ScQobnwG","outputId":"a30f27eb-2e34-4a91-fae0-a9ab53505322"},"outputs":[],"source":["df_test = pd.read_csv('in.tsv', sep='\\t', header=None)"]},{"cell_type":"code","execution_count":218,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":573},"executionInfo":{"elapsed":5,"status":"ok","timestamp":1696955652118,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"x3qN4TMKcDfL","outputId":"ed2fa477-65e6-494e-9423-de6894c47ef8"},"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"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
0123456789101112131415161718192021222324
0do zamieszkania250 złpełna własność6311https://www.otodom.pl/oferta/idealne-mieszkani...3NaN59.10wtórny4.0blokNaNNaNidealne mieszkanie do zamieszkania od zaraz2NaNmiejskieplastikoweNaNNaNNaNwielka płytaZamieszkaj od zaraz – idealna lokalizacja OFE...NaNtelewizja kablowa, internet, telefon, domofon ...
1do zamieszkaniaNaNpełna własność7868https://www.otodom.pl/oferta/2-pokoje-38m2-po-...2NaN38.00wtórny12.0blokNaNNaN2 pokoje / 38m2 / po remoncie / Winogrady4NaNinneplastikoweNaNNaNNaNNaNNa sprzedaż mieszkanie dwupokojowe na osiedlu...NaNbalkon
2do zamieszkania650 złpełna własność5717https://www.otodom.pl/oferta/3-pokoje-na-jezyc...3NaN63.84wtórny4.0blokNaNNaN3 pokoje na Jeżycach blisko Rusałki4NaNmiejskieplastikowe1958.0NaNNaNcegła!! Oferta dostępna tylko u nas !! Polecam ofe...NaNtelewizja kablowa, internet, telefon, piwnica,...
3do zamieszkania359 złspółdzielcze własnościowe7380https://www.otodom.pl/oferta/uniwersytet-przyr...4NaN50.00wtórny10.0blokNaNNaNUniwersytet Przyrodniczy - 4 pokoje - ROI 8-10%10NaNmiejskieplastikowe1975.0NaN2019-06-30wielka płytaOferta  bezpośrednio od właściciela  - bez po...NaNtelewizja kablowa, internet, telefon, drzwi / ...
4NaNNaNNaN7373https://www.otodom.pl/oferta/mieszkanie-blisko...3NaN65.62pierwotny3.0NaNNaNNaNMieszkanie blisko centrum w kameralnej okolicy.1NaNNaNNaN2020.0NaN2020-01-01NaNMIESZKANIE 3-POKOJOWE O POW.65,62M2 Mieszkani...NaNgaraż/miejsce parkingowe, taras, pom. użytkowe
\n","
"],"text/plain":[" 0 1 2 3 \\\n","0 do zamieszkania 250 zł pełna własność 6311 \n","1 do zamieszkania NaN pełna własność 7868 \n","2 do zamieszkania 650 zł pełna własność 5717 \n","3 do zamieszkania 359 zł spółdzielcze własnościowe 7380 \n","4 NaN NaN NaN 7373 \n","\n"," 4 5 6 7 \\\n","0 https://www.otodom.pl/oferta/idealne-mieszkani... 3 NaN 59.10 \n","1 https://www.otodom.pl/oferta/2-pokoje-38m2-po-... 2 NaN 38.00 \n","2 https://www.otodom.pl/oferta/3-pokoje-na-jezyc... 3 NaN 63.84 \n","3 https://www.otodom.pl/oferta/uniwersytet-przyr... 4 NaN 50.00 \n","4 https://www.otodom.pl/oferta/mieszkanie-blisko... 3 NaN 65.62 \n","\n"," 8 9 10 11 12 \\\n","0 wtórny 4.0 blok NaN NaN \n","1 wtórny 12.0 blok NaN NaN \n","2 wtórny 4.0 blok NaN NaN \n","3 wtórny 10.0 blok NaN NaN \n","4 pierwotny 3.0 NaN NaN NaN \n","\n"," 13 14 15 16 \\\n","0 idealne mieszkanie do zamieszkania od zaraz 2 NaN miejskie \n","1 2 pokoje / 38m2 / po remoncie / Winogrady 4 NaN inne \n","2 3 pokoje na Jeżycach blisko Rusałki 4 NaN miejskie \n","3 Uniwersytet Przyrodniczy - 4 pokoje - ROI 8-10% 10 NaN miejskie \n","4 Mieszkanie blisko centrum w kameralnej okolicy. 1 NaN NaN \n","\n"," 17 18 19 20 21 \\\n","0 plastikowe NaN NaN NaN wielka płyta \n","1 plastikowe NaN NaN NaN NaN \n","2 plastikowe 1958.0 NaN NaN cegła \n","3 plastikowe 1975.0 NaN 2019-06-30 wielka płyta \n","4 NaN 2020.0 NaN 2020-01-01 NaN \n","\n"," 22 23 \\\n","0 Zamieszkaj od zaraz – idealna lokalizacja OFE... NaN \n","1 Na sprzedaż mieszkanie dwupokojowe na osiedlu... NaN \n","2 !! Oferta dostępna tylko u nas !! Polecam ofe... NaN \n","3 Oferta  bezpośrednio od właściciela  - bez po... NaN \n","4 MIESZKANIE 3-POKOJOWE O POW.65,62M2 Mieszkani... NaN \n","\n"," 24 \n","0 telewizja kablowa, internet, telefon, domofon ... \n","1 balkon \n","2 telewizja kablowa, internet, telefon, piwnica,... \n","3 telewizja kablowa, internet, telefon, drzwi / ... \n","4 garaż/miejsce parkingowe, taras, pom. użytkowe "]},"execution_count":218,"metadata":{},"output_type":"execute_result"}],"source":["df_test.head()"]},{"cell_type":"code","execution_count":219,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":244,"status":"ok","timestamp":1696955801209,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"UybULQjXcMbT","outputId":"1bd9cb56-50cf-4040-f797-0d54e0293ef5"},"outputs":[],"source":["y_test = pd.read_csv('expected.tsv', sep='\\t', header=None)"]},{"cell_type":"code","execution_count":220,"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","
stanl pokoimetrażrynek
0do zamieszkania243.44wtórny
1do wykończenia242.60pierwotny
2do remontu244.30wtórny
3do zamieszkania488.00wtórny
4brak info377.00wtórny
...............
2541do wykończenia370.40pierwotny
2542do wykończenia494.00wtórny
2543brak info253.50wtórny
2544brak info355.25wtórny
2545brak info362.00wtórny
\n","

2540 rows × 4 columns

\n","
"],"text/plain":[" stan l pokoi metraż rynek\n","0 do zamieszkania 2 43.44 wtórny\n","1 do wykończenia 2 42.60 pierwotny\n","2 do remontu 2 44.30 wtórny\n","3 do zamieszkania 4 88.00 wtórny\n","4 brak info 3 77.00 wtórny\n","... ... ... ... ...\n","2541 do wykończenia 3 70.40 pierwotny\n","2542 do wykończenia 4 94.00 wtórny\n","2543 brak info 2 53.50 wtórny\n","2544 brak info 3 55.25 wtórny\n","2545 brak info 3 62.00 wtórny\n","\n","[2540 rows x 4 columns]"]},"execution_count":220,"metadata":{},"output_type":"execute_result"}],"source":["X_train"]},{"cell_type":"code","execution_count":221,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":8,"status":"ok","timestamp":1696955946495,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"WMsGxdMwdMM8","outputId":"d2a8f0ac-4051-465e-d43c-e1fb7b9a3034"},"outputs":[],"source":["df_test.rename(columns={0: \"stan\", 1: \"czynsz\", 5: \"l pokoi\", 7: \"metraż\", 8: \"rynek\"}, inplace=True)"]},{"cell_type":"code","execution_count":222,"metadata":{"executionInfo":{"elapsed":226,"status":"ok","timestamp":1696956067214,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"TNHLwq_5daGO"},"outputs":[{"data":{"text/plain":["Index([ 'stan', 'czynsz', 2, 3, 4, 'l pokoi',\n"," 6, 'metraż', 'rynek', 9, 10, 11,\n"," 12, 13, 14, 15, 16, 17,\n"," 18, 19, 20, 21, 22, 23,\n"," 24],\n"," dtype='object')"]},"execution_count":222,"metadata":{},"output_type":"execute_result"}],"source":["df_test.columns"]},{"cell_type":"code","execution_count":223,"metadata":{},"outputs":[],"source":["df_test = df_test[['stan', 'l pokoi', 'metraż', 'rynek']] "]},{"cell_type":"code","execution_count":224,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":6,"status":"ok","timestamp":1696956090162,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"tbcOpXendvZv","outputId":"93eddcd2-b741-4aa6-b185-59c96dc2e833"},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 462 entries, 0 to 461\n","Data columns (total 4 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 stan 275 non-null object \n"," 1 l pokoi 462 non-null int64 \n"," 2 metraż 462 non-null float64\n"," 3 rynek 462 non-null object \n","dtypes: float64(1), int64(1), object(2)\n","memory usage: 14.6+ KB\n"]}],"source":["df_test.info()"]},{"cell_type":"code","execution_count":225,"metadata":{"executionInfo":{"elapsed":323,"status":"ok","timestamp":1696956241887,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"j5IFS4YQdKPW"},"outputs":[],"source":["df_test['stan'].fillna('brak info', inplace=True)"]},{"cell_type":"code","execution_count":226,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 462 entries, 0 to 461\n","Data columns (total 4 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 stan 462 non-null object \n"," 1 l pokoi 462 non-null int64 \n"," 2 metraż 462 non-null float64\n"," 3 rynek 462 non-null object \n","dtypes: float64(1), int64(1), object(2)\n","memory usage: 14.6+ KB\n"]}],"source":["df_test.info()"]},{"cell_type":"code","execution_count":227,"metadata":{},"outputs":[{"data":{"text/plain":["0 59.10\n","1 38.00\n","2 63.84\n","3 50.00\n","4 65.62\n"," ... \n","457 72.78\n","458 51.23\n","459 54.16\n","460 90.10\n","461 71.90\n","Name: metraż, Length: 462, dtype: float64"]},"execution_count":227,"metadata":{},"output_type":"execute_result"}],"source":["df_test['metraż']"]},{"cell_type":"code","execution_count":228,"metadata":{},"outputs":[],"source":["df_test.reset_index(drop=True, inplace=True)"]},{"cell_type":"code","execution_count":229,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 462 entries, 0 to 461\n","Data columns (total 4 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 stan 462 non-null object \n"," 1 l pokoi 462 non-null int64 \n"," 2 metraż 462 non-null float64\n"," 3 rynek 462 non-null object \n","dtypes: float64(1), int64(1), object(2)\n","memory usage: 14.6+ KB\n"]}],"source":["df_test.info()"]},{"cell_type":"code","execution_count":230,"metadata":{},"outputs":[{"data":{"text/html":["
Pipeline(steps=[('columntransformer',\n","                 ColumnTransformer(transformers=[('num',\n","                                                  Pipeline(steps=[('standardscaler',\n","                                                                   StandardScaler())]),\n","                                                  Index(['l pokoi', 'metraż'], dtype='object')),\n","                                                 ('cat',\n","                                                  Pipeline(steps=[('onehotencoder',\n","                                                                   OneHotEncoder())]),\n","                                                  Index(['stan', 'rynek'], dtype='object'))])),\n","                ('ridge', Ridge())])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
"],"text/plain":["Pipeline(steps=[('columntransformer',\n"," ColumnTransformer(transformers=[('num',\n"," Pipeline(steps=[('standardscaler',\n"," StandardScaler())]),\n"," Index(['l pokoi', 'metraż'], dtype='object')),\n"," ('cat',\n"," Pipeline(steps=[('onehotencoder',\n"," OneHotEncoder())]),\n"," Index(['stan', 'rynek'], dtype='object'))])),\n"," ('ridge', Ridge())])"]},"execution_count":230,"metadata":{},"output_type":"execute_result"}],"source":["model1"]},{"cell_type":"markdown","metadata":{},"source":["Przykład - przewidywanie cen na danych testowych"]},{"cell_type":"code","execution_count":231,"metadata":{},"outputs":[{"data":{"text/plain":["array([ 407917.66889452, 285306.27863261, 444184.94702291,\n"," 299459.05926666, 459271.83408962, 614055.95902743,\n"," 311243.98561031, 361244.58944658, 329238.65906305,\n"," 369470.84812889, 285350.13919824, 329238.65906305,\n"," 420020.53940636, 399085.99304054, 368717.32379097,\n"," 339834.65864991, 335512.74515277, 304524.88092914,\n"," 367036.20209137, 286773.80808993, 354525.20168926,\n"," 282085.35025252, 386303.76202814, 477660.29347794,\n"," 407152.53644455, 490742.17175818, 529758.94244497,\n"," 335044.40697838, 399501.21194489, 431641.29394143,\n"," 331214.22563058, 334772.89329194, 404282.20491201,\n"," 369968.98599038, 392538.22357404, 354476.13872373,\n"," 531690.53563375, 428309.25045513, 298510.41733766,\n"," 551966.54555785, 332974.0302655 , 474293.99377424,\n"," 247049.65613431, 383931.85143325, 546789.20856336,\n"," 438766.28443053, 275556.44383868, 325403.7381088 ,\n"," 319934.12593671, 277654.95413295, 294800.60980049,\n"," 285306.27863261, 283776.01373268, 282811.35937324,\n"," 511210.54963994, 327121.56879228, 335039.88788041,\n"," 638797.47051695, 521922.40393947, 235305.67479634,\n"," 238447.52001532, 465392.89368935, 272046.09327325,\n"," 848434.43816552, 512546.27689188, 382253.07914128,\n"," 781492.5027453 , 531716.09929903, 442847.05008064,\n"," 498968.43044048, 272108.82871587, 275556.44383868,\n"," 307110.38376632, 373296.51037872, 320469.71865169,\n"," 629040.94693472, 456886.14569235, 463535.64405524,\n"," 356361.80264533, 387288.89243253, 249184.65490398,\n"," 305443.0398691 , 312129.77494706, 323562.90113092,\n"," 286773.80808993, 338640.52949322, 265910.97279499,\n"," 414803.86094421, 262352.30513363, 273562.29729465,\n"," 959123.60494806, 476401.54226445, 463695.54142089,\n"," 474293.99377424, 245933.92683679, 276309.90323886,\n"," 95163.71086422, 410945.54601501, 377887.30507851,\n"," 332477.49594204, 374627.25336918, 354168.19912956,\n"," 369968.98599038, 311900.23521207, 275897.03611221,\n"," 272224.40035237, 522497.33812211, 317135.7885512 ,\n"," 317671.38126618, 357993.86137939, 352637.93422963,\n"," 908358.15173798, 288551.8042999 , 398779.94006055,\n"," 279465.70834759, 310024.57586448, 367940.58322895,\n"," 336039.07916333, 295296.8610478 , 395408.55510658,\n"," 289706.87506509, 461286.74212482, 959007.7502354 ,\n"," 671918.16381992, 357151.93260828, 573837.44243868,\n"," 286071.41108258, 453635.41762516, 294033.30766019,\n"," 430106.50994353, 361819.52362922, 280070.72529348,\n"," 820481.6050142 , 349767.60269709, 364114.92097912,\n"," 262468.15984629, 301183.86181458, 297937.65284535,\n"," 285306.27863261, 393955.0865278 , 666659.89980777,\n"," 560179.02643777, 440551.36965458, 544315.22105819,\n"," 460711.80794218, 281978.75424428, 380105.90610726,\n"," 501187.31454538, 343001.78445802, 567830.35093743,\n"," 262544.39001514, 332442.95664849, 703770.99332145,\n"," 369470.84812889, 494101.3824478 , 273562.29729465,\n"," 180666.17730277, 452295.35099255, 331304.51667796,\n"," 453635.41762516, 323108.3407589 , 507194.68912278,\n"," 326474.92353875, 334772.89329194, 335044.40697838,\n"," 240054.29816025, 562052.51609502, 274404.22606576,\n"," 375397.37008062, 253585.25133645, 311900.23521207,\n"," 365811.99017143, 339834.65864991, 395408.55510658,\n"," 567728.27402715, 336238.53613507, 490526.69290172,\n"," 257086.66903124, 385858.46036054, 344082.22859239,\n"," 533220.80053368, 295941.33661099, 220577.95997966,\n"," 291229.76787478, 200262.6085879 , 281213.62179431,\n"," 338640.52949322, 267288.49428108, 439786.23720462,\n"," 400076.14612753, 301183.86181458, 479730.95326697,\n"," 319470.24429261, 470581.73347059, 336354.39084773,\n"," 491317.10594082, 354168.19912956, 369551.88047185,\n"," 435462.4370933 , 514271.0794398 , 331214.22563058,\n"," 234999.90489251, 240207.32465024, 395408.55510658,\n"," 305290.01337911, 265336.03861235, 349500.60810862,\n"," 315911.57663126, 448585.54345538, 310063.91733215,\n"," 414803.86094421, 521922.40393947, 768450.42872618,\n"," 285306.27863261, 414228.92676157, 408188.43671135,\n"," 262917.91567413, 530071.86630062, 284993.07170081,\n"," 354168.19912956, 350852.56592942, 341174.72528252,\n"," 174670.0129817 , 346185.25798463, 308617.25469129,\n"," 319206.16526408, 479496.61135786, 285306.27863261,\n"," 338832.89745087, 238677.05975031, 300193.70872759,\n"," 284350.94791532, 312129.77494706, 288864.94629397,\n"," 447136.31089841, 468759.4764692 , 311243.98561031,\n"," 773841.17824564, 309069.24514719, 311818.91979295,\n"," 303300.6690092 , 249129.2915516 , 317026.62262684,\n"," 270578.56381593, 374826.77527865, 317632.03979852,\n"," 218540.23357609, 336303.15819187, 364613.05884061,\n"," 419438.51620964, 348842.0716669 , 300494.95953345,\n"," 245456.65579176, 632191.76778196, 342245.91071247,\n"," 321241.94011573, 345941.94044726, 654441.17458326,\n"," 594917.92628041, 403059.87960624, 295368.85519483,\n"," 287144.48312671, 504057.36300177, 259834.05683704,\n"," 356196.60189099, 671431.17127702, 221915.85692194,\n"," 266766.67936848, 862139.34958591, 253061.54980967,\n"," 278229.88831559, 360787.39659078, 819749.12524361,\n"," 225938.68930354, 337453.4893506 , 417419.08907647,\n"," 433477.61182135, 428415.84646337, 369470.84812889,\n"," 644948.32980378, 369778.78772305, 486728.1978552 ,\n"," 220003.02579702, 372225.04187261, 533707.33028312,\n"," 268312.96615313, 351337.20906469, 266766.67936848,\n"," 433665.17760489, 291427.33823234, 681260.15179974,\n"," 386155.25463611, 361819.52362922, 378283.64910587,\n"," 312584.05224292, 262442.87925716, 347027.18675575,\n"," 388599.15937804, 330653.06925032, 331214.22563058,\n"," 392424.82162787, 581111.00288747, 510178.4226015 ,\n"," 638681.61580429, 273562.29729465, 332934.68879784,\n"," 370402.78487122, 251183.25797831, 454520.92388575,\n"," 327814.99017136, 317446.36062915, 270745.3681083 ,\n"," 568020.54920476, 1041637.53573378, 445984.0931255 ,\n"," 246474.72195167, 353326.27035845, 456478.01580208,\n"," 268245.71161255, 476014.4569415 , 305276.23557673,\n"," 590784.32443641, 441316.50210455, 265910.97279499,\n"," 319470.24429261, 266451.36768408, 331214.22563058,\n"," 327784.90740811, 319470.24429261, 244403.66193686,\n"," 252780.99555724, 268449.97075841, 912139.95342218,\n"," 430604.64780502, 536459.92048882, 1156407.40322869,\n"," 395408.55510658, 221600.76337596, 327898.59243044,\n"," 237907.12512623, 498752.66850787, 468835.9897142 ,\n"," 350852.56592942, 300033.9934493 , 232365.80188326,\n"," 533897.52855045, 232365.80188326, 369329.42975094,\n"," -118069.19958188, 317722.33084589, 323601.95952243,\n"," 369203.85354041, 268053.34365489, 1051697.65952951,\n"," 254248.58995229, 303300.6690092 , 273638.81053964,\n"," 244461.9836068 , 258111.42397945, 388332.16478956,\n"," 429074.38290509, 536459.92048882, 800353.81940598,\n"," 298918.26415178, 407917.66889452, 388332.16478956,\n"," 414613.66267689, 1262607.50420783, 369329.42975094,\n"," 319129.65201908, 334197.9591093 , 286263.77904024,\n"," 307993.25754312, 741174.54173005, 491064.17223088,\n"," 298429.10191855, 292957.60313228, 315911.57663126,\n"," 327478.85442812, 451544.27942111, 317135.7885512 ,\n"," 724682.50318048, 509137.53807322, 361833.3014316 ,\n"," 693810.21059336, 582168.1274389 , 212609.37224369,\n"," 260216.62306202, 710680.29626995, 264840.07044119,\n"," 300877.52575844, 309268.70211893, 389929.9023685 ,\n"," 464347.27192468, 347409.46990458, 693810.21059336,\n"," 468363.13244184, 427977.91688601, 251373.45624563,\n"," 427817.80138193, 352408.11141849, 728508.16543031,\n"," 749166.7415794 , 558648.76153784, 450512.15238267,\n"," 571124.93957025, 592161.2797702 , 418937.46278821,\n"," 319398.53322173, 415378.79512685, 600960.30294481,\n"," 263047.6131269 , 364648.06092761, 325259.97032322,\n"," 589476.22718124, 599471.54920288, 983410.6732152 ,\n"," 405432.07327729, 442158.14779951, 491279.65108734,\n"," 636692.27143438, 311900.23521207, 186643.53405465,\n"," 454252.04268309, 348902.56302718, 335848.88089601,\n"," 377701.62590915, 377701.62590915, 353370.41400023,\n"," 376477.41398921, 560336.57202573, 556969.98924588,\n"," 402990.3382257 , 568449.1456857 , 448323.35104102,\n"," 517259.61509264, 688264.08517628, 606585.11129723,\n"," 1137012.09739106, 327010.51625373, 361028.82751397,\n"," 628428.55789859, 413554.08535898, 341098.21203752,\n"," 401415.92968398, 455318.42593893, 1619425.93740436,\n"," 451114.99963823, 267139.98688905, 342658.5597007 ,\n"," 304976.87138504, 438573.91647287, 304976.87138504,\n"," 392508.02366116, 458652.63911557, 547637.54304662,\n"," 524873.76781497, 508805.98636568, 382751.50007893,\n"," 366338.32418199, 645108.72838401, 532942.19783316])"]},"execution_count":231,"metadata":{},"output_type":"execute_result"}],"source":["model1.predict(df_test)"]},{"cell_type":"markdown","metadata":{},"source":["Saving the model to file"]},{"cell_type":"code","execution_count":233,"metadata":{},"outputs":[{"data":{"text/plain":["['ridge_model.sav']"]},"execution_count":233,"metadata":{},"output_type":"execute_result"}],"source":["filename = 'ridge_model.sav'\n","joblib.dump(model1, filename)"]}],"metadata":{"colab":{"authorship_tag":"ABX9TyMI6m3bAQGO+zYnw6aWIlMe","provenance":[],"toc_visible":true},"kernelspec":{"display_name":"Python 3","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"}},"nbformat":4,"nbformat_minor":0} +{"cells":[{"cell_type":"code","execution_count":232,"metadata":{"executionInfo":{"elapsed":422,"status":"ok","timestamp":1696951840697,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"veKEtGweNaXi"},"outputs":[],"source":["import pandas as pd\n","import numpy as np\n","import joblib\n"]},{"cell_type":"code","execution_count":191,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":4,"status":"ok","timestamp":1696952151344,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"w7poi-MONhxI","outputId":"379c3cbe-96bc-4d7e-d27f-dd56d02a817b"},"outputs":[],"source":["df_train = pd.read_csv('train.tsv', sep='\\t', header=None)"]},{"cell_type":"code","execution_count":192,"metadata":{"executionInfo":{"elapsed":226,"status":"ok","timestamp":1696952356655,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"8vT9n8oCPIhS"},"outputs":[],"source":["pd.set_option('display.max_columns', 500)"]},{"cell_type":"code","execution_count":193,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":643},"executionInfo":{"elapsed":254,"status":"ok","timestamp":1696952363298,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"hbfWxhoOOeQH","outputId":"3a4608d9-8d37-47c3-b28e-d64be0c43e2d"},"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"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \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...
1314900.0do wykończeniaNaNpełna własność7392https://www.otodom.pl/oferta/urokliwe-mieszkan...2NaN42.60pierwotny2.0blokNaNNaNUrokliwe mieszkanie 2 pokojowe Strzeszyn1NaNgazoweplastikoweNaNNaNNaNcegłaKameralne 2 pokojowe mieszkanie z aneksem kuc...NaNtelewizja kablowa, internet, telefon, drzwi / ...
2249000.0do remontu300 złpełna własność5621https://www.otodom.pl/oferta/mieszkanie-do-rem...2NaN44.30wtórny4.0blokNaNNaNMieszkanie do remontu ul. Klonowa, blisko tramwaj2NaNmiejskieplastikowe1960.0NaN2019-06-30cegłaOferta bezpośrednio od właściciela - bez pośr...NaNtelewizja kablowa, internet, telefon, domofon ...
3419000.0do zamieszkania490 złpełna własność4761https://www.otodom.pl/oferta/w-szeregowcu-4-po...4NaN88wtórny3.0szeregowiecNaNNaNW szeregowcu 4 pokoje z garażem1NaNgazoweplastikoweNaNNaNNaNcegłaDrodzy Państwo Zapraszam do zapoznania się z ...NaNtelewizja kablowa, internet, zmywarka, lodówka...
4499000.0NaN850 złNaN6481https://www.otodom.pl/oferta/komfortowe-przest...3NaN77wtórny16.0blokNaNNaNKomfortowe,Przestronne,3Pokoje, Armii Krajowej!!!7NaNNaNplastikoweNaNNaNNaNNaNBiuro Immohouse ma przyjemność proponować do ...NaNbalkon, piwnica, winda
\n","
"],"text/plain":[" 0 1 2 3 4 \\\n","0 309000.0 do zamieszkania 390 zł spółdzielcze własnościowe 7113 \n","1 314900.0 do wykończenia NaN pełna własność 7392 \n","2 249000.0 do remontu 300 zł pełna własność 5621 \n","3 419000.0 do zamieszkania 490 zł pełna własność 4761 \n","4 499000.0 NaN 850 zł NaN 6481 \n","\n"," 5 6 7 8 9 \\\n","0 https://www.otodom.pl/oferta/niezalezny-uklad-... 2 NaN 43.44 wtórny \n","1 https://www.otodom.pl/oferta/urokliwe-mieszkan... 2 NaN 42.60 pierwotny \n","2 https://www.otodom.pl/oferta/mieszkanie-do-rem... 2 NaN 44.30 wtórny \n","3 https://www.otodom.pl/oferta/w-szeregowcu-4-po... 4 NaN 88 wtórny \n","4 https://www.otodom.pl/oferta/komfortowe-przest... 3 NaN 77 wtórny \n","\n"," 10 11 12 13 \\\n","0 4.0 blok NaN NaN \n","1 2.0 blok NaN NaN \n","2 4.0 blok NaN NaN \n","3 3.0 szeregowiec NaN NaN \n","4 16.0 blok NaN NaN \n","\n"," 14 15 16 17 \\\n","0 Niezależny Układ W Nowoczesnym Wydaniu 1 NaN gazowe \n","1 Urokliwe mieszkanie 2 pokojowe Strzeszyn 1 NaN gazowe \n","2 Mieszkanie do remontu ul. Klonowa, blisko tramwaj 2 NaN miejskie \n","3 W szeregowcu 4 pokoje z garażem 1 NaN gazowe \n","4 Komfortowe,Przestronne,3Pokoje, Armii Krajowej!!! 7 NaN NaN \n","\n"," 18 19 20 21 22 \\\n","0 plastikowe NaN NaN NaN cegła \n","1 plastikowe NaN NaN NaN cegła \n","2 plastikowe 1960.0 NaN 2019-06-30 cegła \n","3 plastikowe NaN NaN NaN cegła \n","4 plastikowe NaN NaN NaN NaN \n","\n"," 23 24 \\\n","0 Polecamy na sprzedaż dwupokojowe mieszkanie p... NaN \n","1 Kameralne 2 pokojowe mieszkanie z aneksem kuc... NaN \n","2 Oferta bezpośrednio od właściciela - bez pośr... NaN \n","3 Drodzy Państwo Zapraszam do zapoznania się z ... NaN \n","4 Biuro Immohouse ma przyjemność proponować do ... NaN \n","\n"," 25 \n","0 telewizja kablowa, internet, meble, piwnica, g... \n","1 telewizja kablowa, internet, telefon, drzwi / ... \n","2 telewizja kablowa, internet, telefon, domofon ... \n","3 telewizja kablowa, internet, zmywarka, lodówka... \n","4 balkon, piwnica, winda "]},"execution_count":193,"metadata":{},"output_type":"execute_result"}],"source":["df_train.head()"]},{"cell_type":"markdown","metadata":{"id":"nt0TOLw5RAqS"},"source":["1,2,6, 8, 9 - to bedziemy w aplikacji używać\n"]},{"cell_type":"code","execution_count":194,"metadata":{},"outputs":[],"source":["df_train = df_train.iloc[:, [0, 1, 2, 6, 8, 9]]"]},{"cell_type":"code","execution_count":195,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1696952402833,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"QdXwQzPsOza0","outputId":"d5d231f0-da54-432f-9bd6-454d4063eaff"},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 2547 entries, 0 to 2546\n","Data columns (total 6 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 0 2547 non-null float64\n"," 1 1 1519 non-null object \n"," 2 2 929 non-null object \n"," 3 6 2547 non-null object \n"," 4 8 2547 non-null object \n"," 5 9 2547 non-null object \n","dtypes: float64(1), object(5)\n","memory usage: 119.5+ KB\n"]}],"source":["df_train.info()"]},{"cell_type":"code","execution_count":196,"metadata":{},"outputs":[],"source":["df_train.rename(columns={0: \"cena m\", 1: \"stan\", 2: \"czynsz\", 6: \"l pokoi\", 8: \"metraż\", 9: \"rynek\"}, inplace=True)"]},{"cell_type":"code","execution_count":197,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 2547 entries, 0 to 2546\n","Data columns (total 6 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 cena m 2547 non-null float64\n"," 1 stan 1519 non-null object \n"," 2 czynsz 929 non-null object \n"," 3 l pokoi 2547 non-null object \n"," 4 metraż 2547 non-null object \n"," 5 rynek 2547 non-null object \n","dtypes: float64(1), object(5)\n","memory usage: 119.5+ KB\n"]}],"source":["df_train.info()"]},{"cell_type":"markdown","metadata":{},"source":["Usunięcie kolumn, w których jest dużo pustych wartości"]},{"cell_type":"code","execution_count":198,"metadata":{"executionInfo":{"elapsed":249,"status":"ok","timestamp":1696953612119,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"x6jB9brYRSTJ"},"outputs":[],"source":["df_train.drop(columns = ['czynsz'], axis=1, inplace=True)"]},{"cell_type":"code","execution_count":199,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":608},"executionInfo":{"elapsed":339,"status":"ok","timestamp":1696953613765,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"NIzvOY2BQqTK","outputId":"ceaa0534-470a-4296-f51c-97f1b9904190"},"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","
cena mstanl pokoimetrażrynek
0309000.0do zamieszkania243.44wtórny
1314900.0do wykończenia242.60pierwotny
2249000.0do remontu244.30wtórny
3419000.0do zamieszkania488wtórny
4499000.0NaN377wtórny
\n","
"],"text/plain":[" cena m stan l pokoi metraż rynek\n","0 309000.0 do zamieszkania 2 43.44 wtórny\n","1 314900.0 do wykończenia 2 42.60 pierwotny\n","2 249000.0 do remontu 2 44.30 wtórny\n","3 419000.0 do zamieszkania 4 88 wtórny\n","4 499000.0 NaN 3 77 wtórny"]},"execution_count":199,"metadata":{},"output_type":"execute_result"}],"source":["df_train.head()"]},{"cell_type":"markdown","metadata":{},"source":["Uzupełnianie braków w danych "]},{"cell_type":"code","execution_count":200,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":3,"status":"ok","timestamp":1696953649491,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"qNqxEsnNUZcH","outputId":"33ce3384-6b79-4795-c582-0d8fd8457943"},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 2547 entries, 0 to 2546\n","Data columns (total 5 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 cena m 2547 non-null float64\n"," 1 stan 1519 non-null object \n"," 2 l pokoi 2547 non-null object \n"," 3 metraż 2547 non-null object \n"," 4 rynek 2547 non-null object \n","dtypes: float64(1), object(4)\n","memory usage: 99.6+ KB\n"]}],"source":["df_train.info()"]},{"cell_type":"code","execution_count":201,"metadata":{"executionInfo":{"elapsed":245,"status":"ok","timestamp":1696953995554,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"5BTDYi_xUdGF"},"outputs":[],"source":["df_train['stan'].fillna('brak info', inplace=True)"]},{"cell_type":"code","execution_count":202,"metadata":{},"outputs":[],"source":["df_train = df_train[df_train['metraż'] != \"6 909\"]"]},{"cell_type":"code","execution_count":203,"metadata":{},"outputs":[],"source":["df_train = df_train[df_train['l pokoi'] != \"więcej niż 10\"]"]},{"cell_type":"code","execution_count":204,"metadata":{},"outputs":[],"source":["df_train['l pokoi'] = pd.to_numeric(df_train['l pokoi'])"]},{"cell_type":"code","execution_count":205,"metadata":{},"outputs":[],"source":["df_train['metraż'] = pd.to_numeric(df_train['metraż'])"]},{"cell_type":"code","execution_count":206,"metadata":{},"outputs":[],"source":["X_train = df_train.drop(columns = [\"cena m\"])\n","y_train = df_train[\"cena m\"]"]},{"cell_type":"code","execution_count":207,"metadata":{"executionInfo":{"elapsed":240,"status":"ok","timestamp":1696955504933,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"LW2CpZn6V5sl"},"outputs":[],"source":["number_cols = X_train.select_dtypes(exclude=[object]).columns\n","object_cols = X_train.select_dtypes(include=[object]).columns"]},{"cell_type":"code","execution_count":208,"metadata":{"executionInfo":{"elapsed":6,"status":"ok","timestamp":1696954577003,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"DJOcANTvXMjl"},"outputs":[],"source":["from sklearn.compose import ColumnTransformer\n","from sklearn.preprocessing import OneHotEncoder\n","from sklearn.preprocessing import StandardScaler\n","from sklearn.pipeline import make_pipeline"]},{"cell_type":"code","execution_count":209,"metadata":{"executionInfo":{"elapsed":240,"status":"ok","timestamp":1696955508626,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"5nvY10OHXjEw"},"outputs":[],"source":["ct = ColumnTransformer([\n"," (number_cols, StandardScaler()),\n"," (object_cols, OneHotEncoder())\n"," ],remainder='passthrough')\n"]},{"cell_type":"code","execution_count":210,"metadata":{"executionInfo":{"elapsed":529,"status":"ok","timestamp":1696954626952,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"wcGvPEZzYDPZ"},"outputs":[],"source":["from sklearn.linear_model import Ridge"]},{"cell_type":"code","execution_count":211,"metadata":{"executionInfo":{"elapsed":343,"status":"ok","timestamp":1696955511401,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"4z3w4bzbYseK"},"outputs":[],"source":["scaler = StandardScaler()\n","encoder = OneHotEncoder()\n","# putting numeric columns to scaler and categorical to encoder\n","num_transformer = make_pipeline(scaler)\n","cat_transformer = make_pipeline(encoder)\n","\n","# getting together our scaler and encoder with preprocessor\n","preprocessor = ColumnTransformer(\n"," transformers=[('num', num_transformer, number_cols),\n"," ('cat', cat_transformer, object_cols)])"]},{"cell_type":"code","execution_count":212,"metadata":{"executionInfo":{"elapsed":354,"status":"ok","timestamp":1696955513049,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"QXvbFrmXYLtR"},"outputs":[],"source":["clf = Ridge(alpha=1.0)"]},{"cell_type":"code","execution_count":213,"metadata":{"executionInfo":{"elapsed":428,"status":"ok","timestamp":1696955515987,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"pytR_osgX5Lb"},"outputs":[],"source":["model1 = make_pipeline(preprocessor, clf)"]},{"cell_type":"code","execution_count":214,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":608},"executionInfo":{"elapsed":233,"status":"ok","timestamp":1696955309653,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"vzR7OGK8Z-lD","outputId":"6aa1623d-b9fb-46ad-a200-f185708542ac"},"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","
stanl pokoimetrażrynek
0do zamieszkania243.44wtórny
1do wykończenia242.60pierwotny
2do remontu244.30wtórny
3do zamieszkania488.00wtórny
4brak info377.00wtórny
\n","
"],"text/plain":[" stan l pokoi metraż rynek\n","0 do zamieszkania 2 43.44 wtórny\n","1 do wykończenia 2 42.60 pierwotny\n","2 do remontu 2 44.30 wtórny\n","3 do zamieszkania 4 88.00 wtórny\n","4 brak info 3 77.00 wtórny"]},"execution_count":214,"metadata":{},"output_type":"execute_result"}],"source":["X_train.head()"]},{"cell_type":"code","execution_count":215,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":7,"status":"ok","timestamp":1696955419804,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"vcg92-RtbLSH","outputId":"457f8462-c2d8-4721-a19a-fb855998472c"},"outputs":[{"data":{"text/plain":["0 309000.0\n","1 314900.0\n","2 249000.0\n","3 419000.0\n","4 499000.0\n"," ... \n","2541 383680.0\n","2542 507600.0\n","2543 342400.0\n","2544 335000.0\n","2545 260000.0\n","Name: cena m, Length: 2540, dtype: float64"]},"execution_count":215,"metadata":{},"output_type":"execute_result"}],"source":["y_train"]},{"cell_type":"markdown","metadata":{"id":"GY_ZQICKc__t"},"source":["## Model Ridge - regresja liniowa"]},{"cell_type":"code","execution_count":216,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":191},"executionInfo":{"elapsed":236,"status":"ok","timestamp":1696955526976,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"cFvgBYD5YYz7","outputId":"008e021f-cb56-4458-99e8-ca95df32e68d"},"outputs":[{"data":{"text/html":["
Pipeline(steps=[('columntransformer',\n","                 ColumnTransformer(transformers=[('num',\n","                                                  Pipeline(steps=[('standardscaler',\n","                                                                   StandardScaler())]),\n","                                                  Index(['l pokoi', 'metraż'], dtype='object')),\n","                                                 ('cat',\n","                                                  Pipeline(steps=[('onehotencoder',\n","                                                                   OneHotEncoder())]),\n","                                                  Index(['stan', 'rynek'], dtype='object'))])),\n","                ('ridge', Ridge())])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
"],"text/plain":["Pipeline(steps=[('columntransformer',\n"," ColumnTransformer(transformers=[('num',\n"," Pipeline(steps=[('standardscaler',\n"," StandardScaler())]),\n"," Index(['l pokoi', 'metraż'], dtype='object')),\n"," ('cat',\n"," Pipeline(steps=[('onehotencoder',\n"," OneHotEncoder())]),\n"," Index(['stan', 'rynek'], dtype='object'))])),\n"," ('ridge', Ridge())])"]},"execution_count":216,"metadata":{},"output_type":"execute_result"}],"source":["model1.fit(X_train, y_train)"]},{"cell_type":"code","execution_count":217,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":451,"status":"ok","timestamp":1696955647207,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"M7X8ScQobnwG","outputId":"a30f27eb-2e34-4a91-fae0-a9ab53505322"},"outputs":[],"source":["df_test = pd.read_csv('in.tsv', sep='\\t', header=None)"]},{"cell_type":"code","execution_count":218,"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":573},"executionInfo":{"elapsed":5,"status":"ok","timestamp":1696955652118,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"x3qN4TMKcDfL","outputId":"ed2fa477-65e6-494e-9423-de6894c47ef8"},"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"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n"," \n","
0123456789101112131415161718192021222324
0do zamieszkania250 złpełna własność6311https://www.otodom.pl/oferta/idealne-mieszkani...3NaN59.10wtórny4.0blokNaNNaNidealne mieszkanie do zamieszkania od zaraz2NaNmiejskieplastikoweNaNNaNNaNwielka płytaZamieszkaj od zaraz – idealna lokalizacja OFE...NaNtelewizja kablowa, internet, telefon, domofon ...
1do zamieszkaniaNaNpełna własność7868https://www.otodom.pl/oferta/2-pokoje-38m2-po-...2NaN38.00wtórny12.0blokNaNNaN2 pokoje / 38m2 / po remoncie / Winogrady4NaNinneplastikoweNaNNaNNaNNaNNa sprzedaż mieszkanie dwupokojowe na osiedlu...NaNbalkon
2do zamieszkania650 złpełna własność5717https://www.otodom.pl/oferta/3-pokoje-na-jezyc...3NaN63.84wtórny4.0blokNaNNaN3 pokoje na Jeżycach blisko Rusałki4NaNmiejskieplastikowe1958.0NaNNaNcegła!! Oferta dostępna tylko u nas !! Polecam ofe...NaNtelewizja kablowa, internet, telefon, piwnica,...
3do zamieszkania359 złspółdzielcze własnościowe7380https://www.otodom.pl/oferta/uniwersytet-przyr...4NaN50.00wtórny10.0blokNaNNaNUniwersytet Przyrodniczy - 4 pokoje - ROI 8-10%10NaNmiejskieplastikowe1975.0NaN2019-06-30wielka płytaOferta  bezpośrednio od właściciela  - bez po...NaNtelewizja kablowa, internet, telefon, drzwi / ...
4NaNNaNNaN7373https://www.otodom.pl/oferta/mieszkanie-blisko...3NaN65.62pierwotny3.0NaNNaNNaNMieszkanie blisko centrum w kameralnej okolicy.1NaNNaNNaN2020.0NaN2020-01-01NaNMIESZKANIE 3-POKOJOWE O POW.65,62M2 Mieszkani...NaNgaraż/miejsce parkingowe, taras, pom. użytkowe
\n","
"],"text/plain":[" 0 1 2 3 \\\n","0 do zamieszkania 250 zł pełna własność 6311 \n","1 do zamieszkania NaN pełna własność 7868 \n","2 do zamieszkania 650 zł pełna własność 5717 \n","3 do zamieszkania 359 zł spółdzielcze własnościowe 7380 \n","4 NaN NaN NaN 7373 \n","\n"," 4 5 6 7 \\\n","0 https://www.otodom.pl/oferta/idealne-mieszkani... 3 NaN 59.10 \n","1 https://www.otodom.pl/oferta/2-pokoje-38m2-po-... 2 NaN 38.00 \n","2 https://www.otodom.pl/oferta/3-pokoje-na-jezyc... 3 NaN 63.84 \n","3 https://www.otodom.pl/oferta/uniwersytet-przyr... 4 NaN 50.00 \n","4 https://www.otodom.pl/oferta/mieszkanie-blisko... 3 NaN 65.62 \n","\n"," 8 9 10 11 12 \\\n","0 wtórny 4.0 blok NaN NaN \n","1 wtórny 12.0 blok NaN NaN \n","2 wtórny 4.0 blok NaN NaN \n","3 wtórny 10.0 blok NaN NaN \n","4 pierwotny 3.0 NaN NaN NaN \n","\n"," 13 14 15 16 \\\n","0 idealne mieszkanie do zamieszkania od zaraz 2 NaN miejskie \n","1 2 pokoje / 38m2 / po remoncie / Winogrady 4 NaN inne \n","2 3 pokoje na Jeżycach blisko Rusałki 4 NaN miejskie \n","3 Uniwersytet Przyrodniczy - 4 pokoje - ROI 8-10% 10 NaN miejskie \n","4 Mieszkanie blisko centrum w kameralnej okolicy. 1 NaN NaN \n","\n"," 17 18 19 20 21 \\\n","0 plastikowe NaN NaN NaN wielka płyta \n","1 plastikowe NaN NaN NaN NaN \n","2 plastikowe 1958.0 NaN NaN cegła \n","3 plastikowe 1975.0 NaN 2019-06-30 wielka płyta \n","4 NaN 2020.0 NaN 2020-01-01 NaN \n","\n"," 22 23 \\\n","0 Zamieszkaj od zaraz – idealna lokalizacja OFE... NaN \n","1 Na sprzedaż mieszkanie dwupokojowe na osiedlu... NaN \n","2 !! Oferta dostępna tylko u nas !! Polecam ofe... NaN \n","3 Oferta  bezpośrednio od właściciela  - bez po... NaN \n","4 MIESZKANIE 3-POKOJOWE O POW.65,62M2 Mieszkani... NaN \n","\n"," 24 \n","0 telewizja kablowa, internet, telefon, domofon ... \n","1 balkon \n","2 telewizja kablowa, internet, telefon, piwnica,... \n","3 telewizja kablowa, internet, telefon, drzwi / ... \n","4 garaż/miejsce parkingowe, taras, pom. użytkowe "]},"execution_count":218,"metadata":{},"output_type":"execute_result"}],"source":["df_test.head()"]},{"cell_type":"code","execution_count":219,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":244,"status":"ok","timestamp":1696955801209,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"UybULQjXcMbT","outputId":"1bd9cb56-50cf-4040-f797-0d54e0293ef5"},"outputs":[],"source":["y_test = pd.read_csv('expected.tsv', sep='\\t', header=None)"]},{"cell_type":"code","execution_count":220,"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","
stanl pokoimetrażrynek
0do zamieszkania243.44wtórny
1do wykończenia242.60pierwotny
2do remontu244.30wtórny
3do zamieszkania488.00wtórny
4brak info377.00wtórny
...............
2541do wykończenia370.40pierwotny
2542do wykończenia494.00wtórny
2543brak info253.50wtórny
2544brak info355.25wtórny
2545brak info362.00wtórny
\n","

2540 rows × 4 columns

\n","
"],"text/plain":[" stan l pokoi metraż rynek\n","0 do zamieszkania 2 43.44 wtórny\n","1 do wykończenia 2 42.60 pierwotny\n","2 do remontu 2 44.30 wtórny\n","3 do zamieszkania 4 88.00 wtórny\n","4 brak info 3 77.00 wtórny\n","... ... ... ... ...\n","2541 do wykończenia 3 70.40 pierwotny\n","2542 do wykończenia 4 94.00 wtórny\n","2543 brak info 2 53.50 wtórny\n","2544 brak info 3 55.25 wtórny\n","2545 brak info 3 62.00 wtórny\n","\n","[2540 rows x 4 columns]"]},"execution_count":220,"metadata":{},"output_type":"execute_result"}],"source":["X_train"]},{"cell_type":"code","execution_count":221,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":8,"status":"ok","timestamp":1696955946495,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"WMsGxdMwdMM8","outputId":"d2a8f0ac-4051-465e-d43c-e1fb7b9a3034"},"outputs":[],"source":["df_test.rename(columns={0: \"stan\", 1: \"czynsz\", 5: \"l pokoi\", 7: \"metraż\", 8: \"rynek\"}, inplace=True)"]},{"cell_type":"code","execution_count":222,"metadata":{"executionInfo":{"elapsed":226,"status":"ok","timestamp":1696956067214,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"TNHLwq_5daGO"},"outputs":[{"data":{"text/plain":["Index([ 'stan', 'czynsz', 2, 3, 4, 'l pokoi',\n"," 6, 'metraż', 'rynek', 9, 10, 11,\n"," 12, 13, 14, 15, 16, 17,\n"," 18, 19, 20, 21, 22, 23,\n"," 24],\n"," dtype='object')"]},"execution_count":222,"metadata":{},"output_type":"execute_result"}],"source":["df_test.columns"]},{"cell_type":"code","execution_count":223,"metadata":{},"outputs":[],"source":["df_test = df_test[['stan', 'l pokoi', 'metraż', 'rynek']] "]},{"cell_type":"code","execution_count":224,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":6,"status":"ok","timestamp":1696956090162,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"tbcOpXendvZv","outputId":"93eddcd2-b741-4aa6-b185-59c96dc2e833"},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 462 entries, 0 to 461\n","Data columns (total 4 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 stan 275 non-null object \n"," 1 l pokoi 462 non-null int64 \n"," 2 metraż 462 non-null float64\n"," 3 rynek 462 non-null object \n","dtypes: float64(1), int64(1), object(2)\n","memory usage: 14.6+ KB\n"]}],"source":["df_test.info()"]},{"cell_type":"code","execution_count":225,"metadata":{"executionInfo":{"elapsed":323,"status":"ok","timestamp":1696956241887,"user":{"displayName":"Aneta Tlałka","userId":"13389112088336863360"},"user_tz":-120},"id":"j5IFS4YQdKPW"},"outputs":[],"source":["df_test['stan'].fillna('brak info', inplace=True)"]},{"cell_type":"code","execution_count":226,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 462 entries, 0 to 461\n","Data columns (total 4 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 stan 462 non-null object \n"," 1 l pokoi 462 non-null int64 \n"," 2 metraż 462 non-null float64\n"," 3 rynek 462 non-null object \n","dtypes: float64(1), int64(1), object(2)\n","memory usage: 14.6+ KB\n"]}],"source":["df_test.info()"]},{"cell_type":"code","execution_count":227,"metadata":{},"outputs":[{"data":{"text/plain":["0 59.10\n","1 38.00\n","2 63.84\n","3 50.00\n","4 65.62\n"," ... \n","457 72.78\n","458 51.23\n","459 54.16\n","460 90.10\n","461 71.90\n","Name: metraż, Length: 462, dtype: float64"]},"execution_count":227,"metadata":{},"output_type":"execute_result"}],"source":["df_test['metraż']"]},{"cell_type":"code","execution_count":228,"metadata":{},"outputs":[],"source":["df_test.reset_index(drop=True, inplace=True)"]},{"cell_type":"code","execution_count":229,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","RangeIndex: 462 entries, 0 to 461\n","Data columns (total 4 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 stan 462 non-null object \n"," 1 l pokoi 462 non-null int64 \n"," 2 metraż 462 non-null float64\n"," 3 rynek 462 non-null object \n","dtypes: float64(1), int64(1), object(2)\n","memory usage: 14.6+ KB\n"]}],"source":["df_test.info()"]},{"cell_type":"code","execution_count":230,"metadata":{},"outputs":[{"data":{"text/html":["
Pipeline(steps=[('columntransformer',\n","                 ColumnTransformer(transformers=[('num',\n","                                                  Pipeline(steps=[('standardscaler',\n","                                                                   StandardScaler())]),\n","                                                  Index(['l pokoi', 'metraż'], dtype='object')),\n","                                                 ('cat',\n","                                                  Pipeline(steps=[('onehotencoder',\n","                                                                   OneHotEncoder())]),\n","                                                  Index(['stan', 'rynek'], dtype='object'))])),\n","                ('ridge', Ridge())])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
"],"text/plain":["Pipeline(steps=[('columntransformer',\n"," ColumnTransformer(transformers=[('num',\n"," Pipeline(steps=[('standardscaler',\n"," StandardScaler())]),\n"," Index(['l pokoi', 'metraż'], dtype='object')),\n"," ('cat',\n"," Pipeline(steps=[('onehotencoder',\n"," OneHotEncoder())]),\n"," Index(['stan', 'rynek'], dtype='object'))])),\n"," ('ridge', Ridge())])"]},"execution_count":230,"metadata":{},"output_type":"execute_result"}],"source":["model1"]},{"cell_type":"markdown","metadata":{},"source":["Przykład - przewidywanie cen na danych testowych"]},{"cell_type":"code","execution_count":231,"metadata":{},"outputs":[{"data":{"text/plain":["array([ 407917.66889452, 285306.27863261, 444184.94702291,\n"," 299459.05926666, 459271.83408962, 614055.95902743,\n"," 311243.98561031, 361244.58944658, 329238.65906305,\n"," 369470.84812889, 285350.13919824, 329238.65906305,\n"," 420020.53940636, 399085.99304054, 368717.32379097,\n"," 339834.65864991, 335512.74515277, 304524.88092914,\n"," 367036.20209137, 286773.80808993, 354525.20168926,\n"," 282085.35025252, 386303.76202814, 477660.29347794,\n"," 407152.53644455, 490742.17175818, 529758.94244497,\n"," 335044.40697838, 399501.21194489, 431641.29394143,\n"," 331214.22563058, 334772.89329194, 404282.20491201,\n"," 369968.98599038, 392538.22357404, 354476.13872373,\n"," 531690.53563375, 428309.25045513, 298510.41733766,\n"," 551966.54555785, 332974.0302655 , 474293.99377424,\n"," 247049.65613431, 383931.85143325, 546789.20856336,\n"," 438766.28443053, 275556.44383868, 325403.7381088 ,\n"," 319934.12593671, 277654.95413295, 294800.60980049,\n"," 285306.27863261, 283776.01373268, 282811.35937324,\n"," 511210.54963994, 327121.56879228, 335039.88788041,\n"," 638797.47051695, 521922.40393947, 235305.67479634,\n"," 238447.52001532, 465392.89368935, 272046.09327325,\n"," 848434.43816552, 512546.27689188, 382253.07914128,\n"," 781492.5027453 , 531716.09929903, 442847.05008064,\n"," 498968.43044048, 272108.82871587, 275556.44383868,\n"," 307110.38376632, 373296.51037872, 320469.71865169,\n"," 629040.94693472, 456886.14569235, 463535.64405524,\n"," 356361.80264533, 387288.89243253, 249184.65490398,\n"," 305443.0398691 , 312129.77494706, 323562.90113092,\n"," 286773.80808993, 338640.52949322, 265910.97279499,\n"," 414803.86094421, 262352.30513363, 273562.29729465,\n"," 959123.60494806, 476401.54226445, 463695.54142089,\n"," 474293.99377424, 245933.92683679, 276309.90323886,\n"," 95163.71086422, 410945.54601501, 377887.30507851,\n"," 332477.49594204, 374627.25336918, 354168.19912956,\n"," 369968.98599038, 311900.23521207, 275897.03611221,\n"," 272224.40035237, 522497.33812211, 317135.7885512 ,\n"," 317671.38126618, 357993.86137939, 352637.93422963,\n"," 908358.15173798, 288551.8042999 , 398779.94006055,\n"," 279465.70834759, 310024.57586448, 367940.58322895,\n"," 336039.07916333, 295296.8610478 , 395408.55510658,\n"," 289706.87506509, 461286.74212482, 959007.7502354 ,\n"," 671918.16381992, 357151.93260828, 573837.44243868,\n"," 286071.41108258, 453635.41762516, 294033.30766019,\n"," 430106.50994353, 361819.52362922, 280070.72529348,\n"," 820481.6050142 , 349767.60269709, 364114.92097912,\n"," 262468.15984629, 301183.86181458, 297937.65284535,\n"," 285306.27863261, 393955.0865278 , 666659.89980777,\n"," 560179.02643777, 440551.36965458, 544315.22105819,\n"," 460711.80794218, 281978.75424428, 380105.90610726,\n"," 501187.31454538, 343001.78445802, 567830.35093743,\n"," 262544.39001514, 332442.95664849, 703770.99332145,\n"," 369470.84812889, 494101.3824478 , 273562.29729465,\n"," 180666.17730277, 452295.35099255, 331304.51667796,\n"," 453635.41762516, 323108.3407589 , 507194.68912278,\n"," 326474.92353875, 334772.89329194, 335044.40697838,\n"," 240054.29816025, 562052.51609502, 274404.22606576,\n"," 375397.37008062, 253585.25133645, 311900.23521207,\n"," 365811.99017143, 339834.65864991, 395408.55510658,\n"," 567728.27402715, 336238.53613507, 490526.69290172,\n"," 257086.66903124, 385858.46036054, 344082.22859239,\n"," 533220.80053368, 295941.33661099, 220577.95997966,\n"," 291229.76787478, 200262.6085879 , 281213.62179431,\n"," 338640.52949322, 267288.49428108, 439786.23720462,\n"," 400076.14612753, 301183.86181458, 479730.95326697,\n"," 319470.24429261, 470581.73347059, 336354.39084773,\n"," 491317.10594082, 354168.19912956, 369551.88047185,\n"," 435462.4370933 , 514271.0794398 , 331214.22563058,\n"," 234999.90489251, 240207.32465024, 395408.55510658,\n"," 305290.01337911, 265336.03861235, 349500.60810862,\n"," 315911.57663126, 448585.54345538, 310063.91733215,\n"," 414803.86094421, 521922.40393947, 768450.42872618,\n"," 285306.27863261, 414228.92676157, 408188.43671135,\n"," 262917.91567413, 530071.86630062, 284993.07170081,\n"," 354168.19912956, 350852.56592942, 341174.72528252,\n"," 174670.0129817 , 346185.25798463, 308617.25469129,\n"," 319206.16526408, 479496.61135786, 285306.27863261,\n"," 338832.89745087, 238677.05975031, 300193.70872759,\n"," 284350.94791532, 312129.77494706, 288864.94629397,\n"," 447136.31089841, 468759.4764692 , 311243.98561031,\n"," 773841.17824564, 309069.24514719, 311818.91979295,\n"," 303300.6690092 , 249129.2915516 , 317026.62262684,\n"," 270578.56381593, 374826.77527865, 317632.03979852,\n"," 218540.23357609, 336303.15819187, 364613.05884061,\n"," 419438.51620964, 348842.0716669 , 300494.95953345,\n"," 245456.65579176, 632191.76778196, 342245.91071247,\n"," 321241.94011573, 345941.94044726, 654441.17458326,\n"," 594917.92628041, 403059.87960624, 295368.85519483,\n"," 287144.48312671, 504057.36300177, 259834.05683704,\n"," 356196.60189099, 671431.17127702, 221915.85692194,\n"," 266766.67936848, 862139.34958591, 253061.54980967,\n"," 278229.88831559, 360787.39659078, 819749.12524361,\n"," 225938.68930354, 337453.4893506 , 417419.08907647,\n"," 433477.61182135, 428415.84646337, 369470.84812889,\n"," 644948.32980378, 369778.78772305, 486728.1978552 ,\n"," 220003.02579702, 372225.04187261, 533707.33028312,\n"," 268312.96615313, 351337.20906469, 266766.67936848,\n"," 433665.17760489, 291427.33823234, 681260.15179974,\n"," 386155.25463611, 361819.52362922, 378283.64910587,\n"," 312584.05224292, 262442.87925716, 347027.18675575,\n"," 388599.15937804, 330653.06925032, 331214.22563058,\n"," 392424.82162787, 581111.00288747, 510178.4226015 ,\n"," 638681.61580429, 273562.29729465, 332934.68879784,\n"," 370402.78487122, 251183.25797831, 454520.92388575,\n"," 327814.99017136, 317446.36062915, 270745.3681083 ,\n"," 568020.54920476, 1041637.53573378, 445984.0931255 ,\n"," 246474.72195167, 353326.27035845, 456478.01580208,\n"," 268245.71161255, 476014.4569415 , 305276.23557673,\n"," 590784.32443641, 441316.50210455, 265910.97279499,\n"," 319470.24429261, 266451.36768408, 331214.22563058,\n"," 327784.90740811, 319470.24429261, 244403.66193686,\n"," 252780.99555724, 268449.97075841, 912139.95342218,\n"," 430604.64780502, 536459.92048882, 1156407.40322869,\n"," 395408.55510658, 221600.76337596, 327898.59243044,\n"," 237907.12512623, 498752.66850787, 468835.9897142 ,\n"," 350852.56592942, 300033.9934493 , 232365.80188326,\n"," 533897.52855045, 232365.80188326, 369329.42975094,\n"," -118069.19958188, 317722.33084589, 323601.95952243,\n"," 369203.85354041, 268053.34365489, 1051697.65952951,\n"," 254248.58995229, 303300.6690092 , 273638.81053964,\n"," 244461.9836068 , 258111.42397945, 388332.16478956,\n"," 429074.38290509, 536459.92048882, 800353.81940598,\n"," 298918.26415178, 407917.66889452, 388332.16478956,\n"," 414613.66267689, 1262607.50420783, 369329.42975094,\n"," 319129.65201908, 334197.9591093 , 286263.77904024,\n"," 307993.25754312, 741174.54173005, 491064.17223088,\n"," 298429.10191855, 292957.60313228, 315911.57663126,\n"," 327478.85442812, 451544.27942111, 317135.7885512 ,\n"," 724682.50318048, 509137.53807322, 361833.3014316 ,\n"," 693810.21059336, 582168.1274389 , 212609.37224369,\n"," 260216.62306202, 710680.29626995, 264840.07044119,\n"," 300877.52575844, 309268.70211893, 389929.9023685 ,\n"," 464347.27192468, 347409.46990458, 693810.21059336,\n"," 468363.13244184, 427977.91688601, 251373.45624563,\n"," 427817.80138193, 352408.11141849, 728508.16543031,\n"," 749166.7415794 , 558648.76153784, 450512.15238267,\n"," 571124.93957025, 592161.2797702 , 418937.46278821,\n"," 319398.53322173, 415378.79512685, 600960.30294481,\n"," 263047.6131269 , 364648.06092761, 325259.97032322,\n"," 589476.22718124, 599471.54920288, 983410.6732152 ,\n"," 405432.07327729, 442158.14779951, 491279.65108734,\n"," 636692.27143438, 311900.23521207, 186643.53405465,\n"," 454252.04268309, 348902.56302718, 335848.88089601,\n"," 377701.62590915, 377701.62590915, 353370.41400023,\n"," 376477.41398921, 560336.57202573, 556969.98924588,\n"," 402990.3382257 , 568449.1456857 , 448323.35104102,\n"," 517259.61509264, 688264.08517628, 606585.11129723,\n"," 1137012.09739106, 327010.51625373, 361028.82751397,\n"," 628428.55789859, 413554.08535898, 341098.21203752,\n"," 401415.92968398, 455318.42593893, 1619425.93740436,\n"," 451114.99963823, 267139.98688905, 342658.5597007 ,\n"," 304976.87138504, 438573.91647287, 304976.87138504,\n"," 392508.02366116, 458652.63911557, 547637.54304662,\n"," 524873.76781497, 508805.98636568, 382751.50007893,\n"," 366338.32418199, 645108.72838401, 532942.19783316])"]},"execution_count":231,"metadata":{},"output_type":"execute_result"}],"source":["model1.predict(df_test)"]},{"cell_type":"code","execution_count":234,"metadata":{},"outputs":[{"data":{"text/plain":["Index(['stan', 'l pokoi', 'metraż', 'rynek'], dtype='object')"]},"execution_count":234,"metadata":{},"output_type":"execute_result"}],"source":["df_test.columns"]},{"cell_type":"code","execution_count":237,"metadata":{},"outputs":[{"data":{"text/plain":["array(['wtórny', 'pierwotny'], dtype=object)"]},"execution_count":237,"metadata":{},"output_type":"execute_result"}],"source":["X_train['rynek'].unique()"]},{"cell_type":"markdown","metadata":{},"source":["Saving the model to file"]},{"cell_type":"code","execution_count":233,"metadata":{},"outputs":[{"data":{"text/plain":["['ridge_model.sav']"]},"execution_count":233,"metadata":{},"output_type":"execute_result"}],"source":["filename = 'ridge_model.sav'\n","joblib.dump(model1, filename)"]}],"metadata":{"colab":{"authorship_tag":"ABX9TyMI6m3bAQGO+zYnw6aWIlMe","provenance":[],"toc_visible":true},"kernelspec":{"display_name":"Python 3","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"}},"nbformat":4,"nbformat_minor":0}