File size: 1,790 Bytes
673fd3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#Make gradio
from joblib import load
import gradio as gr
import numpy as np
encoder_location = load("encoder.pkl")
regressor_model = load("Yogyakarta_housing_price_prediction_model.pkl")
# features ['bed', 'bath', 'carport', 'surface_area(m2)', 'building_area(m2)', 'location']
output_scaler = load("label_scaler.pkl")
input_scaler = load("Feature_scaler.pkl")
def Yogyakarta_Housing_Price_Prediction(bed,bath,carport,surface_are,building_area,location):
    encoded_location = encoder_location.transform([[location]])[0]
    input_features = np.array([[bed,bath,carport,surface_are,building_area,encoded_location]])
    input_features = input_scaler.transform(input_features)
    predicted_price = regressor_model.predict(input_features)
    predicted_price = predicted_price.reshape(-1,1)
    predicted_price = output_scaler.inverse_transform(predicted_price)
    predicted_price = predicted_price[0][0]
    if predicted_price >= 1000000000:
        return f"Rp {np.round((predicted_price/1000000000),4)} Milliar"
    else:
        return f"Rp {np.round((predicted_price/1000000),2)} Juta"
UI = gr.Interface(fn = Yogyakarta_Housing_Price_Prediction,
                  inputs = [
                      gr.Number(label="Jumlah Kamar"),
                      gr.Number(label="Jumlah Kamar Mandi"),
                      gr.Number(label = "Jumlah Parkiran"),
                      gr.Slider(1,2000,step=1,label = "Luas lahan (m²)"),
                      gr.Slider(1,2000,step = 1, label = "Luas Bangunan (m²)"),
                      gr.Dropdown(["Bantul","Sleman","Yogyakarta"], label = "Lokasi")
                  ],
                  outputs = gr.Label(label = "Prediksi Harga Rumah"),
                  title = "Prediksi Harga Rumah di DIY")
UI.launch()