modified app.py
Browse filesadded the slider instead of text boxes
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 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
fn=predict_house_price,
|
| 18 |
inputs=[
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
],
|
| 28 |
-
outputs=gr.Textbox(label="Predicted House
|
| 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()
|
|
|
|
|
|
|
|
|