Decision trees are a popular operations research tool to aid decision analysis, providing a tree-like model of decisions and their possible consequences. It is a popular technique in many industries from financial services, healthcare, through to asset heavy industries like mining and oil and gas. In this article we specifically explore its suitability for predictive maintenance using an example Kaggle dataset.
In this introduction to decision trees, we aim to:
- Provide an overview of decision trees and predictive maintenance
- Explore the suitability of decision trees in conducting predictive maintenance using an example Kaggle dataset
- Discuss outcomes and future improvements
What is Predictive Maintenance?
A basic introduction to predictive maintenance is provided in our previously published article that introduces predictive maintenance using the NASA turboengine dataset.
Predictive maintenance (PdM) is maintenance that monitors the performance and condition of equipment during normal operation to reduce the likelihood of failures
http://www.reliableplant.com/
In summary—predictive maintenance is concerned with monitoring the current condition of equipment to predict when maintenance will be required, so the maintenance can be performed at the optimal moment, hopefully reducing costly unplanned downtime.
Decision Trees and Predictive Maintenance
Decision trees are a compelling tool in predictive maintenance because they mirror how engineers and operators think which is through structured, rule-based logic (Patel and Prajapati 2018). At their core, these models evaluate sequential “if-then” conditions such as if vibration is high and operating hours exceed 2,000, then predict failure. The tree begins with a root node, which represents the full dataset and initiates the first split. From there, decision nodes apply yes/no logic based on specific thresholds (e.g., is temperature > 80°C?), progressively segmenting the data. The process ends at leaf nodes, which deliver the final prediction which is typically, failure or no failure.
What makes decision trees especially valuable is their ability to uncover complex interactions between variables during training. Failures rarely stem from a single factor. More often, it’s the combination that signals risk e.g. moderately high torque combined with elevated temperature. Trees automatically learn and capture these layered patterns as part of the training process.
Each split is chosen based on how effectively it separates failure from non-failure cases. The algorithm evaluates every potential threshold using measures like information gain or Gini impurity, which quantify how much uncertainty is reduced by a given split. In simple terms, the model selects the question that brings the most clarity at each step, ensuring that the tree’s structure is both interpretable and statistically grounded.
In practice, we use features like air and process temperature, rotational speed, torque, vibration levels, and total run-time. The model then identifies patterns that consistently precede failures. The result is a transparent ruleset that not only predicts issues early but also surfaces the conditions that lead to them, supporting smarter maintenance decisions and reducing unplanned downtime.
Figure 1: Example Decision Tree for Predictive Maintenance

From Decision Trees to Ensemble Methods: Balancing Transparency and Accuracy
While decision trees provide clear, interpretable logic aligned with how engineers think, they are prone to overfitting, especially on limited or noisy datasets common in predictive maintenance. Ensemble methods such as random forests and gradient boosting build on this foundation, combining multiple trees to improve robustness and predictive accuracy without sacrificing transparency. Random forests aggregate many trees trained in parallel on random data subsets, reducing variance and improving accuracy. Gradient boosting, meanwhile, builds trees sequentially to correct previous errors, achieving higher precision but requiring careful tuning to prevent overfitting.
Advanced Algorithms and Industrial-Scale Implementation
The last decade has seen significant improvements in ensemble algorithms and their practical deployment. Open-source libraries like scikit-learn offer solid baseline implementations, while specialised tools such as LightGBM and CatBoost deliver faster, more scalable solutions tailored for large-scale sensor data and complex machine configurations. These frameworks enhance computational efficiency and simplify feature handling, enabling faster model iteration and deployment in industrial environments.
Snapshot-Based Modelling for Practical Predictive Maintenance
Rather than modelling full time series data, predictive maintenance models often rely on snapshot data, which are individual records capturing a machine’s operational state at a point in time. This approach preserves critical temporal insights, such as the cumulative effect of vibration and runtime on failure risk, without the complexity of sequence modelling. Trained on historical snapshots and validated rigorously, these models can classify real-time machine data to enable early intervention and reduce unplanned downtime.
Customization: The Key to Outperforming Off-the-Shelf Models
Off-the-shelf ensemble models provide a valuable starting point but often fall short in industrial contexts. Custom models incorporate domain knowledge directly, leveraging operational thresholds, historical failure patterns, and tailored loss functions that emphasise the cost of missed failures. They are also better suited to handling imbalanced data where failure events are rare. Through techniques like re-weighting and threshold adjustment, these models prioritise early warning and operational relevance. Finally, custom pruning and ensemble size optimisation strike a balance between predictive power and interpretability delivering actionable insights that integrate seamlessly into maintenance workflows and real-time monitoring systems.
Example: Applying Decision Trees to Predictive Maintenance
Data Overview and Initial Exploration
Our starting point is a cleaned machine sensor readings and operational metrics Kaggle dataset, with the failure outcome transformed into a binary variable indicating whether a failure occurred within a future window.
While the exact duration of the prediction window isn’t specified, the failure label still offers a useful basis for identifying pre-failure patterns and training models to distinguish normal from at-risk conditions.
Figure 2: Dataset Overview

