From f6e8f0710a122085e4297e2cb4ade6157f2ec99d Mon Sep 17 00:00:00 2001 From: Szymon Obst Date: Tue, 17 Oct 2023 18:50:02 +0200 Subject: [PATCH] integracja z gui --- Gui.py | 79 +++++++++++++++++++++++ SysInf.ipynb | 164 +++++++++++++++++++++++++---------------------- mieszkania5 | 1 + mieszkania_model | Bin 0 -> 572 bytes model.py | 0 5 files changed, 168 insertions(+), 76 deletions(-) create mode 100644 Gui.py create mode 160000 mieszkania5 create mode 100644 mieszkania_model create mode 100644 model.py diff --git a/Gui.py b/Gui.py new file mode 100644 index 0000000..9b1074e --- /dev/null +++ b/Gui.py @@ -0,0 +1,79 @@ +# Import Module +from tkinter import * +import pickle +import pandas as pd +import numpy as np + +#Styl +tlo = "grey" +guziki = "#60839D" + +# Create Object +root = Tk() +root.geometry('1000x600') +root.configure(bg=tlo) + +def update(): + dane = [address1.__getattribute__,address2.__getattribute__,address3.__getattribute__] + return None + +#Wczytanie modelu +model = pickle.load(open('mieszkania_model', 'rb')) + +def cena_mieszkania(pokoje, metraz, rok): + mieszkanie = pd.DataFrame([[pokoje, metraz, rok]], columns=['pokoje', 'metraz', 'rok']) + cena = model.predict(mieszkanie).item() + return np.round(cena, 2) + +# Funkcja tworzy nowe okno ktore wyswietla predykcje ceny +def Oblicz(): + newWindow = Toplevel(root) + newWindow.geometry('600x300') + newWindow.title("wynik") + newWindow.config(bg=tlo) + + # okno + T4 = Label(newWindow,bg=tlo,fg="white",height=3,width=37, text = "Potencjalna cena mieszkania:", bd = 0, relief=RAISED).place(x = 100, y= 50) + address1 = Label(newWindow,width=37,height=3,bg=guziki,text = wyznacz_cene()).place(x = 100, y= 100) + update() + return None + +def reset(): + return None + +Button(root,text="Oblicz",font="arial 20 bold",command=Oblicz ).place(x= 800, y=500) + +#Pola do wpisywania + + +# metraż + +address1 = Text(root,width=37,height=3,bg=guziki) +address1.place(x = 100, y= 100) +T = Label(root,bg=tlo,fg="white",height=3,width=37, text = "Liczba Pokoi", bd = 0, relief=RAISED).place(x = 100, y= 50) + + +# liczba pokoi +address2 = Text(root,width=37,height=3,bg=guziki) +address2.place(x = 100, y= 200) + +T2 = Label(root,bg=tlo,fg="white",height=3,width=37, text = "Metraż", bd = 0, relief=RAISED).place(x = 100, y= 150) + +# Rok budowy +address3 = Text(root,width=37,height=3,bg=guziki) +address3.place(x = 100, y= 300) + +T3 = Label(root,bg=tlo,fg="white",height=3,width=37, text = "Rok Budowy", bd = 0, relief=RAISED).place(x = 100, y= 250) + +Output = Text(root, height = 5, + width = 25, + bg = tlo) + +def wyznacz_cene(): + pokoje = address1.get("1.0",END) + metraz = address2.get("1.0",END) + rok = address3.get("1.0",END) + return cena_mieszkania(pokoje,metraz,rok) + +# Execute Tkinter +root.mainloop() \ No newline at end of file diff --git a/SysInf.ipynb b/SysInf.ipynb index 14f6dc1..cb489b8 100644 --- a/SysInf.ipynb +++ b/SysInf.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 118, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 119, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -57,7 +57,7 @@ }, { "cell_type": "code", - "execution_count": 120, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 121, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -452,7 +452,7 @@ "[2547 rows x 26 columns]" ] }, - "execution_count": 121, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -470,7 +470,7 @@ }, { "cell_type": "code", - "execution_count": 122, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -479,7 +479,7 @@ }, { "cell_type": "code", - "execution_count": 123, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -865,7 +865,7 @@ "[462 rows x 25 columns]" ] }, - "execution_count": 123, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -876,7 +876,7 @@ }, { "cell_type": "code", - "execution_count": 124, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -885,7 +885,7 @@ }, { "cell_type": "code", - "execution_count": 125, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -979,7 +979,7 @@ "[462 rows x 1 columns]" ] }, - "execution_count": 125, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -997,7 +997,7 @@ }, { "cell_type": "code", - "execution_count": 126, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -1006,7 +1006,7 @@ }, { "cell_type": "code", - "execution_count": 127, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -1392,7 +1392,7 @@ "[418 rows x 25 columns]" ] }, - "execution_count": 127, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1410,7 +1410,7 @@ }, { "cell_type": "code", - "execution_count": 128, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -1419,7 +1419,7 @@ }, { "cell_type": "code", - "execution_count": 129, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -1428,7 +1428,7 @@ }, { "cell_type": "code", - "execution_count": 130, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -1437,7 +1437,7 @@ }, { "cell_type": "code", - "execution_count": 131, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -1453,7 +1453,7 @@ }, { "cell_type": "code", - "execution_count": 132, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -1462,7 +1462,7 @@ }, { "cell_type": "code", - "execution_count": 133, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -1471,7 +1471,7 @@ }, { "cell_type": "code", - "execution_count": 134, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -1494,7 +1494,7 @@ }, { "cell_type": "code", - "execution_count": 135, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -1503,7 +1503,7 @@ }, { "cell_type": "code", - "execution_count": 136, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -1512,7 +1512,7 @@ }, { "cell_type": "code", - "execution_count": 137, + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -1521,7 +1521,7 @@ }, { "cell_type": "code", - "execution_count": 138, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -1530,7 +1530,7 @@ }, { "cell_type": "code", - "execution_count": 139, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -1540,7 +1540,7 @@ }, { "cell_type": "code", - "execution_count": 140, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -1643,7 +1643,7 @@ "max 6.000000e+06 11.000000 404.000000 2022.000000" ] }, - "execution_count": 140, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -1654,7 +1654,7 @@ }, { "cell_type": "code", - "execution_count": 141, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -1784,7 +1784,7 @@ "[1763 rows x 4 columns]" ] }, - "execution_count": 141, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -1802,7 +1802,7 @@ }, { "cell_type": "code", - "execution_count": 142, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -1905,7 +1905,7 @@ "max 2.318580e+06 6.000000 234.200000 2021.000000" ] }, - "execution_count": 142, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -1916,7 +1916,7 @@ }, { "cell_type": "code", - "execution_count": 143, + "execution_count": 34, "metadata": {}, "outputs": [], "source": [ @@ -1925,7 +1925,7 @@ }, { "cell_type": "code", - "execution_count": 144, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -1934,7 +1934,7 @@ }, { "cell_type": "code", - "execution_count": 145, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -1943,7 +1943,7 @@ }, { "cell_type": "code", - "execution_count": 146, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -1952,7 +1952,7 @@ }, { "cell_type": "code", - "execution_count": 147, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -1962,7 +1962,7 @@ }, { "cell_type": "code", - "execution_count": 148, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -2092,7 +2092,7 @@ "[320 rows x 4 columns]" ] }, - "execution_count": 148, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -2110,7 +2110,7 @@ }, { "cell_type": "code", - "execution_count": 149, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -2119,7 +2119,7 @@ }, { "cell_type": "code", - "execution_count": 150, + "execution_count": 41, "metadata": {}, "outputs": [], "source": [ @@ -2128,7 +2128,7 @@ }, { "cell_type": "code", - "execution_count": 151, + "execution_count": 42, "metadata": {}, "outputs": [], "source": [ @@ -2138,7 +2138,7 @@ }, { "cell_type": "code", - "execution_count": 152, + "execution_count": 43, "metadata": {}, "outputs": [ { @@ -2241,7 +2241,7 @@ "max 6.000000e+06 11.000000 404.000000 2022.000000" ] }, - "execution_count": 152, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -2259,7 +2259,7 @@ }, { "cell_type": "code", - "execution_count": 153, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -2275,7 +2275,7 @@ }, { "cell_type": "code", - "execution_count": 154, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -2285,7 +2285,7 @@ }, { "cell_type": "code", - "execution_count": 155, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -2295,7 +2295,7 @@ }, { "cell_type": "code", - "execution_count": 156, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -2311,7 +2311,7 @@ }, { "cell_type": "code", - "execution_count": 157, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -2320,19 +2320,19 @@ }, { "cell_type": "code", - "execution_count": 158, + "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
LinearRegression()
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.
" + "
LinearRegression()
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": [ "LinearRegression()" ] }, - "execution_count": 158, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -2350,7 +2350,7 @@ }, { "cell_type": "code", - "execution_count": 159, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -2359,7 +2359,7 @@ }, { "cell_type": "code", - "execution_count": 160, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -2368,7 +2368,7 @@ }, { "cell_type": "code", - "execution_count": 161, + "execution_count": 52, "metadata": {}, "outputs": [ { @@ -2377,7 +2377,7 @@ "0.6264197107092035" ] }, - "execution_count": 161, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -2388,7 +2388,7 @@ }, { "cell_type": "code", - "execution_count": 162, + "execution_count": 53, "metadata": {}, "outputs": [ { @@ -2397,7 +2397,7 @@ "22930468691.882328" ] }, - "execution_count": 162, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -2408,7 +2408,7 @@ }, { "cell_type": "code", - "execution_count": 163, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ @@ -2417,7 +2417,7 @@ }, { "cell_type": "code", - "execution_count": 164, + "execution_count": 55, "metadata": {}, "outputs": [ { @@ -2426,7 +2426,7 @@ "0.5872189061243203" ] }, - "execution_count": 164, + "execution_count": 55, "metadata": {}, "output_type": "execute_result" } @@ -2437,7 +2437,7 @@ }, { "cell_type": "code", - "execution_count": 165, + "execution_count": 56, "metadata": {}, "outputs": [ { @@ -2446,7 +2446,7 @@ "12603444942.321444" ] }, - "execution_count": 165, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -2464,7 +2464,7 @@ }, { "cell_type": "code", - "execution_count": 166, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ @@ -2473,7 +2473,7 @@ }, { "cell_type": "code", - "execution_count": 167, + "execution_count": 58, "metadata": {}, "outputs": [ { @@ -2567,7 +2567,7 @@ "[292 rows x 1 columns]" ] }, - "execution_count": 167, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -2586,7 +2586,7 @@ }, { "cell_type": "code", - "execution_count": 168, + "execution_count": 59, "metadata": {}, "outputs": [], "source": [ @@ -2602,7 +2602,7 @@ }, { "cell_type": "code", - "execution_count": 169, + "execution_count": 60, "metadata": {}, "outputs": [ { @@ -2633,7 +2633,7 @@ }, { "cell_type": "code", - "execution_count": 170, + "execution_count": 61, "metadata": {}, "outputs": [ { @@ -2664,7 +2664,7 @@ }, { "cell_type": "code", - "execution_count": 171, + "execution_count": 62, "metadata": {}, "outputs": [ { @@ -2695,7 +2695,7 @@ }, { "cell_type": "code", - "execution_count": 172, + "execution_count": 63, "metadata": {}, "outputs": [ { @@ -2726,7 +2726,7 @@ }, { "cell_type": "code", - "execution_count": 173, + "execution_count": 64, "metadata": {}, "outputs": [ { @@ -2757,7 +2757,7 @@ }, { "cell_type": "code", - "execution_count": 174, + "execution_count": 65, "metadata": {}, "outputs": [ { @@ -2788,7 +2788,7 @@ }, { "cell_type": "code", - "execution_count": 175, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -2800,7 +2800,7 @@ }, { "cell_type": "code", - "execution_count": 176, + "execution_count": 70, "metadata": {}, "outputs": [ { @@ -2809,7 +2809,7 @@ "184531.94" ] }, - "execution_count": 176, + "execution_count": 70, "metadata": {}, "output_type": "execute_result" } @@ -2817,6 +2817,18 @@ "source": [ "cena_mieszkania(pokoje=2, metraz=25, rok=2000)" ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [], + "source": [ + "# Zapisanie modelu do pliku\n", + "import pickle\n", + "filename = 'mieszkania_model'\n", + "pickle.dump(model, open(filename, 'wb'))\n" + ] } ], "metadata": { diff --git a/mieszkania5 b/mieszkania5 new file mode 160000 index 0000000..242c10d --- /dev/null +++ b/mieszkania5 @@ -0,0 +1 @@ +Subproject commit 242c10da9f5aa9be2878f9ca555eb4d4833f4710 diff --git a/mieszkania_model b/mieszkania_model new file mode 100644 index 0000000000000000000000000000000000000000..916414430e1cd3945d20b7a03c24b677b0663e4e GIT binary patch literal 572 zcmZvaJ!lj`6vywwJrhYZ0V85%nKX-01W61Yq|yy5oEA1=+}(Sd-Q4cXGBbPOL@@#L zaqzG(&%)kD1uGkypqfn_@i5jb<{D%GnWi0V1tJ@;8^wvU zRpBdgaU>He)^Q(bh?60BI+wt>mx3~-jBtwQX*RF}A;C`bM8}?#-hgn7NeBd2TIPW^ zOti{}gok;zda_GSZIc%3K5bKnrk%Re+@xq6t*#zqP?R*TUZCMlm2G1EHo2~Q<(G+a zaV}}{hs&msRwjC4)im2mK}+uzVN;48fyv`h&h}kbhMgu_fq;-vG!`8z97L0U_{PB& zMJKQk{=>caAGcO;7fOFqjmYo!pFY*sQuydyYSwZ2krNF-~9OgcCOMo@^?lDNz^Nek?Z%5KVExz a{&k6;VEcc9^+A?XM{CwTXP=?mw|@iKwCZ#K literal 0 HcmV?d00001 diff --git a/model.py b/model.py new file mode 100644 index 0000000..e69de29