Spaces:
Runtime error
Runtime error
File size: 1,463 Bytes
bc9b26f be7643a bc9b26f 27c7c95 bc9b26f 3d78478 bc9b26f b6e185f bc9b26f 3d78478 bc9b26f |
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 38 39 40 41 42 43 44 45 46 47 48 |
import streamlit as st
from PIL import Image
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import joblib
# Load All Files
with open('model.pkl', 'rb') as file_1:
model = joblib.load(file_1)
with open('pipeline.pkl', 'rb') as file_2:
preprocessor = joblib.load(file_2)
def run():
# Membuat Form
with st.form(key='form_parameters'):
income = st.number_input('Average Income', min_value=0, max_value=150000, value=50000, step=1000)
age = st.number_input('House Age', min_value=0, max_value=50, value=5, step=1)
rooms = st.number_input('Number of Rooms', min_value=0, max_value=25, value=5, step=1)
bedrooms = st.number_input('Number of Bedrooms', min_value=0, max_value=10, value=3, step=1)
population = st.number_input('Area Population', min_value=0, max_value=100000, value=50000, step=1000)
st.markdown('---')
submitted = st.form_submit_button('Predict')
data_inf = {
'Income': income,
'Age': age,
'Rooms': rooms,
'Bedrooms': bedrooms,
'Population': population
}
data_inf = pd.DataFrame([data_inf])
st.dataframe(data_inf)
if submitted:
# Feature Preprocessing
X_inf = preprocessor.transform(data_inf)
# Predict using Linear regression
y_pred_inf = model.predict(X_inf)
st.write('# House Price : ', str(int(y_pred_inf)))
if __name__ == '__main__':
run() |