-
Notifications
You must be signed in to change notification settings - Fork 0
/
prediction_gui.py
71 lines (60 loc) · 2.3 KB
/
prediction_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 18 14:18:01 2019
@author: aj-nok
"""
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
import statsmodels.api as sm
from sklearn.metrics import r2_score
import tkinter as tk
import pandas as pd
import numpy as np
model = LinearRegression()
df=pd.read_csv('realestatetransactions.csv',usecols=["sq__ft","latitude","longitude","beds","baths","price"])
df = df[df.sq__ft != 0]
X = np.column_stack((df['sq__ft'],df['beds'],df['baths']))
Y=df['price']
Y=Y.values.reshape(len(Y),1)
model.fit(X, Y)
print('Intercept: \n', model.intercept_)
print('Coefficients: \n', model.coef_)
X = sm.add_constant(X)
mod = sm.OLS(Y, X).fit()
predictions = mod.predict(X)
root= tk.Tk()
root.title("Prediction")
canvas1 = tk.Canvas(root, width = 1200, height = 450)
canvas1.pack()
print_mod = mod.summary()
label_model = tk.Label(root, text=print_mod, justify = 'center', relief = 'solid', bg='yellow')
canvas1.create_window(800, 220, window=label_model)
label0 = tk.Label(root, text='Enter the details: ')
canvas1.create_window(80, 80, window=label0)
label1 = tk.Label(root, text='Type Square feet: ')
canvas1.create_window(100, 100, window=label1)
entry1 = tk.Entry (root)
canvas1.create_window(270, 100, window=entry1)
label4 = tk.Label(root, text=' Type Beds: ')
canvas1.create_window(120, 120, window=label4)
entry4 = tk.Entry (root)
canvas1.create_window(270, 120, window=entry4)
label5 = tk.Label(root, text=' Type Baths: ')
canvas1.create_window(140, 140, window=label5)
entry5 = tk.Entry (root)
canvas1.create_window(270, 140, window=entry5)
def values():
global New_sq__ft_Rate
New_sq__ft_Rate = int(entry1.get())
global New_beds_Rate
New_beds_Rate = int(entry4.get())
global New_baths_Rate
New_baths_Rate = int(entry5.get())
Prediction_result = ('Predicted Price: ', model.predict([[New_sq__ft_Rate,New_beds_Rate,New_baths_Rate]]))
label_Prediction = tk.Label(root, text= Prediction_result, font=("times", 21), bg='red')
canvas1.create_window(260, 280, window=label_Prediction)
button1 = tk.Button (root, text='Predict Price',command=values, bg='cyan')
canvas1.create_window(270, 210, window=button1)
root.mainloop()