import streamlit as st import pandas as pd import numpy as np import pickle # Load All Files # Model Logistic Regresi with open('log_reg.pkl', 'rb') as file_1: model_log_reg = pickle.load(file_1) # Model Suppor Vector Classifier with open('svc.pkl', 'rb') as file_2: model_svc = pickle.load(file_2) st.subheader('Prediksi Kelas Pendapatan') # Nilai dari education num education_num = st.slider('Pilih Total Tahun Pendidikan Formal',3,16) # Nilai dari fitur capital gain capital_gain = st.slider('Tentukan Capital Gain Per Tahun ( Dalam USD )',0,100000) # Nilai dari fitur hours per week hours_per_week = st.number_input('Masukkan Total Jam Kerja Per Minggu', 0, 80) # value dari fitur new_occupation occu = st.radio('Pilih Jenis Tingkat Pekerjaan',( 'Manager Up', 'Middle Worker', 'Low Worker', 'Others Service')) # Value fitur sex sex = st.radio('Pilih Jenis Kelamin',('Male', 'Female')) if st.button('Predict'): data_inf = pd.DataFrame({'education_num': education_num, 'capital_gain': capital_gain, 'hours_per_week': hours_per_week, 'new_occupation': occu, 'sex':sex},index=[0]) hasil_log_reg = model_log_reg.predict(data_inf)[0] if hasil_log_reg == 0: hasil_log_reg = 'Dibawah $ 50.000 Per Tahun' else: hasil_log_reg = 'Diatas $ 50.000 Per Tahun' st.write(f'Kelas Pendapatan Anda Menurut Model Logistic Regression: {hasil_log_reg}') hasil_svm = model_svc.predict(data_inf)[0] if hasil_svm == 0: hasil_svm = 'Dibawah $ 50.000 Per Tahun' else: hasil_svm = 'Diatas $ 50.000 Per Tahun' st.write(f'Kelas Pendapatan Anda Menurut Model Logistic SVC : {hasil_svm}')