Exploratory analysis of machine failure data using pandas and Matplotlib.
- Load and inspect the AI4I 2020 Predictive Maintenance dataset.
- Calculate the overall machine failure rate and rates for each failure type.
- Compare average torque, tool wear, and temperature difference between samples with and without machine failure.
- Visualize failure rates by type.
- Python
- pandas
- Matplotlib
Machine failure status is represented by:
0: No machine failure1: Machine failure
Temperature difference is calculated for each sample as:
Process temperature [K] − Air temperature [K]
Average measurements are compared by machine failure status. The temperature difference chart includes all machine failures; it is not an analysis restricted to HDF.
- Total samples: 10,000
- Samples with machine failure: 339
- Samples without machine failure: 9,661
- Overall machine failure rate: 3.39%
- No missing values were found.
Each rate is calculated relative to all 10,000 samples. A sample can have more than one failure type, so these percentages should not be added to calculate the overall machine failure rate.
| Failure type | Rate (%) |
|---|---|
| TWF | 0.46 |
| HDF | 1.15 |
| PWF | 0.95 |
| OSF | 0.98 |
| RNF | 0.19 |
| Measurement | Without failure | With failure |
|---|---|---|
| Torque (Nm) | 39.63 | 50.17 |
| Tool wear (min) | 106.69 | 143.78 |
| Rotational speed (rpm) | 1540.26 | 1496.49 |
Samples with failure had higher average torque and tool wear, and lower average rotational speed.
Average temperature differences are shown in the chart below
and saved in comparison_summary.csv.
These comparisons describe associations and do not establish causation. This project performs exploratory analysis and does not train a prediction model.
- Install Python.
- Download or clone this repository.
- Ensure
ai4i2020.csvis in the same folder asmain.py. - Open a terminal in the project folder.
- Install the required libraries:
python -m pip install -r requirements.txt- Run the analysis:
python main.pyClose each chart window to continue to the next chart. The script prints analysis results and saves CSV tables and PNG charts in the current working directory.
| File | Contents |
|---|---|
comparison_summary.csv |
Average torque, tool wear, rotational speed, and temperature difference by failure status |
failure_type_rates.csv |
Percentage of all samples with each failure type |
average_torque.png |
Average torque by failure status |
average_tool_wear.png |
Average tool wear by failure status |
average_temperature_difference.png |
Average process minus air temperature by failure status |
failure_type_rates.png |
Failure rates by type |
AI4I 2020 Predictive Maintenance Dataset (2020). UCI Machine Learning Repository.
- Dataset: https://archive.ics.uci.edu/dataset/601/ai4i
- DOI: https://doi.org/10.24432/C5HS5C
- License: CC BY 4.0
- License link: https://creativecommons.org/licenses/by/4.0/
The dataset contains 10,000 synthetic samples representing industrial predictive maintenance conditions.
The original CSV is used without modification. Temperature difference is calculated during analysis as an additional column.



