File size: 2,246 Bytes
f930536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
57
58
59
import streamlit as st
import pandas as pd
import joblib

model = joblib.load('model.pkl')

st.title('🫁 Lung Cancer Diagnosis')
st.write("Please fill out the following information to assess the likelihood of lung cancer.")

gender = st.selectbox('Gender', [0, 1], format_func=lambda x: "Female" if x == 0 else "Male")
age = st.number_input('Age', max_value=120, value=0)
smoking = st.selectbox('Smoking', ['Yes', 'No'])
yellow_fingers = st.selectbox('Yellow Fingers', ['Yes', 'No'])
anxiety = st.selectbox('Anxiety', ['Yes', 'No'])
peer_pressure = st.selectbox('Peer Pressure', ['Yes', 'No'])
chronic_disease = st.selectbox('Chronic Disease', ['Yes', 'No'])
fatigue = st.selectbox('Fatigue', ['Yes', 'No'])
allergy = st.selectbox('Allergy', ['Yes', 'No'])
wheezing = st.selectbox('Wheezing', ['Yes', 'No'])
alcohol = st.selectbox('Alcohol Consuming', ['Yes', 'No'])
coughing = st.selectbox('Coughing', ['Yes', 'No'])
shortness_of_breath = st.selectbox('Shortness of Breath', ['Yes', 'No'])
swallowing_difficulty = st.selectbox('Swallowing Difficulty', ['Yes', 'No'])
chest_pain = st.selectbox('Chest Pain', ['Yes', 'No'])

# Convert inputs to numerical (assuming 1 = Yes, 0 = No)
def binary_encode(value):
    return 1 if value == 'Yes' else 0

data = pd.DataFrame([[
    gender,
    age,
    binary_encode(smoking),
    binary_encode(yellow_fingers),
    binary_encode(anxiety),
    binary_encode(peer_pressure),
    binary_encode(chronic_disease),
    binary_encode(fatigue),
    binary_encode(allergy),
    binary_encode(wheezing),
    binary_encode(alcohol),
    binary_encode(coughing),
    binary_encode(shortness_of_breath),
    binary_encode(swallowing_difficulty),
    binary_encode(chest_pain)
]], columns=[
    'GENDER', 'AGE', 'SMOKING', 'YELLOW_FINGERS', 'ANXIETY', 'PEER_PRESSURE',
 'CHRONIC DISEASE', 'FATIGUE', 'ALLERGY', 'WHEEZING', 'ALCOHOL CONSUMING',
 'COUGHING', 'SHORTNESS OF BREATH', 'SWALLOWING DIFFICULTY', 'CHEST PAIN'
])

# Predict button
if st.button('Predict'):
    prediction = model.predict(data)[0]
    if prediction == 1:
        st.error("⚠️ High risk of lung cancer. Please consult a doctor.")
    else:
        st.success("✅ No Lung Cancer.")