| | import streamlit as st |
| | import numpy as np |
| | import joblib as jl |
| | |
| | model = jl.load('best_model.pkl') |
| |
|
| | |
| | st.title("Heart Attack Risk Prediction") |
| | st.markdown("Enter the following information to predict your risk of a heart attack.") |
| |
|
| | |
| | age = st.number_input("Age", min_value=1, max_value=120, value=30) |
| | sex = st.selectbox("Sex", ["Male", "Female"]) |
| | cp = st.selectbox("Chest Pain Type", [0, 1, 2, 3]) |
| | trtbps = st.number_input("Resting Blood Pressure", min_value=1, max_value=300, value=120) |
| | chol = st.number_input("Serum Cholesterol", min_value=1, max_value=1000, value=200) |
| | fbs = st.selectbox("Fasting Blood Sugar > 120 mg/dl", [0, 1]) |
| | restecg = st.selectbox("Resting Electrocardiographic Results", [0, 1, 2]) |
| | thalachh = st.number_input("Maximum Heart Rate Achieved", min_value=1, max_value=300, value=150) |
| | exng = st.selectbox("Exercise Induced Angina", [0, 1]) |
| | |
| | |
| | caa = st.number_input("Number of Major Vessels Colored by Flourosopy", min_value=0, max_value=4, value=0) |
| | |
| |
|
| | |
| | if st.button("Predict"): |
| | |
| | sex = 1 if sex == "Male" else 0 |
| | input_data = np.array([[age, sex, cp, trtbps, chol, fbs, restecg, thalachh, exng, caa]]) |
| |
|
| | |
| | prediction = model.predict(input_data) |
| |
|
| | |
| | if prediction == 0: |
| | st.markdown("### Result: **Low Risk** of a Heart Attack") |
| | else: |
| | st.markdown("### Result: **High Risk** of a Heart Attack") |
| |
|