Diff of /app.py [000000] .. [b8f1d3]

Switch to unified view

a b/app.py
1
import numpy as np
2
import streamlit as st
3
import pickle
4
import time
5
import base64
6
7
bg = "static/bg2.jpg"
8
bg_ext = "jpg"
9
10
st.markdown(
11
    f"""
12
    <style>
13
    .reportview-container {{
14
        background: url(data:image/{bg_ext};base64,{base64.b64encode(open(bg, "rb").read()).decode()})
15
    }}
16
    </style>
17
    """,
18
    unsafe_allow_html=True
19
)
20
21
st.title("Lung Cancer Prediction")
22
st.subheader("Enter Details")
23
24
arr = []
25
26
col1, col2 = st.columns(2)
27
with col1:
28
    x = st.selectbox('Gender',['Male','Female'])
29
    if x=='Male':
30
        arr.append(1)
31
    else:
32
        arr.append(0)
33
34
with col2:
35
    x = st.number_input('Age',0,100,1)
36
    arr.append(x)
37
38
col1, col2, col3 = st.columns(3)
39
with col1:
40
    x = st.selectbox('Smoking',['Yes','No'])
41
    if x=='Yes':
42
        arr.append(1)
43
    else:
44
        arr.append(0)
45
with col2:
46
    x = st.selectbox('Yellow Fingers',['Yes','No'])
47
    if x=='Yes':
48
        arr.append(1)
49
    else:
50
        arr.append(0)
51
with col3:
52
    x = st.selectbox('Anxiety',['Yes','No'])
53
    if x=='Yes':
54
        arr.append(1)
55
    else:
56
        arr.append(0)
57
58
59
col1, col2, col3 = st.columns(3)
60
with col1:
61
    x = st.selectbox('Peer Pressure',['Yes','No'])
62
    if x=='Yes':
63
        arr.append(1)
64
    else:
65
        arr.append(0)
66
with col2:
67
    x = st.selectbox('Chronic Disease',['Yes','No'])
68
    if x=='Yes':
69
        arr.append(1)
70
    else:
71
        arr.append(0)
72
with col3:
73
    x = st.selectbox('Fatigue',['Yes','No'])
74
    if x=='Yes':
75
        arr.append(1)
76
    else:
77
        arr.append(0)
78
79
80
col1, col2, col3 = st.columns(3)
81
with col1:
82
    x = st.selectbox('Allergy',['Yes','No'])
83
    if x=='Yes':
84
        arr.append(1)
85
    else:
86
        arr.append(0)
87
with col2:
88
    x = st.selectbox('Weezing',['Yes','No'])
89
    if x=='Yes':
90
        arr.append(1)
91
    else:
92
        arr.append(0)
93
with col3:
94
    x = st.selectbox('Alcohol Consumption',['Yes','No'])
95
    if x=='Yes':
96
        arr.append(1)
97
    else:
98
        arr.append(0)
99
100
101
col1, col2, col3, col4 = st.columns(4)
102
with col1:
103
    x = st.selectbox('Coughing',['Yes','No'])
104
    if x=='Yes':
105
        arr.append(1)
106
    else:
107
        arr.append(0)
108
with col2:
109
    x = st.selectbox('Shortness Of Breath',['Yes','No'])
110
    if x=='Yes':
111
        arr.append(1)
112
    else:
113
        arr.append(0)
114
with col3:
115
    x = st.selectbox('Swallowing Difficulty',['Yes','No'])
116
    if x=='Yes':
117
        arr.append(1)
118
    else:
119
        arr.append(0)
120
with col4:
121
    x = st.selectbox('Chest Pain',['Yes','No'])
122
    if x=='Yes':
123
        arr.append(1)
124
    else:
125
        arr.append(0)
126
127
128
129
if st.button('Predict'):
130
    lst = np.array(arr).reshape(1, 15)
131
    loaded_model = pickle.load(open("model/lung_cancer.pkl", "rb"))
132
    result = loaded_model.predict(lst)
133
134
    with st.spinner("Predicting.....Have Patience"):
135
        time.sleep(2)
136
    if result==1:
137
        st.error("Chance Of Disease")
138
    if result==0:
139
        st.success("No Chance Of Disease")