File size: 1,814 Bytes
de11062
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2af4e1a
de11062
 
 
 
 
 
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
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},index=[0])
    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