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_lin_reg.pkl', 'rb') as file_1: model_lin_reg = 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=60, value=25, step=1) age = st.number_input('House Age', min_value=0, max_value=60, value=25, step=1) rooms = st.number_input('Number of Rooms', min_value=50, max_value=150, value=70) bedrooms = st.number_input('Number of Bedrooms', min_value=50, max_value=150, value=70) population = st.number_input('Area Population', min_value=50, max_value=150, value=70) # price = st.slider('Price', 0, 100000000, 0) #price = st.number_input('Price', min_value=0, max_value=1000000000, value=0) 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_lin_reg.predict(X_inf) st.write('# House Price : ', str(int(y_pred_inf))) if __name__ == '__main__': run()