File size: 2,483 Bytes
63a679d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
import streamlit as st
import pandas as pd
import pickle
from PIL import Image

def run():
# Load All Files

    with open('final_model.pkl', 'rb') as file:
        final_model = pickle.load(file)


        Gender= st.selectbox("Gender", ["Male", "Female"])
        Occupation = st.selectbox("Occupation", ["Software Engineer", "Doctor", "Sales Representative", "Teacher", "Nurse", 
                                                 "Engineer", "Accountant", "Scientist", "Lawyer", "Salesperson", "Manager"])
        Sleep_Duration = st.selectbox("Sleep_Duration", [6.1, 6.2, 5.9, 6.3, 7.8, 6. , 6.5, 7.6, 7.7, 7.9, 6.4, 7.5, 7.2, 5.8,
                                                         6.7, 7.3, 7.4, 7.1, 6.6, 6.9, 8. , 6.8, 8.1, 8.3, 8.5, 8.4, 8.2])
        Physical_Activity_Level = st.selectbox("Physical_Activity_Level", [42, 60, 30, 40, 75, 35, 45, 50, 32, 70, 
                                                                           80, 55, 90, 47, 65, 85])
        Stress_Level = st.selectbox("Stress_Level", [6, 8, 7, 4, 3, 5])
        BMI_Category = st.selectbox("BMI_Category", ["Overweight", "Normal", "Obese", "Normal Weight"])
        Heart_Rate = st.selectbox("Heart_Rate", [77, 75, 85, 82, 70, 80, 78, 69, 72, 68, 76, 81, 65, 84, 74, 67, 73, 83, 86])
        
    
    st.write('In the following is the result of the data you have input : ')
    
    data_inf = pd.DataFrame({
            "Gender" : Gender,
            "Occupation" : Occupation,
            "Sleep Duration" : Sleep_Duration,
            "Physical Activity Level" : Physical_Activity_Level,
            "Stress Level" : Stress_Level,
            "BMI Category" : BMI_Category,
            "Heart Rate" : Heart_Rate,
        }, index=[0])

    st.table(data_inf)


    if st.button(label='predict'):
    
        # Melakukan prediksi data dummy
        scaler = scaler.transform(input)
        y_pred_inf = final_model.predict(data_inf)

        st.write("Here is a prediction of the People Who Have Sleep Disorder: ")
        if y_pred_inf[0] == 1:
            st.subheader("The Diagnosis is:")
            prediction = 'Sleep Apnea'
            
        if y_pred_inf[0] == 2:
            st.subheader("This People Diagnosed Insomnia")
            prediction = 'Insomnia'
            
        else:
            st.subheader("This People Normal")
            prediction = 'Normal'
            
        st.subheader('Based on user input, the model predicted: ')
        st.header(y_pred_inf)