---
title: Machine Failure Prediction with SHAP
emoji: 🤖🔧
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 4.12.0
python_version: 3.1
app_file: app.py
pinned: false
license: mit
language:
- en
---
# Machine Failure Prediction with Live SHAP Analysis
This application demonstrates a real-time machine failure prediction model. It allows users to interactively adjust machine parameters and see the immediate impact on the predicted failure probability.
## How it Works
The app uses a `RandomForestClassifier` model trained on a predictive maintenance dataset. For each prediction, it uses the **SHAP (SHapley Additive exPlanations)** library to explain the output.
- **Probability of Machine Failure**: The model's prediction of the likelihood that the machine will fail given the current input parameters.
- **SHAP Waterfall Plot**: This plot visualizes how each feature contributes to pushing the prediction away from the baseline (the average prediction) towards the final probability.
- **Red bars** show features that are increasing the probability of failure.
- **Blue bars** show features that are decreasing the probability of failure.
## How to Use the Demo
1. **Adjust the Sliders**: Use the sliders and the dropdown on the left to change the input values for the machine's operational parameters.
2. **View Real-Time Results**: The "Probability of Machine Failure" and the SHAP plot on the right will update automatically.
3. **Interpret the Plot**: Observe how changing a feature (e.g., increasing 'Tool wear') changes its contribution (the size and color of its bar) in the SHAP plot.