Early data exploration showed no obvious difference between failure and non-failure cases when looking at individual variables like temperature, speed, or torque.
Figure 3: Feature Distribution by Failure Status

Statistical tests including unpaired unequal variance t-tests and Mann-Whitney tests confirmed this observation: no single sensor reading or metric on its own significantly separates failures from normal operation (all p-values > 0.05). This highlights a key challenge in predictive maintenance where failure events are rarely triggered by one factor, but by complex combinations of conditions. Full test results can be found in the codebase here.
Why Use Decision Trees?
Given the lack of simple linear separability in the data, we applied decision trees, which excel at capturing layered “if-then” logic reflecting real-world interactions. By modelling how variables combine, decision trees can detect subtle patterns in the sensor data that precede failures.
Applying Off-the-Shelf Models
Following our exploratory analysis, we prepared the data for modelling. The dataset was split into training and testing sets while preserving the failure-to-no-failure ratio using stratified sampling. To handle categorical variables, we applied one-hot encoding, and numerical features were standardised for consistency.
Because failure events are rare, we applied SMOTE (Synthetic Minority Oversampling Technique) on the training data to generate synthetic samples of the minority failure class, improving the model’s ability to learn these critical patterns.
We then trained and evaluated several classification models, including traditional machine learning algorithms from scikit-learn (Decision Tree, Random Forest, Gradient Boosting, AdaBoost), alongside popular gradient boosting frameworks such as XGBoost, LightGBM, and CatBoost. Each model was trained on the balanced training data and tested on the holdout set using key metrics like precision, recall, F1-score, and accuracy. See full classification report below.
Key Finding
Surprisingly, the straightforward Decision Tree model outperformed both Random Forest and all tested gradient boosting methods. This indicates that, for this dataset and problem, a simple, interpretable model captured essential patterns better than more complex ensembles.
Starting with scikit-learn’s decision trees offers a strong, easy-to-understand baseline before exploring more sophisticated approaches.
Summary of Model Accuracies
| Model | Accuracy |
| Decision Tree | 0.9200 |
| Random Forest | 0.8100 |
| Gradient Boosting: | 0.8300 |
| AdaBoost: | 0.7900 |
| XGBoost | 0.8500 |
| LightGBM | 0.8400 |
| CatBoost | 0.8600 |
While these off-the-shelf models provide a valuable starting point, building custom models tailored to specific domain knowledge remains essential. Custom models can integrate operational thresholds, balance strategies, and splitting criteria that reflect real-world failure dynamics, leading to better performance and more actionable insights.
Custom-built decision tree
We began by building a custom decision tree classifier from the ground up, using entropy-based splits and information gain to create a transparent and interpretable model. To address the class imbalance in the dataset, we applied upsampling techniques to ensure balanced training. This approach allowed us to tailor the splitting criteria and training process specifically to the maintenance failure prediction problem.
Next, we benchmarked this custom decision tree against established scikit-learn algorithms, including Random Forest and Gradient Boosting classifiers. The results aligned with expectations:
- The custom decision tree achieved an accuracy of 0.84,
- The Random Forest improved to 0.89, and
- The Gradient Boosting model significantly outperformed both, achieving an accuracy of 0.96.
Only the custom-built gradient boosting model surpassed the performance of standard libraries, underscoring the strength of boosting techniques in failure prediction tasks. This progression highlights the advantage of ensemble methods over standalone trees and validates our custom implementation as a solid baseline for future experimentation.
Classification Report: Custom Models vs. Off-the-Shelf Decision Tree
A classification report provides a detailed assessment of a machine learning model’s performance on a classification task. It breaks down key metrics like precision, recall, F1-score, and accuracy for each class in this case, “failure” and “no failure.” These metrics help evaluate how well the model identifies rare but critical events, such as equipment failures, and are particularly important in imbalanced datasets common in predictive maintenance.
When benchmarked against the best-performing off-the-shelf decision tree on the Shelf dataset, our custom-built models show significant improvements, particularly in detecting the minority failure class:
| Metric | Off-the-Shelf Decision Tree | Custom-Built Gradient Boosting |
| Accuracy | 0.92 | 0.96 |
| Precision (No Failure) | 0.95 | 1.00 |
| Recall (No Failure) | 0.97 | 0.93 |
| F1-Score (No Failure) | 0.96 | 0.97 |
| Precision (Failure) | 0.40 | 0.93 |
| Recall (Failure) | 0.29 | 1.00 |
| F1-Score (Failure) | 0.33 | 0.96 |
The off-the-shelf model struggles particularly with the minority failure class, reflected in low recall (28.6%) and precision (40.0%), indicating many missed failures and false positives. Conversely, the custom gradient boosting model achieves near-perfect recall and precision for the failure class, effectively detecting all failure cases without compromising performance on the no-failure class. This stark contrast highlights the effectiveness of the custom model’s tailored splitting strategy, balanced training, and boosting methodology, making it a superior choice for critical predictive maintenance applications.
What is feature importance and why does it matter?
Before diving into specific features, it’s important to understand what feature importance tells us. Feature importance reveals which variables the model depends on most to make accurate predictions. In predictive maintenance, this highlights the operational and environmental conditions that have the greatest influence on failure risk. These insights allow maintenance teams to focus their attention where it matters most.
Our custom gradient boosting model identifies “Operational Hours” as the most influential factor in predicting equipment failure, with a feature importance score of 0.5427. For maintenance teams, this emphasises the importance of closely tracking equipment runtime to plan preventive maintenance and avoid costly downtime.
“Air Temperature” is the next most important feature (importance: 0.1312). High or fluctuating temperatures can cause components to overheat or degrade more quickly, underscoring the need to monitor environmental conditions and possibly implement climate control or adjust operating parameters during extreme weather.
Other relevant features include:
- Rotational Speed [rpm]: 0.1034
- Process Temperature [K]: 0.1022
- Torque [Nm]: 0.0575
- Vibration Levels: 0.0562
Low importance was found for categorical variables like “Machine Type”.
Figure 4: Feature Importance

