catherinehelenna/model_test_111
0
1import streamlit as st2import numpy as py3import pandas as pd4import pickle5import json6 7def run():8 # buat header9 st.header("Show model")10 11 12 # load model yang sudah disave13 with open('model_linreg.pkl','rb') as file_1:14 modelku = pickle.load(file_1)15 16 with open('model_scaler2.pkl', 'rb') as file_2:17 sc= pickle.load(file_2)18 19 with open('model_ohe_encoder_1.pkl', 'rb') as file_3:20 ohe = pickle.load(file_3)21 22 # semua fitur yang masuk dalam modelling harus ditulis23 with st.form("informasi berkaitan universitas"):24 # total_cost = st.number_input('total_cost',min_value = 0, max_value = 50000, help='total cost')25 world_rank = st.slider('world_rank',min_value = 0, max_value = 50000, help='world_rank')26 27 tuition_fees = st.slider('tuition_fees',min_value = 0, max_value = 50000, help='tuition_fees')28 # submit form29 sub = st.form_submit_button('Prediksi')30 31 data_predict = {'tuition_fees': tuition_fees}32 data = pd.DataFrame([data_predict])33 st.dataframe(data)34 35 if sub:36 y_pred = modelku.predict(data)37 st.write('Prediksi total cost adalah: ', y_pred[0])38 39if __name__ == '__main__':40 run()41 