Mummia-99's picture
Upload 5 files
5c5de0a verified
raw
history blame
3.12 kB
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.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)
output = health_model.predict(scaler_val)
if output ==0:
st.write("The patient is Healthy")
else:
st.write("The Patient has Heart Disease")