使用 tkinter 在 GUI 上显示数字时出现问题

问题描述 投票:0回答:0

我正在尝试显示线性回归的答案。我可以只用 print(regr.fit(X_train,y_train) 在控制台中打印答案,但我无法让它工作并显示在我的 GUI 中。

定义线性回归(): df2.interpolate(方法 ='线性', inplace = True)

X = np.array(df2['doors']).reshape(-1, 1)
y = np.array(df2['persons']).reshape(-1, 1)

# Separating the data into independent and dependent variables
# Converting each dataframe into a numpy array
# since each dataframe contains only one column
df2.dropna(inplace = True)

# Dropping any rows with Nan values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)

regr = LinearRegression()
regr.fit(X_train, y_train)

LR = regr.fit(X_train, y_train)

answer1.configure(text=LR)

button4 = Button( window , text = "运行算法!" , command = LinearRegression ).grid(pady=30)

answer1 = 标签(窗口, text="",font=('纸莎草',14), bg="小麦") 答案1.grid(列=1,行=0)

窗口.mainloop()

user-interface tkinter-canvas
© www.soinside.com 2019 - 2024. All rights reserved.