import streamlit as st import pandas as pd import numpy as np import joblib with open('model_encode1.pkl', 'rb') as file_1: encode1 = joblib.load(file_1) with open('model_encode2.pkl', 'rb') as file_2: encode2 = joblib.load(file_2) with open('model_scale.pkl', 'rb') as file_3: scale = joblib.load(file_3) with open('model.pkl', 'rb') as file_4: model = joblib.load(file_4) with open('feature_num_col.pkl', 'rb') as file_5: num_col = joblib.load(file_5) with open('feature_cat_nom.pkl', 'rb') as file_6: cat_nom = joblib.load(file_6) with open('feature_cat_ord.pkl', 'rb') as file_7: cat_ord = joblib.load(file_7) hour = st.slider('Masukan Jam:',0, 24,step=1) distance = st.number_input('Masukan Jarak dalam mile:') platform = st.radio('Lyft/Uber:',('Lyft', 'Uber')) service = st.selectbox('Masukan Jenis Layanan: ',('Shared', 'Lux', 'UberPool', 'Lyft XL', 'Black', 'Lyft', 'UberXL', 'UberX', 'WAV', 'Lux Black', 'Black SUV', 'Lux Black XL')) destination = st.selectbox('Masukan Tujuan:',('North Station', 'Fenway', 'West End', 'Back Bay', 'Haymarket Square', 'Theatre District', 'South Station', 'Northeastern University', 'North End', 'Financial District', 'Beacon Hill', 'Boston University')) weather = st.selectbox('Masukan Cuaca Sekarang: ',(' Drizzle ', ' Clear ', ' Overcast ', ' Possible Drizzle ', ' Mostly Cloudy ', ' Partly Cloudy ', ' Rain ', ' Light Rain ', ' Foggy ')) if st.button('Predict'): data_inf = pd.DataFrame({'hour' : hour, 'distance' : distance, 'platform' : platform, 'service' : service, 'destination' : destination, 'weather' : weather},index=[0]) data_inf_scaled = scale.transform(data_inf[num_col]) data_inf_encoded1 = encode1.transform(data_inf[cat_nom]) data_inf_encoded2 = np.array([encode2.transform(data_inf[cat_ord])]).T data_inf_fix = np.concatenate([data_inf_scaled, data_inf_encoded1, data_inf_encoded2], axis=1) hasil = model.predict(data_inf_fix)[0] st.header(f'Harga Uber= ${hasil}')