jamesnzeex commited on
Commit
ccce4ac
1 Parent(s): fe19938

fixed error

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -4,7 +4,7 @@ import pickle
4
  import pandas as pd
5
  import gradio as gr
6
 
7
- def main(address :str, floor_area_sqft :int, remaining_lease_years :int, flat_type, storey_range, year_sold=2020 :int, update_model=False):
8
 
9
  model_file = 'model.sav'
10
 
@@ -41,9 +41,6 @@ def main(address :str, floor_area_sqft :int, remaining_lease_years :int, flat_ty
41
  elif storey_range == 'HIGH FLOOR':
42
  storey_high = 1,
43
 
44
- # loading model
45
- # if update_model:
46
- # utils.get_update(year_sold)
47
  if os.path.exists("./model.sav"):
48
  model = pickle.load(open(model_file, 'rb'))
49
  input_dict = pd.DataFrame({
@@ -63,7 +60,7 @@ def main(address :str, floor_area_sqft :int, remaining_lease_years :int, flat_ty
63
  'storey_range_Mid Floor': storey_mid},
64
  index = [0])
65
 
66
- return ('Predicted PSF:', round(model.predict(input_dict).item(),2), '\nPredicted Property Value:', round(model.predict(input_dict).item(),2) * floor_area_sqft)
67
 
68
  else:
69
  return ('ERROR: No saved model')
@@ -76,8 +73,6 @@ iface = gr.Interface(
76
  gr.inputs.Number(default=None, label='Remaining Lease (years)', optional=False),
77
  gr.inputs.Dropdown(choices=['1 ROOM', '2 ROOM', '3 ROOM', '4 ROOM', '5 ROOM', 'EXECUTIVE', 'MULTI-GENERATION'], type="value", default=None, label="Flat Type"),
78
  gr.inputs.Dropdown(choices=['LOW FLOOR', 'MID FLOOR', 'HIGH FLOOR'], type="value", default=None, label="Storey Range"),
79
- # gr.inputs.Number(default=2020, label='Data from:', optional=False),
80
- # gr.inputs.Checkbox(default=False, label="Update Model?", optional=False)
81
  ],
82
  outputs = [gr.outputs.Textbox(type="auto", label='Predicted Price per SQFT')])
83
  iface.launch()
 
4
  import pandas as pd
5
  import gradio as gr
6
 
7
+ def main(address :str, floor_area_sqft :int, remaining_lease_years :int, flat_type, storey_range):
8
 
9
  model_file = 'model.sav'
10
 
 
41
  elif storey_range == 'HIGH FLOOR':
42
  storey_high = 1,
43
 
 
 
 
44
  if os.path.exists("./model.sav"):
45
  model = pickle.load(open(model_file, 'rb'))
46
  input_dict = pd.DataFrame({
 
60
  'storey_range_Mid Floor': storey_mid},
61
  index = [0])
62
 
63
+ return ({'Predicted PSF': round(model.predict(input_dict).item(),2), 'Predicted Price': round(model.predict(input_dict).item() * floor_area_sqft, 2)})
64
 
65
  else:
66
  return ('ERROR: No saved model')
 
73
  gr.inputs.Number(default=None, label='Remaining Lease (years)', optional=False),
74
  gr.inputs.Dropdown(choices=['1 ROOM', '2 ROOM', '3 ROOM', '4 ROOM', '5 ROOM', 'EXECUTIVE', 'MULTI-GENERATION'], type="value", default=None, label="Flat Type"),
75
  gr.inputs.Dropdown(choices=['LOW FLOOR', 'MID FLOOR', 'HIGH FLOOR'], type="value", default=None, label="Storey Range"),
 
 
76
  ],
77
  outputs = [gr.outputs.Textbox(type="auto", label='Predicted Price per SQFT')])
78
  iface.launch()