pppp / appp.py
Sarah0022's picture
Upload 3 files
f3721c9 verified
import streamlit as st
import pickle
import numpy as np
model = pickle.load(open("heart_disease_model.pkl", "rb"))
st.title("Heart Disease Prediction App")
age = st.number_input("Enter Age", min_value=0, max_value=120)
sex = st.selectbox("Select Gender", options=["Male", "Female"])
chest_pain = st.selectbox("Chest Pain Type", options=[1, 2, 3, 4])
blood_pressure = st.number_input("Enter Blood Pressure", min_value=0)
cholesterol = st.number_input("Enter Cholesterol Level", min_value=0)
blood_sugar = st.selectbox("Blood Sugar > 120 mg/dl?", options=[0, 1])
electrocardiographic_result = st.selectbox("Electrocardiographic Result", options=[0, 1, 2])
max_heart_rate = st.number_input("Enter Maximum Heart Rate", min_value=0)
exercise_angina = st.selectbox("Exercise Induced Angina", options=[0, 1])
oldpeak = st.number_input("Enter Oldpeak", min_value=0.0, max_value=6.0)
slope = st.selectbox("Slope of the Peak Exercise ST Segment", options=[1, 2, 3])
ca = st.selectbox("Number of Major Vessels Colored by Fluoroscopy", options=[0, 1, 2, 3])
thalassemia = st.selectbox("Thalassemia", options=[3, 6, 7])
if st.button("Predict"):
input_data = [
age,
1 if sex == "Male" else 0,
chest_pain,
blood_pressure,
cholesterol,
blood_sugar,
electrocardiographic_result,
max_heart_rate,
exercise_angina,
oldpeak,
slope,
ca,
thalassemia
]
# تحويل البيانات إلى مصفوفة ثنائية الأبعاد
input_data_reshape = np.asarray(input_data).reshape(1, -1)
# التنبؤ
prediction = model.predict(input_data_reshape)
prediction_text = "Heart Disease Detected" if prediction[0] == 1 else "No Heart Disease Detected"
st.write(f"Prediction: {prediction_text}")