Spaces:
Sleeping
Sleeping
| 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 |