import streamlit as st import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import plotly.express as px from PIL import Image import numpy as np import joblib import json # 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('---') #attacking_work_rate = st.selectbox('AttackingWorkrate', ('Low', 'Medium', 'High'), index=1) #defensive_work_rate = st.selectbox('DefensiveWorkRate', ('Low', 'Medium', 'High'), index=1) st.markdown('---') #pace = st.number_input('Pace', min_value=0, max_value=100, value=50) #shooting = st.number_input('Shooting', min_value=0, max_value=100, value=50) #passing = st.number_input('Passing', min_value=0, max_value=100, value=50) #dribbling = st.number_input('Dribbling', min_value=0, max_value=100, value=50) #defending = st.number_input('Defending', min_value=0, max_value=100, value=50) #physicality = st.number_input('Physicality', min_value=0, max_value=100, value=50) 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()