File size: 2,671 Bytes
408fb7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import streamlit as st
import numpy as np

# Custom CSS for styling
st.markdown(
    """
    <style>
        .header-text {
            color: #333333;
            text-align: center;
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 20px;
        }
        .result-text {
            color: #333333;
            font-size: 18px;
            margin-bottom: 10px;
        }
    </style>
    """,
    unsafe_allow_html=True
)

def map_to_emotion(spo2, bp, temp):
    # Spo2 mapping
    if spo2 >= 96:
        spo2_emotion = ["Joy", "Anticipation", "Trust"]
    elif spo2 == 93 or spo2 == 94:
        spo2_emotion = ["Fear"]
    else:
        spo2_emotion = ["Anger", "Disgust"]

    # BP mapping
    if bp == "110/70mmHg":
        bp_emotion = ["Trust"]
    elif bp == "122/74 mmHg":
        bp_emotion = ["Joy"]
    else:
        bp_emotion = ["Surprise"]

    # Temperature mapping
    if temp >= 98.7 and temp <= 99.1:
        temp_emotion = ["Joy", "Surprise", "Disgust", "Anticipation"]
    elif temp < 98.7:
        temp_emotion = ["Sadness"]
    else:
        temp_emotion = ["Fear", "Anger"]

    # Combine all emotions
    emotions = spo2_emotion + bp_emotion + temp_emotion
    return emotions

def predict_levels(emotions):
    # Placeholder for machine learning models
    # Here, we generate random predictions as placeholders
    stress_percentage = np.random.randint(0, 100)
    anxiety_percentage = np.random.randint(0, 100)
    depression_percentage = np.random.randint(0, 100)
    return stress_percentage, anxiety_percentage, depression_percentage

def main():
    st.title("Emotion Analysis and Mental Health Prediction")
    st.markdown("### Enter Vital Parameters:")
    
    # User inputs
    spo2 = st.selectbox("Select Spo2 Level", ["96% or more", "93-94%", "92% or less"])
    bp = st.selectbox("Select Blood Pressure Level", ["110/70mmHg", "122/74 mmHg", "Others"])
    temp = st.selectbox("Select Body Temperature", ["98.7F-99.1F", "Less than 98.7F", "Greater than 99.1F"])

    # Map inputs to emotions
    emotions = map_to_emotion(spo2, bp, temp)

    st.markdown("### Emotion Analysis Results:")
    for emotion in emotions:
        st.write(f"- {emotion}")

    # Predict levels using machine learning models
    st.markdown("### Predicted Mental Health Levels:")
    stress_percentage, anxiety_percentage, depression_percentage = predict_levels(emotions)
    st.write(f"Stress Percentage (approx): {stress_percentage}%")
    st.write(f"Anxiety Percentage (approx): {anxiety_percentage}%")
    st.write(f"Depression Percentage (approx): {depression_percentage}%")

if __name__ == "__main__":
    main()