Machine Learning
How to learn from data in engineering: when to use machine learning, data preparation, regression, classification, trees and clustering, validation, signal features, neural networks and deployment, with worked numbers.
Machine learning (ML) builds a model from examples instead of from explicit rules: you give it data (and usually the right answers) and a method, and it finds a pattern that you can apply to new data. For engineers that means predicting a quantity that is hard to model, classifying an image or a signal, or noticing that a machine behaves differently from normal. It is powerful, but it is mostly data handling and honest testing, with a little algorithm on top. This guide takes the whole path in nine pages: what ML is and when to use it, preparing and splitting data, regression, classification, trees and clustering, overfitting and validation, features for signals and machines, neural networks, and deployment with its limits. Every worked number is computed from the data shown so that you can check your own results against it. The data comes from Data Logging and the code runs in Python (see Programming Languages).
Start here: what do you need?
| I need to… | Go to |
|---|---|
| decide whether ML is the right tool, or plan a project | What Machine Learning Is and When to Use It |
| clean data, split it properly, or find out why test results look too good | Data Preparation, Splitting and Leakage |
| fit a line or curve, calibrate a sensor, or predict a number | Regression and Curve Fitting |
| classify faults, set an alarm threshold, or choose between precision and recall | Classification and Metrics |
| use trees, find operating modes, or detect something unusual | Trees, Clustering and Anomaly Detection |
| stop a model memorizing, tune it, or trust a validation score | Overfitting, Validation and Tuning |
| turn vibration, current or sound into features a model can use | Features for Signals and Machines |
| understand neural networks, training and learning rates | Neural Networks and Deep Learning |
| run a model on a microcontroller, monitor it or know its limits | Deployment, Monitoring and Limits |
A suggested order
Start with What Machine Learning Is and When to Use It and Data Preparation, Splitting and Leakage, because data quality and honest splitting decide most outcomes. Then learn the two basic tasks, Regression and Curve Fitting and Classification and Metrics, before the broader Trees, Clustering and Anomaly Detection. Overfitting, Validation and Tuning and Features for Signals and Machines are what turn a demo into something useful on real machines; Neural Networks and Deep Learning comes after you can beat a simple baseline; Deployment, Monitoring and Limits closes the loop.
- What Machine Learning Is and When to Use It: Supervised, unsupervised and reinforcement learning, when a formula beats a model, the project workflow and how to set a baseline.
- Data Preparation, Splitting and Leakage: Cleaning, scaling, class imbalance, training, validation and test splits, time-ordered data, cross-validation and how leakage fools you.
- Regression and Curve Fitting: Least squares, R², several inputs, polynomial and regularized fits, residual plots and the danger of extrapolation.
- Classification and Metrics: Logistic regression, thresholds, the confusion matrix, precision, recall, F1, ROC and AUC, and choosing a metric from the cost of errors.
- Trees, Clustering and Anomaly Detection: Decision trees and random forests, nearest neighbors, k-means, z-score and isolation-style anomaly detectors, with computed examples.
- Overfitting, Validation and Tuning: Underfitting and overfitting computed on real fits, learning curves, regularization, hyperparameter search and keeping the test set honest.
- Features for Signals and Machines: Windows, RMS, crest factor, kurtosis, spectrum bands, bearing frequencies and operating conditions: the features that make condition monitoring work.
- Neural Networks and Deep Learning: Neurons, layers, activations, a forward pass by hand, gradient descent and learning rate, convolutional networks and pretrained models.
- Deployment, Monitoring and Limits: Models on microcontrollers, quantization and memory budgets, drift monitoring, retraining, safety limits and a troubleshooting table.
The project loop
| Step | Question to answer | Where to look |
|---|---|---|
| Define | What do I predict, and what does a wrong answer cost? | What Machine Learning Is and When to Use It |
| Data | Is it representative, correctly labeled and split without leakage? | Data Preparation, Splitting and Leakage |
| Baseline and model | What is the simple method, and does anything beat it? | Regression and Curve Fitting, Classification and Metrics, Trees, Clustering and Anomaly Detection |
| Validate | Is the score honest, and is the model too complex? | Overfitting, Validation and Tuning |
| Features | Do the inputs carry the physics? | Features for Signals and Machines |
| Deploy | Does it fit, run, and stay accurate? | Deployment, Monitoring and Limits |
Quick reference: formulas and rules
| Topic | Formula or rule | Page |
|---|---|---|
| Least squares | m = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², b = ȳ − m x̄ | Regression and Curve Fitting |
| R² | 1 − SSE ÷ SST | Regression and Curve Fitting |
| Precision, recall | TP ÷ (TP + FP), TP ÷ (TP + FN) | Classification and Metrics |
| F1 | 2 TP ÷ (2 TP + FP + FN) | Classification and Metrics |
| Gini impurity | 1 − Σ p² | Trees, Clustering and Anomaly Detection |
| z-score | (x − μ) ÷ σ; alarm above 3 | Trees, Clustering and Anomaly Detection |
| RMS and crest factor | √(mean of x²); peak ÷ RMS | Features for Signals and Machines |
| Gradient step | w ← w − η ∂L/∂w | Neural Networks and Deep Learning |
| Model size | parameters × bytes per parameter | Deployment, Monitoring and Limits |
| Typical split | about 70 % train, 15 % validation, 15 % test; by time for time series | Data Preparation, Splitting and Leakage |
Related guides and tools
- Data Logging: collecting, timing and checking the data a model learns from.
- Programming Languages: Python, numerical methods, filters and data files.
- Embedded Systems: the microcontroller side of edge deployment.
- Robotics Tools: perception and learning in robots.
- Sensors and Field Devices and Motion Control and Actuators: the signals behind the features.
Safety and responsibility
- A learned model is not a safety function. It has no guaranteed behavior on inputs unlike its training data. Where a wrong answer can hurt people, protection must be a rated, deterministic device; keep ML advisory or in monitoring (see Deployment, Monitoring and Limits).
- Test on conditions you have not seen, not only the average ones, and decide in advance what action follows each alert and who checks it.
- Data may be personal or confidential: camera images, location and occupancy records need consent, access control and a stated purpose.
- Keep a person in the loop for decisions that matter, at least until the system has a long documented record.
FAQ
How much data do I need?
A straight-line fit needs tens of points, a random forest on a table hundreds to thousands, a neural network on images thousands to millions (fewer with a pretrained model). Coverage of the conditions you will meet matters more than raw quantity. See Data Preparation, Splitting and Leakage.
Do I need deep learning?
Usually not for tables of sensor numbers, where trees and simple models often win. Deep learning shines on images, audio and other raw data, especially with a pretrained network. See Neural Networks and Deep Learning.
Why did my model do well in testing and badly in service?
Most often leakage, training data that does not cover real conditions, or change over time. See Data Preparation, Splitting and Leakage and Deployment, Monitoring and Limits.
Where did the old Machine Learning sections go?
All of them are in this guide with much more depth: the workflow, data, regression, classification, models, overfitting, features, edge deployment, limits and troubleshooting each have a place in the nine pages.
References
- James, G., Witten, D., Hastie, T. and Tibshirani, R., An Introduction to Statistical Learning, Springer (free online).
- Géron, A., Hands-On Machine Learning with Scikit-Learn, Keras and TensorFlow, O’Reilly; Hastie, T., Tibshirani, R. and Friedman, J., The Elements of Statistical Learning.
- Goodfellow, I., Bengio, Y. and Courville, A., Deep Learning, MIT Press; Warden, P. and Situnayake, D., TinyML, O’Reilly; the scikit-learn user guide.
Last reviewed: October 2026. Validate any model on realistic data before relying on it, and never make it the only protection against a hazard.
