File size: 2,339 Bytes
ee16a18
3d5a36e
 
 
ee16a18
3d5a36e
 
ee16a18
3d5a36e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee16a18
3d5a36e
ee16a18
3d5a36e
 
ee16a18
3d5a36e
 
 
 
 
 
 
 
 
 
 
 
 
ee16a18
 
3d5a36e
ee16a18
 
 
 
3d5a36e
 
ee16a18
3d5a36e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import numpy as np
import streamlit as st
import pickle

# تحميل النموذج
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,  # تحويل الجنس إلى رقم (ذكر = 1، أنثى = 0)
        chest_pain,
        blood_pressure,
        cholesterol,
        blood_sugar,
        electrocardiographic_result,
        max_heart_rate,
        exercise_angina,
        oldpeak,
        slope,
        ca,
        thalassemia
    ]
    
    # تحويل البيانات إلى مصفوفة numpy
    input_data_as_numpy_array = np.asarray(input_data)
    
    # إعادة تشكيل البيانات لتناسب التنبؤ (1 صف و 13 عمود)
    input_data_reshape = input_data_as_numpy_array.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}")