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 projectWhat Machine Learning Is and When to Use It
clean data, split it properly, or find out why test results look too goodData Preparation, Splitting and Leakage
fit a line or curve, calibrate a sensor, or predict a numberRegression and Curve Fitting
classify faults, set an alarm threshold, or choose between precision and recallClassification and Metrics
use trees, find operating modes, or detect something unusualTrees, Clustering and Anomaly Detection
stop a model memorizing, tune it, or trust a validation scoreOverfitting, Validation and Tuning
turn vibration, current or sound into features a model can useFeatures for Signals and Machines
understand neural networks, training and learning ratesNeural Networks and Deep Learning
run a model on a microcontroller, monitor it or know its limitsDeployment, 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.

  1. 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.
  2. Data Preparation, Splitting and Leakage: Cleaning, scaling, class imbalance, training, validation and test splits, time-ordered data, cross-validation and how leakage fools you.
  3. Regression and Curve Fitting: Least squares, R², several inputs, polynomial and regularized fits, residual plots and the danger of extrapolation.
  4. Classification and Metrics: Logistic regression, thresholds, the confusion matrix, precision, recall, F1, ROC and AUC, and choosing a metric from the cost of errors.
  5. Trees, Clustering and Anomaly Detection: Decision trees and random forests, nearest neighbors, k-means, z-score and isolation-style anomaly detectors, with computed examples.
  6. Overfitting, Validation and Tuning: Underfitting and overfitting computed on real fits, learning curves, regularization, hyperparameter search and keeping the test set honest.
  7. Features for Signals and Machines: Windows, RMS, crest factor, kurtosis, spectrum bands, bearing frequencies and operating conditions: the features that make condition monitoring work.
  8. Neural Networks and Deep Learning: Neurons, layers, activations, a forward pass by hand, gradient descent and learning rate, convolutional networks and pretrained models.
  9. Deployment, Monitoring and Limits: Models on microcontrollers, quantization and memory budgets, drift monitoring, retraining, safety limits and a troubleshooting table.

The project loop

A machine learning project is a loop, not a line1 Definegoal and cost of errors2 Collectand label data3 Cleanand explore4 Splittrain, validate, test5 Baselinesimplest predictor6 Modeltrain and tune7 Evaluateonce, on the test set8 Deployand monitornew data, drift or poor results send you back to collection and features
A machine learning project is a loop: monitoring in service sends you back to the data.
StepQuestion to answerWhere to look
DefineWhat do I predict, and what does a wrong answer cost?What Machine Learning Is and When to Use It
DataIs it representative, correctly labeled and split without leakage?Data Preparation, Splitting and Leakage
Baseline and modelWhat is the simple method, and does anything beat it?Regression and Curve Fitting, Classification and Metrics, Trees, Clustering and Anomaly Detection
ValidateIs the score honest, and is the model too complex?Overfitting, Validation and Tuning
FeaturesDo the inputs carry the physics?Features for Signals and Machines
DeployDoes it fit, run, and stay accurate?Deployment, Monitoring and Limits

Quick reference: formulas and rules

TopicFormula or rulePage
Least squaresm = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², b = ȳ − m x̄Regression and Curve Fitting
R²1 − SSE ÷ SSTRegression and Curve Fitting
Precision, recallTP ÷ (TP + FP), TP ÷ (TP + FN)Classification and Metrics
F12 TP ÷ (2 TP + FP + FN)Classification and Metrics
Gini impurity1 − Σ p²Trees, Clustering and Anomaly Detection
z-score(x − μ) ÷ σ; alarm above 3Trees, Clustering and Anomaly Detection
RMS and crest factor√(mean of x²); peak ÷ RMSFeatures for Signals and Machines
Gradient stepw ← w − η ∂L/∂wNeural Networks and Deep Learning
Model sizeparameters × bytes per parameterDeployment, Monitoring and Limits
Typical splitabout 70 % train, 15 % validation, 15 % test; by time for time seriesData Preparation, Splitting and Leakage

Related guides and tools

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.