|
|
|
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")
|
|
|
|
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() |