File size: 1,679 Bytes
90d20a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc187b3
90d20a8
 
5cfa681
90d20a8
 
5cfa681
90d20a8
 
 
 
 
 
 
 
 
 
 
 
3bc837e
 
 
 
90d20a8
 
 
 
3bc837e
90d20a8
3bc837e
90d20a8
 
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
43
44
45
46
47
48
49
50
51
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}')