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.

What machine learning is

A normal program applies rules that a person wrote. A learned model finds its own rules from examples. You provide data (the inputs, often called features) and usually the right answers (the labels), choose a model family (a line, a tree, a neural network), and a training procedure adjusts the model’s parameters until its predictions match the examples. The model is then used on new inputs. For an engineer that is a tool for relationships that are too complex to write down: estimating a quality that cannot be measured directly, recognizing a fault from vibration, or noticing that today’s data looks different from every earlier day.

It is not magic and it is not the only tool. A model can only reproduce patterns that are in its data; it has no understanding of the physics unless you give it some, and it can be confidently wrong on inputs unlike anything it saw. Most of the work (and most of the failures) is in the data, the testing and the deployment, which is why this guide spends more pages there than on algorithms.

The kinds of learning

TypeLearns fromTypical taskEngineering example
Supervised: regressionInputs with known numbersPredict a numberEstimate moisture from dryer temperatures (a soft sensor); remaining life of a bearing
Supervised: classificationInputs with known categoriesPredict a categoryPass or fail from a camera image; fault type from vibration
Unsupervised: clusteringInputs without labelsFind groupsGroup the operating modes of a machine
Unsupervised: anomaly detectionMostly normal dataFlag the unusualA pump vibrates differently from its usual self
Dimensionality reductionInputs without labelsSummarize many inputs by a fewCompress 200 sensor channels into 3 trends for plotting
Reinforcement learningTrial and error with a rewardLearn a policyA robot learning to walk or grasp, usually in simulation
Self-supervised and foundation modelsVast unlabeled dataGeneral representationsA pretrained image or language model fine-tuned on your small data set

Pages Regression and Curve Fitting and Classification and Metrics cover the supervised tasks; Trees, Clustering and Anomaly Detection covers clustering and anomaly detection; Neural Networks and Deep Learning introduces deep learning.

When to use it, and when not

Use ML when…Use a formula, rule or table when…
the relationship is too complex or unknown to write downthe physics is known and the equation is accurate enough
you have plenty of representative data with answersyou have little data, or only a handful of examples
an occasional wrong answer is acceptable and manageablea wrong answer is dangerous or must be explained to an auditor
the pattern is in images, sound or many noisy channelsa threshold, a lookup table or a trend line does the job
conditions change slowly and you can retrainconditions are fixed and well understood

Worked example: do not model what an equation gives exactly

A 10 kΩ NTC thermistor (B = 3 950 K, 10 kΩ at 25 °C) reads 5 000 Ω. The Beta equation, 1 ÷ T = 1 ÷ T0 + ln(R ÷ R0) ÷ B, gives T = 41.46 °C in one line and needs no data. A neural network trained on a few hundred readings would at best approximate this curve, and would misbehave outside the range it was trained on. Use the equation (see Numerical Methods) and keep ML for what has no equation.

  • Physics plus data is stronger than either. Use the equation for the known part and let a model learn the residual, or feed physical quantities (speed, load, temperature) as inputs.
  • ML is not a safety function. See the limits on Deployment, Monitoring and Limits.
  • Ask whether you can reach the goal without it. A rule that nobody had time to write is not a reason to train a network.

Start from the cost of errors

Before choosing a model, state what each kind of error costs. “95 % accuracy” means nothing until you know what the 5 % costs. In a fault detector a false alarm (stopping a healthy machine) and a miss (running a failing one) rarely cost the same.

Worked example: choosing a detector by cost

Among 10 000 machine-days, 40 are faulty. A false alarm costs $200 (an inspection); a missed fault costs $5 000 (an unplanned stop). Three detectors, differing by how readily they alarm:

DetectorFaults caughtFalse-alarm rateMissesFalse alarmsTotal cost
A: sensitive95 %4.0 %2.0398$89 680
B: balanced85 %1.0 %6.0100$49 920
C: cautious60 %0.2 %16.020$83 984
  • Detector B: balanced is the cheapest at $49 920, even though it is not the most sensitive. The sensitive one drowns the crew in $79 680 of false alarms; the cautious one lets too many faults through.
  • Doing nothing costs 40 × $5 000 = $200 000, so any of these pays for itself. Check this before building anything.
  • Moving the alarm threshold moves you along these rows (see Classification and Metrics). Choose the threshold from the costs, not from a default of 0.5.

Always build a baseline

A baseline is the simplest predictor you could use: the average, last week’s value, a rule of thumb, a straight line. It tells you whether the model earns its complexity and gives you a number to beat. Many projects find that the baseline is nearly good enough.

