Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pickle
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
model = pickle.load(open("heart_disease_model.pkl", "rb"))
|
| 6 |
+
|
| 7 |
+
st.title("Heart Disease Prediction App")
|
| 8 |
+
|
| 9 |
+
age = st.number_input("Enter Age", min_value=0, max_value=120)
|
| 10 |
+
sex = st.selectbox("Select Gender", options=["Male", "Female"])
|
| 11 |
+
chest_pain = st.selectbox("Chest Pain Type", options=[1, 2, 3, 4])
|
| 12 |
+
blood_pressure = st.number_input("Enter Blood Pressure", min_value=0)
|
| 13 |
+
cholesterol = st.number_input("Enter Cholesterol Level", min_value=0)
|
| 14 |
+
blood_sugar = st.selectbox("Blood Sugar > 120 mg/dl?", options=[0, 1])
|
| 15 |
+
electrocardiographic_result = st.selectbox("Electrocardiographic Result", options=[0, 1, 2])
|
| 16 |
+
max_heart_rate = st.number_input("Enter Maximum Heart Rate", min_value=0)
|
| 17 |
+
exercise_angina = st.selectbox("Exercise Induced Angina", options=[0, 1])
|
| 18 |
+
oldpeak = st.number_input("Enter Oldpeak", min_value=0.0, max_value=6.0)
|
| 19 |
+
slope = st.selectbox("Slope of the Peak Exercise ST Segment", options=[1, 2, 3])
|
| 20 |
+
ca = st.selectbox("Number of Major Vessels Colored by Fluoroscopy", options=[0, 1, 2, 3])
|
| 21 |
+
thalassemia = st.selectbox("Thalassemia", options=[3, 6, 7])
|
| 22 |
+
|
| 23 |
+
if st.button("Predict"):
|
| 24 |
+
input_data = [
|
| 25 |
+
age,
|
| 26 |
+
1 if sex == "Male" else 0,
|
| 27 |
+
chest_pain,
|
| 28 |
+
blood_pressure,
|
| 29 |
+
cholesterol,
|
| 30 |
+
blood_sugar,
|
| 31 |
+
electrocardiographic_result,
|
| 32 |
+
max_heart_rate,
|
| 33 |
+
exercise_angina,
|
| 34 |
+
oldpeak,
|
| 35 |
+
slope,
|
| 36 |
+
ca,
|
| 37 |
+
thalassemia
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
# تحويل البيانات إلى مصفوفة ثنائية الأبعاد
|
| 41 |
+
input_data_reshape = np.asarray(input_data).reshape(1, -1)
|
| 42 |
+
|
| 43 |
+
# التنبؤ
|
| 44 |
+
prediction = model.predict(input_data_reshape)
|
| 45 |
+
|
| 46 |
+
prediction_text = "Heart Disease Detected" if prediction[0] == 1 else "No Heart Disease Detected"
|
| 47 |
+
|
| 48 |
+
st.write(f"Prediction: {prediction_text}")
|