File size: 1,700 Bytes
ff75fc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
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.
    -   <span style="color:red;">**Red bars**</span> show features that are increasing the probability of failure.
    -   <span style="color:blue;">**Blue bars**</span> 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.