0

尝试创建一个获取建筑物属性的 GUI,使用 Tkinter 从经过训练的 ML 模型返回一个值。应用程序运行没有错误,但不返回任何结果。很难找到问题。这是整个代码:

from tkinter import *
import random
import time; 
import datetime
from catboost import CatBoostRegressor 
import numpy as np 
import joblib
import json

#load model and scaler
from_file = CatBoostRegressor()
house_model=from_file.load_model("final_housing_model",format="coreml")
house_scaler=joblib.load("housing_scaler.pkl")

#create the very thing(GUI)

house =Tk()
house.title('Veracity')
house.geometry("1600x800+0+0")

#declare stuff
text_Input=IntVar()
#creating the frames for Top, Bottom and Side parts of the GUI

Bottom=Frame(house,width=900,height=700,bg="powder blue",relief=SUNKEN )
Bottom.pack(side=LEFT)


#time tuu nta kindi (the fromat is not good for the moment)
localtime=time.asctime(time.localtime(time.time( )))

#Put Text Content in the thing(as in just the title)
Topinfo=Label(Tops,font=("Helvetica",50,"bold"),text="VeracityReference",fg="black",bd=10,anchor='w')
Topinfo.grid(row=0,column=0)
#time as well from above
time=Label(Tops,font=("Helvetica",20,"bold"),text=localtime,fg="black",bd=10,anchor='w')
time.grid(row=1,column=0)
# the inputs of the value determinants for now

bedroomsinput=IntVar()
bathroomsinput=IntVar()

#Bedrooms
bedrooms_ref=Label(Bottom,font=('Times New Roman',16,'bold'),text="Number of 
 Bedrooms",bd=10,anchor='w')
bedrooms_ref.grid(row=0,column=0)
bedrooms=Entry(Bottom,font 
("arial",16,"bold"),textvariable=bedroomsinput,bd=10,insertwidth=4,bg='white',justify='right')
bedrooms.grid(row=0,column=1)
#Bathrooms
bathrooms_ref=Label(Bottom,font=('Times New Roman',16,'bold'),text='Number of 
bathrooms',bd=10,anchor='w')
bathrooms_ref.grid(row=1,column=0)
bathrooms=Entry(Bottom,font= 
("arial",16,"bold"),textvariable=bathroomsinput,bd=10,insertwidth=4,bg='white',justify='right')
bathrooms.grid(row=1,column=1)


#put them together 
S_bedrooms=float(bedrooms.get())
S_bathrooms=float(bathrooms.get())
S_sqft_living=float(sqft_living.get())
S_sqft_lot=float(Sqft_lot.get())
S_floors=float(Number_of_floors.get())

inputh= 

[[S_卧室,S_浴室]]

#function to do stuff
def return_predictions(model=house_model,scaler=house_scaler,House=inputh):
    S_bedrooms=float(bedrooms.get())
    S_bathrooms=float(bathrooms.get())
    House= 

[[S_bedrooms,S_bathrooms]] House=scaler.transform(House)

    Market_value=model.predict(House)

    return  Market_value

results=return_predictions(house_model,house_scaler,inputh)

submit=Button(Bottom,padx=16,pady=8,bd=16,fg='black',font= 
('Arial',16,'bold'),width=10,text="submit",bg="powder 
blue",command=return_predictions).grid(row=9,column=6)

Market_value_ref=Label(Bottom,font=('Times New Roman',16,'bold'),text="Estimated Market 
Value",bd=10,anchor='w')
Market_value_ref.grid(row=7,column=6)
Market_value=Entry(Bottom,font= 
("arial",16,"bold"),textvariable=results,bd=10,insertwidth=4,bg='white',justify='right')
Market_value.grid(row=8,column=6)


house.mainloop()
4

0 回答 0