Worked example: predicting moisture from outlet temperature

  • Ten dryer runs give outlet temperatures 60, 62, 64, 66, 68, 70, 72, 74, 76, 78 °C and product moisture 14.8, 13.9, 13.5, 12.4, 11.9, 10.8, 10.4, 9.3, 8.9, 8.1 %.
  • Baseline: always predict the mean, 11.40 %. Its root-mean-square error is the standard deviation of the data: 2.15 %.
  • Model: a least-squares line, moisture = -0.374 × T + 37.20, has an RMS error of 0.15 % and R² = 0.995. That is a 93 % reduction in error over the baseline, for a model you can check by hand.
  • At 75 °C it predicts 9.16 %. A more complicated model has to beat this to be worth keeping (see Regression and Curve Fitting and Overfitting, Validation and Tuning).
  • These errors are measured on the same ten points the line was fitted to, which flatters it. An honest estimate needs data the model has not seen (see Data Preparation, Splitting and Leakage).

The project workflow

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
The eight steps of a project. Monitoring in service feeds back to data collection.
StepWhat you doCommon mistake
1. Define the problemState what to predict, what counts as success and what an error costsStarting with a method instead of a goal
2. Collect and label dataGather representative data with the right answers (see Data Logging)Data from one machine, one season or one operator
3. Clean and explorePlot it; fix units, gaps and sensor faults; understand itSkipping straight to modeling
4. SplitSeparate training, validation and test data before modelingLetting test information leak into training
5. BaselineBuild the simplest predictorHaving nothing to compare against
6. Model and tuneTrain, compare on the validation set, adjustTuning on the test set
7. EvaluateMeasure once on the held-out test set with the right metricReporting accuracy on imbalanced data
8. Deploy and monitorRun it, log inputs and outputs, check for driftTreating it as finished
  • Spend the time in the early steps. Most improvements come from better data and features, not a fancier model.
  • Keep every experiment reproducible: fix random seeds, version the data and code, and record the library versions.
  • Write down the plan first (goal, data, metric, baseline, deployment target); it is a one-page document that prevents months of drift.

Tools

ToolUse
Python, NumPy, pandasLoading, cleaning and exploring data (see Programming Languages)
scikit-learnClassical ML on tables: regression, trees, clustering, metrics, pipelines
PyTorch, TensorFlow / KerasNeural networks and deep learning
Jupyter notebooksExploring, documenting and sharing experiments
ONNX, TensorFlow Lite, Edge ImpulseMoving trained models to devices (see Deployment, Monitoring and Limits)
MLflow, Git, DVCTracking experiments, data and model versions
OpenCVImage pre-processing and classic vision (see Robotics Tools)
# The smallest complete experiment: baseline, then model, on held-out data
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
baseline = np.full_like(y_test, y_train.mean())
model = LinearRegression().fit(X_train, y_train)
rmse = lambda a, b: mean_squared_error(a, b) ** 0.5
print("baseline", rmse(y_test, baseline), "model", rmse(y_test, model.predict(X_test)))

Vocabulary

TermMeaning
FeatureAn input variable (a temperature, an RMS value)
Label / targetThe answer the model should predict
Training, validation, test setData to fit the model, to choose between models, and to give the final honest score
ParameterA number the training adjusts (a slope, a weight)
HyperparameterA setting you choose before training (tree depth, learning rate)
OverfittingMemorizing the training data, noise included, so that new data does badly
InferenceRunning the trained model on new inputs
DriftThe data or the relationship changing after deployment

Related

FAQ

How much data do I need?

It depends on the model and the problem: tens of points for a straight line, hundreds to thousands for a tree model on a table, thousands to millions for a neural network on images (fewer with a pretrained model). Coverage of the real conditions matters more than quantity.

What is the difference between AI and machine learning?

Artificial intelligence is the broad aim of machines doing tasks that seem intelligent. Machine learning is one way to achieve it: learning from data. Deep learning is machine learning with large neural networks.

Do I need a GPU?

Not for classical models on tables or for small networks. A GPU helps when training deep networks on images or large data sets; running a small trained model needs far less.

Can I just use a hosted AI service?

For text, images and speech, often yes, and it may beat a model you train yourself. Check cost, latency, privacy and what happens when the service is offline or changes.

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.
  • Zinkevich, M., Rules of Machine Learning: Best Practices for ML Engineering, Google (free online).

Last reviewed: October 2026. Costs and rates in the worked example are illustrative: use your own.