mlresearchhub/AI_Powered_Pulmonary_Disease_Predictor
๐ฉบ AI-Powered Pulmonary Disease Predictor
This is an interactive Gradio web application that predicts the probability of pulmonary disease based on key health and lifestyle factors.
The app not only provides a risk assessment (Low, Moderate, or High) but also leverages Explainable AI (XAI) to show why it made a specific prediction. This is achieved by generating a SHAP (SHapley Additive exPlanations) waterfall plot that visualizes the contribution of each factor to the final prediction.
โจ Key Features
- Interactive Prediction: Users can input their information through an easy-to-use web form.
- Risk Assessment: The app classifies the prediction into Low, Moderate, or High Risk categories with clear, color-coded feedback.
- Probability Gauge: A custom-built, visually appealing gauge chart displays the exact probability score.
- Explainable AI (XAI): A SHAP waterfall plot is generated to break down the prediction, showing how each user input (e.g., smoking status, energy level) contributed to the final risk score.
- Modern UI: Built with Gradio and custom CSS for a clean, professional, and responsive user experience.
โ๏ธ How It Works: The Technical Pipeline
The application follows a complete machine learning pipeline from feature selection to explainable prediction.
- Feature Selection (mRMR): Before training, the app uses the
mrmr-selectionlibrary to perform Minimum Redundancy Maximum Relevance (mRMR) feature selection. This technique identifies the 7 most impactful features from the dataset, ensuring the model is both efficient and focused on the most relevant information. The selected features are: SMOKERTHROAT_DISCOMFORTSTRESS_IMMUNE_RESPONSEBREATHING_ISSUEENERGY_LEVELFAMILY_HISTORYPOLLUTION_EXPOSURE
- Core Model (CatBoost): The prediction model is a
CatBoostClassifier, a powerful and efficient gradient boosting algorithm known for its great performance, especially with categorical data. The model is trained on the 7 features selected by mRMR.
- Prediction & Explanation (SHAP): When a user submits their data:
- The trained CatBoost model predicts the probability of pulmonary disease.
- A
shap.TreeExplainerobject, created from the trained model, calculates the SHAP values for the user's input. - These values are then visualized as a waterfall plot, where red bars indicate factors that increase the predicted risk and blue bars indicate factors that decrease it.
๐ How to Use the App
- Navigate to the application interface.
- On the left-hand panel ("๐ Please answer the questions:"), fill in your details using the radio buttons and the slider.
- Click the "Get Prediction" button.
- The results will appear on the right-hand panel:
- An overall interpretation of your risk level.
- A gauge chart visualizing the risk probability.
- An expandable section ("๐ก See Prediction Breakdown") that contains the SHAP waterfall plot explaining the prediction.
๐ฆ Files in this Repository
- `app.py`: The main Python script that contains the data loading, model training, and the Gradio interface logic.
- `requirements.txt`: A list of all the Python libraries required to run the application.
- `cleaned_lung_cancer_dataset.csv`: The dataset used to train the CatBoost model. The target variable is
PULMONARY_DISEASE. - `README.md`: This file, providing a detailed explanation of the project.
Disclaimer
This tool is for educational and demonstrational purposes only. It is not a substitute for professional medical diagnosis or advice. Model predictions are based on patterns in data and are not always correct. Please consult a qualified healthcare professional for any health concerns.
