File size: 4,517 Bytes
24515e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import streamlit as st 
import joblib
import numpy as np
## Heading 
html_temp = """
    <div style="background-color:black;padding:10px">
    <h2 style="color:red;text-align:center;">Cardiovascular Health Prediction App </h2>
    </div>
    """
st.markdown(html_temp, unsafe_allow_html=True)

# st.markdown(html_temp, unsafe_allow_html=True)

# image
url="https://static.vecteezy.com/system/resources/previews/006/712/964/original/abstract-health-medical-science-healthcare-icon-digital-technology-doctor-concept-modern-innovation-treatment-medicine-on-hi-tech-future-blue-background-for-wallpaper-template-web-design-vector.jpg"
st.image(url, use_container_width=True)

st.markdown(f"""
    <style>
        /* Set the background image for the entire app */
        .stApp {{
            background-color:#fdf5df;
            background-size: 100px;
            background-repeat:no;
            background-attachment: auto;
            background-position:full;
        }}
    </style>
    """, unsafe_allow_html=True)

st.write("Enter the Patient  details:")

# model

health_model=joblib.load("health_model.joblib")

scaler_model=joblib.load('scaler_the data_model.joblib')

# Input variables

col1, col2 = st.columns(2)
with col1:
    
    ## Age
    age=st.slider("Slide the AGE of the Patient:",max_value=80,min_value=20)
    
with col2:
    
    ## gender
    option_gen=["Female "," Male"]
    gen=st.selectbox("Select the Gender",option_gen) 
    gender_value=option_gen.index(gen)
    
col1, col2 = st.columns(2)
with col1:
    ## chestpain
    chestpain=st.slider("Slide the chestpain Value:",min_value=0,max_value=3)
    
with col2:
    ## restingBP
    restingBP=st.slider("Slide the Resting  BP of the Patient:",min_value=90,max_value=200)

col1,col2=st.columns(2)
with col1:
    ## serumcholestrol
    serumcholestrol=st.slider("Slide The Serum cholestrol Of a Ptient :",min_value=0,max_value=600)
    
with col2:
    ## fastingbloodsugar
    fastingbloodsugar= st.radio("Is Patient blood is Fasting:", ["YES", "NO"])
    if fastingbloodsugar=="YES":
        fastingbloodsugar_value=1
    else:
       fastingbloodsugar_value=0
    
col1,col2=st.columns(2)

with col1:
   ## restingrelectro
    restingrelectro=st.slider("Slide The restingrelectro of a Patient :",min_value=0,max_value=2)
        
with col2:
    ## maxheartrate
    maxheartrate=st.slider("Slide The max heart rate  of the Patient :",min_value=70,max_value=200)

col1,col2=st.columns(2)
with col1:
    ## exerciseangia
    exerciseangia=st.slider("Slide the exerciseangia Value:",min_value=0,max_value=1)
    

with col2:
    ##oldpeak'
    oldpeak=st.slider("Silde the oldpeak :",max_value=6.2,min_value=0.0,value=0.1)
    
    
col1,col2=st.columns(2)
with col1:
    ## slope
    slope=st.slider("Silde the slope of the Patient :",max_value=3,min_value=0,value=1)
    
with col2:
    ## noofmajorvessels
    noofmajorvessels=st.slider("Silde the No of Major Vessels to  a Patient :",max_value=3,min_value=0,value=1)


if st.button("Submit"):
    
    # st.write("before scaleing:",[age,gender_value,chestpain,restingBP,serumcholestrol,fastingbloodsugar_value,restingrelectro,
    #                              maxheartrate,exerciseangia,oldpeak,slope,noofmajorvessels])
    # Scaler the values
    scaler_val = scaler_model.transform([[age,gender_value,chestpain,restingBP,serumcholestrol,fastingbloodsugar_value,restingrelectro,
                                 maxheartrate,exerciseangia,oldpeak,slope,noofmajorvessels]])
    
    # st.write("after scaleing:",scaler_val)

    try:
    
        prediction=health_model.predict(scaler_val)[0]
        
        # Define messages and colors
        review_status = {
            0: ("✅ The patient is Healthy", "#32CD32"),  # Green
            1: ("❌ The Patient has Heart Disease ", "#FF4500")   # Red-Orange
         }
    
        # Get message and color based on prediction
        message, color = review_status.get(prediction, ("❓ Unknown Prediction", "#808080"))
    
        # Display styled result
        st.markdown(f"""
            <div style="
                padding: 15px; 
                background-color: {color}; 
                border-radius: 10px; 
                text-align: center; 
                font-size: 18px; 
                font-weight: bold; 
                color: white;">
                {message}
            </div>
        """, unsafe_allow_html=True)
    
    except Exception as e:
        st.error(f"⚠️ Error in prediction: {e}")