Keziaa's picture
Upload 10 files
8aef260
import streamlit as st
import pandas as pd
import numpy as np
import joblib
with open('model_lin_reg.pkl', 'rb') as file_1:
model_lin_reg= joblib.load(file_1)
with open('model_scaler.pkl', 'rb') as file_2:
model_scaler=joblib.load(file_2)
with open('model_encoder.pkl', 'rb') as file_3:
model_encoder= joblib.load(file_3)
with open('list_num_cols.txt', 'rb') as file_4:
num_cols= joblib.load(file_4)
with open('list_cat_cols.txt', 'rb') as file_5:
cat_cols= joblib.load(file_5)
hour = st.slider('Masukan Jam : ',0, 24)
distance = st.number_input('Masukan Jarak dalam Mile : ')
cab_type = st.radio('Lyft/Uber : ',('Lyft', 'Uber'))
name = 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'))
icon = st.selectbox('Masukan Cuaca Sekarang : ',(' cloudy ', ' partly-cloudy-day ', ' rain ', ' clear-night ',
' partly-cloudy-night ', ' fog ', ' clear-day '))
if st.button('Predict'):
data_inf = pd.DataFrame({'hour' : hour, 'distance' : distance, 'cab_type' : cab_type, 'name' : name, 'destination' : destination, 'icon' : icon})
data_inf_scaled = model_scaler.transform(data_inf[num_cols])
data_inf_encoded1 = model_encoder.transform(data_inf[cat_cols])
data_inf_fix = np.concatenate([data_inf_scaled,data_inf_encoded1],axis=1)
hasil = model_lin_reg.predict(data_inf_fix)
hasil