Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import pandas as pd
|
3 |
+
from sklearn.neighbors import KNeighborsRegressor
|
4 |
+
from joblib import dump
|
5 |
+
import gradio
|
6 |
+
|
7 |
+
## Building a Fubction for prediction:
|
8 |
+
|
9 |
+
def predictPrice(input1, input2, input3, input4, input5, input6, input7, input8):
|
10 |
+
features = [input1, input2, input3, input4, input5, input6, input7, input8]
|
11 |
+
scaler.fit(features)
|
12 |
+
features_array = np.array(features).reshape(1, -1)
|
13 |
+
prediction = KNN_Regressor.predict(features_array)
|
14 |
+
return prediction
|
15 |
+
|
16 |
+
|
17 |
+
## Buidling inputs and outputs:
|
18 |
+
|
19 |
+
input1 = gr.Slider(-124.35, -114.31, step=5, label = "Longitude")
|
20 |
+
input2 = gr.Slider(32.54, 41.95, step=5, label = "Latitude")
|
21 |
+
input3 = gr.Slider(1, 52.0, step=5, label = "Housing_median_age (Year)")
|
22 |
+
input4 = gr.Slider(1, 39320.0, step=5, label = "Total_rooms")
|
23 |
+
input5 = gr.Slider(1, 6445.0, step=5, label = "Total_bedrooms")
|
24 |
+
input6 = gr.Slider(1, 35682.0, step=5, label = "Population")
|
25 |
+
input7 = gr.Slider(1, 6082.0, step=5, label = "Households")
|
26 |
+
input8 = gr.Slider(0, 15.0, step=5, label = "Median_income")
|
27 |
+
|
28 |
+
output1 = gr.Textbox(label = "House Value")
|
29 |
+
|
30 |
+
|
31 |
+
##title Putting it all together:
|
32 |
+
|
33 |
+
gr.Interface(fn=predictPrice, inputs=[input1, input2, input3, input4, input5, input6, input7, input8],
|
34 |
+
outputs=output1).launch(show_error=True)
|