| import streamlit as st |
|
|
| st.set_page_config(page_title="Lung Cancer Diagnosis", layout="centered") |
|
|
| st.title("🩺 Lung Cancer Risk Estimator") |
| st.write("Answer the following 10 yes/no questions to estimate your risk of lung cancer.") |
|
|
| symptoms = { |
| "Chronic cough": 10, |
| "Shortness of breath": 10, |
| "Chest pain": 10, |
| "Coughing up blood": 15, |
| "Wheezing": 5, |
| "Unexplained weight loss": 10, |
| "Fatigue": 5, |
| "Loss of appetite": 5, |
| "Recurring respiratory infections": 15, |
| "Hoarseness": 15 |
| } |
|
|
| total_score = 0 |
| max_score = sum(symptoms.values()) |
|
|
| st.subheader("Please answer:") |
|
|
| for symptom, weight in symptoms.items(): |
| response = st.radio(f"{symptom}?", ("No", "Yes"), key=symptom) |
| if response == "Yes": |
| total_score += weight |
|
|
| risk_percentage = round((total_score / max_score) * 100, 2) |
|
|
| st.markdown("---") |
| if st.button("🧮 Calculate Lung Cancer Risk"): |
| st.subheader("Result:") |
| st.write(f"Your estimated lung cancer risk is **{risk_percentage}%**.") |
| if risk_percentage >= 70: |
| st.error("High risk. Please consult a doctor immediately.") |
| elif risk_percentage >= 40: |
| st.warning("Moderate risk. A medical check-up is advised.") |
| else: |
| st.success("Low risk. Stay healthy!") |
|
|
|
|