Spaces:
Sleeping
Sleeping
File size: 1,572 Bytes
741c10e |
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 |
import streamlit as st
import pandas as pd
def get_user_input() -> pd.DataFrame:
"""
Render Streamlit widgets for each predictor and
return a 1-row DataFrame ready for prediction.
"""
st.sidebar.header('Patient Information')
inputs = {
'GENDER': st.sidebar.selectbox('Gender', ['Male', 'Female']),
'SMOKING': st.sidebar.selectbox('Smoking', ['YES', 'NO']),
'YELLOW_FINGERS': st.sidebar.selectbox('Yellow Fingers', ['YES', 'NO']),
'ANXIETY': st.sidebar.selectbox('Anxiety', ['YES', 'NO']),
'PEER_PRESSURE': st.sidebar.selectbox('Peer Pressure', ['YES', 'NO']),
'CHRONIC DISEASE': st.sidebar.selectbox('Chronic Disease', ['YES', 'NO']),
'FATIGUE ': st.sidebar.selectbox('Fatigue', ['YES', 'NO']),
'ALLERGY ': st.sidebar.selectbox('Allergy', ['YES', 'NO']),
'WHEEZING': st.sidebar.selectbox('Wheezing', ['YES', 'NO']),
'ALCOHOL CONSUMING': st.sidebar.selectbox('Alcohol Consuming', ['YES', 'NO']),
'COUGHING': st.sidebar.selectbox('Coughing', ['YES', 'NO']),
'SHORTNESS OF BREATH': st.sidebar.selectbox('Shortness of Breath', ['YES', 'NO']),
'SWALLOWING DIFFICULTY': st.sidebar.selectbox('Swallowing Difficulty', ['YES', 'NO']),
'CHEST PAIN': st.sidebar.selectbox('Chest Pain', ['YES', 'NO'])
}
# Convert to DataFrame
df = pd.DataFrame(inputs, index=[0])
mapping = {'YES': 1, 'NO': 0, 'Male': 0, 'Female': 1}
for col in df.columns:
df[col] = df[col].map(mapping)
return df |