Zainajabroh commited on
Commit
7c95e19
·
verified ·
1 Parent(s): 1095cd3

Update Yogyakarta_Housing_Price_Prediction.py

Browse files
Yogyakarta_Housing_Price_Prediction.py CHANGED
@@ -1,33 +1,33 @@
1
- #Make gradio
2
- from joblib import load
3
- import gradio as gr
4
- import numpy as np
5
- encoder_location = load("encoder.pkl")
6
- regressor_model = load("Yogyakarta_housing_price_prediction_model.pkl")
7
- # features ['bed', 'bath', 'carport', 'surface_area(m2)', 'building_area(m2)', 'location']
8
- output_scaler = load("label_scaler.pkl")
9
- input_scaler = load("Feature_scaler.pkl")
10
- def Yogyakarta_Housing_Price_Prediction(bed,bath,carport,surface_are,building_area,location):
11
- encoded_location = encoder_location.transform([[location]])[0]
12
- input_features = np.array([[bed,bath,carport,surface_are,building_area,encoded_location]])
13
- input_features = input_scaler.transform(input_features)
14
- predicted_price = regressor_model.predict(input_features)
15
- predicted_price = predicted_price.reshape(-1,1)
16
- predicted_price = output_scaler.inverse_transform(predicted_price)
17
- predicted_price = predicted_price[0][0]
18
- if predicted_price >= 1000000000:
19
- return f"Rp {np.round((predicted_price/1000000000),4)} Milliar"
20
- else:
21
- return f"Rp {np.round((predicted_price/1000000),2)} Juta"
22
- UI = gr.Interface(fn = Yogyakarta_Housing_Price_Prediction,
23
- inputs = [
24
- gr.Number(label="Jumlah Kamar"),
25
- gr.Number(label="Jumlah Kamar Mandi"),
26
- gr.Number(label = "Jumlah Parkiran"),
27
- gr.Slider(1,2000,step=1,label = "Luas lahan (m²)"),
28
- gr.Slider(1,2000,step = 1, label = "Luas Bangunan (m²)"),
29
- gr.Dropdown(["Bantul","Sleman","Yogyakarta"], label = "Lokasi")
30
- ],
31
- outputs = gr.Label(label = "Prediksi Harga Rumah"),
32
- title = "Prediksi Harga Rumah di DIY")
33
  UI.launch()
 
1
+ #Make gradio
2
+ from joblib import load
3
+ import gradio as gr
4
+ import numpy as np
5
+ encoder_location = load("encoder.pkl")
6
+ regressor_model = load("Yogyakarta_housing_price_prediction_model.pkl")
7
+ # features ['bed', 'bath', 'carport', 'surface_area(m2)', 'building_area(m2)', 'location']
8
+ output_scaler = load("label_scaler.pkl")
9
+ input_scaler = load("Feature_scaler.pkl")
10
+ def Yogyakarta_Housing_Price_Prediction(bed,bath,carport,surface_are,building_area,location):
11
+ encoded_location = encoder_location.transform([[location]])[0]
12
+ input_features = np.array([[bed,bath,carport,surface_are,building_area,encoded_location]])
13
+ input_features = input_scaler.transform(input_features)
14
+ predicted_price = regressor_model.predict(input_features)
15
+ predicted_price = predicted_price.reshape(-1,1)
16
+ predicted_price = output_scaler.inverse_transform(predicted_price)
17
+ predicted_price = predicted_price[0][0]
18
+ if predicted_price >= 1000000000:
19
+ return f"Rp {np.round((predicted_price/1000000000),2)} Milliar"
20
+ else:
21
+ return f"Rp {np.round((predicted_price/1000000),2)} Juta"
22
+ UI = gr.Interface(fn = Yogyakarta_Housing_Price_Prediction,
23
+ inputs = [
24
+ gr.Number(label="Jumlah Kamar"),
25
+ gr.Number(label="Jumlah Kamar Mandi"),
26
+ gr.Number(label = "Jumlah Parkiran"),
27
+ gr.Slider(1,2000,step=1,label = "Luas lahan (m²)"),
28
+ gr.Slider(1,2000,step = 1, label = "Luas Bangunan (m²)"),
29
+ gr.Dropdown(["Bantul","Sleman","Yogyakarta"], label = "Lokasi")
30
+ ],
31
+ outputs = gr.Label(label = "Prediksi Harga Rumah"),
32
+ title = "Prediksi Harga Rumah di DIY")
33
  UI.launch()