Spaces:
Sleeping
Sleeping
File size: 1,372 Bytes
7d4a00c fa5f4f0 24f0b2a 7d4a00c 84e1fbc c832be8 7d4a00c a5cadd1 4775123 9ddebaa c832be8 7d4a00c c832be8 |
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 |
import numpy as np
import pandas as pd
from sklearn.neighbors import KNeighborsRegressor
from joblib import dump, load
import gradio as gr
scaler = load('scaler_lab4.joblib')
KNN_Regressor = load('knn_lab4.joblib')
## Building a Fubction for prediction:
def predictPrice(input1, input2, input3, input4, input5, input6, input7, input8):
features = np.array([[input1, input2, input3, input4, input5, input6, input7, input8]])
features_scaled = scaler.transform(features)
prediction = KNN_Regressor.predict(features_scaled)
return round(prediction.item(), 2)
## Buidling inputs and outputs:
input1 = gr.Slider(-124.35, -114.31, step=5, label = "Longitude")
input2 = gr.Slider(32.54, 41.95, step=5, label = "Latitude")
input3 = gr.Slider(1, 52.0, step=5, label = "Housing_median_age (Year)")
input4 = gr.Slider(1, 39320.0, step=5, label = "Total_rooms")
input5 = gr.Slider(1, 6445.0, step=5, label = "Total_bedrooms")
input6 = gr.Slider(1, 35682.0, step=5, label = "Population")
input7 = gr.Slider(1, 6082.0, step=5, label = "Households")
input8 = gr.Slider(0, 15.0, step=5, label = "Median_income")
output1 = gr.Textbox(label = "House Value")
##title Putting it all together:
gr.Interface(fn=predictPrice, inputs=[input1, input2, input3, input4, input5, input6, input7, input8],
outputs=output1).launch(show_error=True, share=True) |