CoolFace
Apppublic

mlresearchhub/AI_Powered_Pulmonary_Disease_Predictor

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿฉบ 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.

[image]

โœจ 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.

  1. 1.Feature Selection (mRMR): Before training, the app uses the mrmr-selection library 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:
  2. 2.SMOKER
  3. 3.THROAT_DISCOMFORT
  4. 4.STRESS_IMMUNE_RESPONSE
  5. 5.BREATHING_ISSUE
  6. 6.ENERGY_LEVEL
  7. 7.FAMILY_HISTORY
  8. 8.POLLUTION_EXPOSURE
  1. 1.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.
  1. 1.Prediction & Explanation (SHAP): When a user submits their data:
  2. 2.The trained CatBoost model predicts the probability of pulmonary disease.
  3. 3.A shap.TreeExplainer object, created from the trained model, calculates the SHAP values for the user's input.
  4. 4.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

  1. 1.Navigate to the application interface.
  2. 2.On the left-hand panel ("๐Ÿ“‹ Please answer the questions:"), fill in your details using the radio buttons and the slider.
  3. 3.Click the "Get Prediction" button.
  4. 4.The results will appear on the right-hand panel:
  5. 5.An overall interpretation of your risk level.
  6. 6.A gauge chart visualizing the risk probability.
  7. 7.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.