Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
|
|
| 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)
|
|
@@ -20,10 +22,12 @@ 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,
|
|
@@ -37,12 +41,15 @@ if st.button("Predict"):
|
|
| 37 |
thalassemia
|
| 38 |
]
|
| 39 |
|
| 40 |
-
# تحويل البيانات إلى مصفوفة
|
| 41 |
-
|
| 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}")
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
import streamlit as st
|
| 3 |
import pickle
|
|
|
|
| 4 |
|
| 5 |
+
# تحميل النموذج
|
| 6 |
model = pickle.load(open("heart_disease_model.pkl", "rb"))
|
| 7 |
|
| 8 |
+
# واجهة المستخدم
|
| 9 |
st.title("Heart Disease Prediction App")
|
| 10 |
|
| 11 |
age = st.number_input("Enter Age", min_value=0, max_value=120)
|
|
|
|
| 22 |
ca = st.selectbox("Number of Major Vessels Colored by Fluoroscopy", options=[0, 1, 2, 3])
|
| 23 |
thalassemia = st.selectbox("Thalassemia", options=[3, 6, 7])
|
| 24 |
|
| 25 |
+
# عند الضغط على الزر، يتم التنبؤ
|
| 26 |
if st.button("Predict"):
|
| 27 |
+
# تحويل المدخلات للمصفوفة المناسبة للتنبؤ
|
| 28 |
input_data = [
|
| 29 |
age,
|
| 30 |
+
1 if sex == "Male" else 0, # تحويل الجنس إلى رقم (ذكر = 1، أنثى = 0)
|
| 31 |
chest_pain,
|
| 32 |
blood_pressure,
|
| 33 |
cholesterol,
|
|
|
|
| 41 |
thalassemia
|
| 42 |
]
|
| 43 |
|
| 44 |
+
# تحويل البيانات إلى مصفوفة numpy
|
| 45 |
+
input_data_as_numpy_array = np.asarray(input_data)
|
| 46 |
|
| 47 |
+
# إعادة تشكيل البيانات لتناسب التنبؤ (1 صف و 13 عمود)
|
| 48 |
+
input_data_reshape = input_data_as_numpy_array.reshape(1, -1)
|
| 49 |
+
|
| 50 |
+
# التنبؤ باستخدام النموذج
|
| 51 |
prediction = model.predict(input_data_reshape)
|
| 52 |
|
| 53 |
+
# عرض النتيجة
|
| 54 |
prediction_text = "Heart Disease Detected" if prediction[0] == 1 else "No Heart Disease Detected"
|
|
|
|
| 55 |
st.write(f"Prediction: {prediction_text}")
|