karthik55 commited on
Commit
381f844
1 Parent(s): fbe280e

modified app.py

Browse files

added the slider instead of text boxes

Files changed (1) hide show
  1. app.py +25 -15
app.py CHANGED
@@ -12,21 +12,31 @@ def predict_house_price(longitude, latitude, housing_median_age, total_rooms, to
12
  prediction = best_knn_model.predict(scaled_inputs)[0]
13
  return f"${prediction:,.2f}"
14
 
15
- # Define the Gradio interface
16
- interface = gr.Interface(
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  fn=predict_house_price,
18
  inputs=[
19
- gr.Number(label="Longitude"),
20
- gr.Number(label="Latitude"),
21
- gr.Number(label="Housing Median Age"),
22
- gr.Number(label="Total Rooms"),
23
- gr.Number(label="Total Bedrooms"),
24
- gr.Number(label="Population"),
25
- gr.Number(label="Households"),
26
- gr.Number(label="Median Income")
27
  ],
28
- outputs=gr.Textbox(label="Predicted House Price")
29
- )
30
-
31
- # Launch the interface
32
- interface.launch()
 
12
  prediction = best_knn_model.predict(scaled_inputs)[0]
13
  return f"${prediction:,.2f}"
14
 
15
+ input_longitude = gr.Slider(label="Longitude")
16
+ input_latitude = gr.Slider(label="Latitude")
17
+ input_housing_med_age = gr.Slider(label="Housing Median Age")
18
+ input_totla_rooms = gr.Slider(label="Total Rooms")
19
+ input_total_bedRooms = gr.Slider(label="Total Bedrooms")
20
+ input_popu = gr.Slider(label="Population")
21
+ input_households = gr.Slider(label="Households")
22
+ input_med_income = gr.Slider(label="Median Income")
23
+
24
+
25
+ # output modules
26
+
27
+ output_predicted_value = gr.Textbox(label="Predicted Median House Value")
28
+
29
+ gr.Interface(
30
  fn=predict_house_price,
31
  inputs=[
32
+ input_longitude,
33
+ input_latitude,
34
+ input_housing_med_age,
35
+ input_totla_rooms,
36
+ input_total_bedRooms,
37
+ input_popu,
38
+ input_households,
39
+ input_med_income
40
  ],
41
+ outputs=gr.Textbox(label="Predicted Median House Value"),
42
+ ).launch()