| import streamlit as st |
| import joblib |
| import numpy as np |
| |
| 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) |
|
|
| |
|
|
| |
| 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:") |
|
|
| |
|
|
| health_model=joblib.load("health_model.joblib") |
|
|
| scaler_model=joblib.load('scaler_the data_model.joblib') |
|
|
| |
|
|
| col1, col2 = st.columns(2) |
| with col1: |
| |
| |
| age=st.slider("Slide the AGE of the Patient:",max_value=80,min_value=20) |
| |
| with col2: |
| |
| |
| 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=st.slider("Slide the chestpain Value:",min_value=0,max_value=3) |
| |
| with col2: |
| |
| restingBP=st.slider("Slide the Resting BP of the Patient:",min_value=90,max_value=200) |
|
|
| col1,col2=st.columns(2) |
| with col1: |
| |
| serumcholestrol=st.slider("Slide The Serum cholestrol Of a Ptient :",min_value=0,max_value=600) |
| |
| with col2: |
| |
| 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=st.slider("Slide The restingrelectro of a Patient :",min_value=0,max_value=2) |
| |
| with col2: |
| |
| 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=st.slider("Slide the exerciseangia Value:",min_value=0,max_value=1) |
| |
|
|
| with col2: |
| |
| 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=st.slider("Silde the slope of the Patient :",max_value=3,min_value=0,value=1) |
| |
| with col2: |
| |
| noofmajorvessels=st.slider("Silde the No of Major Vessels to a Patient :",max_value=3,min_value=0,value=1) |
|
|
|
|
| if st.button("Submit"): |
| |
| |
| |
| |
| scaler_val = scaler_model.transform([[age,gender_value,chestpain,restingBP,serumcholestrol,fastingbloodsugar_value,restingrelectro, |
| maxheartrate,exerciseangia,oldpeak,slope,noofmajorvessels]]) |
| |
| |
|
|
| try: |
| |
| prediction=health_model.predict(scaler_val)[0] |
| |
| |
| review_status = { |
| 0: ("✅ The patient is Healthy", "#32CD32"), |
| 1: ("❌ The Patient has Heart Disease ", "#FF4500") |
| } |
| |
| |
| message, color = review_status.get(prediction, ("❓ Unknown Prediction", "#808080")) |
| |
| |
| 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}") |