To better understand how these features influence individual predictions, we use SHAP (SHapley Additive exPlanations) values. SHAP helps explain the contribution of each feature on a case-by-case basis, showing whether a factor increases or decreases the risk of failure. This granular interpretability builds trust and allows maintenance teams to make informed decisions grounded in model insights.
Figure 5: SHAP (SHapley Additive exPlanations) Chart

Model Interpretability and Deployment
While standalone decision trees can be visualised fully as simple, intuitive diagrams ideal for explaining decision logic (see example decision tree diagram below) the situation is different for ensemble models like Random Forest and Gradient Boosting. Although it is possible to visualise a single tree from these ensembles, doing so does not provide the full picture, as the overall prediction depends on the combined decisions of many trees. This makes it impractical to display the entire model as a single, comprehensive diagram.
Figure 6: Visualization of a custom-built decision tree

In Summary
Although ensemble methods usually provide superior accuracy and precision compared to a single decision tree, their complexity means they require alternative interpretability tools like SHAP, as well as deployment within user-friendly interactive applications such as Streamlit or Gradio. These platforms allow users to interact with the model, explore feature impacts, and obtain understandable predictions, bridging the gap between model complexity and operational usability.
Predictive maintenance is a critical application of machine learning that transforms raw sensor data into actionable insights, helping to anticipate equipment failures before they occur. Decision trees provide a transparent, rule-based framework that mirrors human decision-making, making them especially valuable for understanding complex interactions in machine sensor data. However, their tendency to overfit and limited accuracy on complex datasets often calls for more robust ensemble approaches like Random Forests and Gradient Boosting.
The example shows that while off-the-shelf models offer a strong starting point, custom-built models tailored with domain expertise, (especially custom gradient boosting) can significantly improve predictive performance and failure detection. This is crucial in industrial settings where missing a failure can have costly consequences. Moreover, feature importance analysis and SHAP explainability reveal key factors such as “Operational Hours” and “Air Temperature” that drive failure risk, providing practical insights for maintenance planning.
Standalone decision trees shine in interpretability, with clear visualisations of their decision paths supporting straightforward communication and decision making. In contrast, ensemble models trade off some interpretability for superior accuracy and require advanced tools like SHAP and interactive deployment platforms (e.g., Streamlit, Gradio) to bridge this gap.
Ultimately, these models, both transparent trees and powerful ensembles, serve as valuable benchmarks and practical tools. They enable maintenance teams not only to predict failures with high confidence but also to understand and act on the underlying causes, driving smarter, more cost-effective maintenance strategies.
By integrating these approaches into real-world systems, organisations can reduce downtime, optimise resource allocation, and extend equipment life, demonstrating the transformative potential of machine learning in predictive maintenance.
The companion codebase for this post can be found here: https://github.com/4CDA/predictive_maintenance_decisiontrees
Reference
Gradient Boosting vs. Random Forest: Which Ensemble Method Should you Choose? https://medium.com/@hassaanidrees7/gradient-boosting-vs-random-forest-which-ensemble-method-should-you-use-9f2ee294d9c6
What is a decision tree? https://www.ibm.com/think/topics/decision-trees
Scikit-learn 1.7.0 documentation. 1.10. Decision Trees. https://scikit-learn.org/stable/modules/tree.html
Patel, H.H. and Prajapati, P., 2018. Study and analysis of decision tree based classification algorithms. International Journal of Computer Sciences and Engineering, 6(10), pp.74-78.
Surucu, O., Gadsden, S.A. and Yawney, J., 2023. Condition monitoring using machine learning: A review of theory, applications, and recent advances. Expert Systems with Applications, 221, p.119738.