|
import streamlit as st |
|
import pandas as pd |
|
import numpy as np |
|
import pickle |
|
|
|
|
|
|
|
with open('log_reg.pkl', 'rb') as file_1: |
|
model_log_reg = pickle.load(file_1) |
|
|
|
|
|
with open('svc.pkl', 'rb') as file_2: |
|
model_svc = pickle.load(file_2) |
|
|
|
|
|
st.subheader('Prediksi Kelas Pendapatan') |
|
|
|
|
|
education_num = st.slider('Pilih Total Tahun Pendidikan Formal',3,16) |
|
|
|
|
|
capital_gain = st.slider('Tentukan Capital Gain Per Tahun',0,100000) |
|
|
|
|
|
hours_per_week = st.number_input('Masukkan Total Waktu Kerja Per Minggu', 0, 80) |
|
|
|
|
|
occu = st.radio('Pilih Jenis Tingkat Pekerjaan',( 'Manager Up', 'Middle Worker', 'Low Worker', 'Others Service')) |
|
|
|
|
|
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}') |
|
|
|
|