Integrate regression model

This commit is contained in:
Piotr 2023-10-17 18:36:06 +02:00
parent 68409d7488
commit 6d3a4d9dc1

View File

@ -1,5 +1,8 @@
from tkinter import * from tkinter import *
from tkinter import messagebox from tkinter import messagebox
import pickle
import numpy as np
from sklearn.preprocessing import StandardScaler
window = Tk() window = Tk()
window.minsize(width=600, height=600) window.minsize(width=600, height=600)
@ -37,6 +40,7 @@ wartosc_regresji = Label()
wartosc_regresji.config(text="Wartosć przewidywana", background="#ffffff") wartosc_regresji.config(text="Wartosć przewidywana", background="#ffffff")
wartosc_regresji.grid(column=1, row=4, sticky='w') wartosc_regresji.grid(column=1, row=4, sticky='w')
model = pickle.load(open("model.pkl", 'rb'))
def val_numbers(): def val_numbers():
@ -50,8 +54,13 @@ def val_numbers():
messagebox.showinfo(title="Error", message=f"Please provide numbers between 0 to 100 for floors and 0 to 100.000 for metric area.") messagebox.showinfo(title="Error", message=f"Please provide numbers between 0 to 100 for floors and 0 to 100.000 for metric area.")
else: else:
confirm = messagebox.askyesno(title="Confirm", message="Do you want to start prediction?") confirm = messagebox.askyesno(title="Confirm", message="Do you want to start prediction?")
if confirm == True:
array = np.array([[int(pietro_entry.get()),float(metraz_entry.get())]])
scaler = StandardScaler()
transformed_data = scaler.fit_transform(array)
prediction = model.predict(transformed_data)
wartosc_regresji.config(text=f'{round(prediction[0][0], 2)} PLN')
start_button = Button(command=val_numbers) start_button = Button(command=val_numbers)
start_button.config(text="Start", background="#000000", foreground="#ffffff") start_button.config(text="Start", background="#000000", foreground="#ffffff")