Machine learning works by using data, a model, an objective function and an optimisation procedure to produce a system whose parameters are adjusted so that its outputs become more useful for a defined task. The precise process varies according to the learning paradigm and model architecture, but a typical workflow involves collecting and preparing data, defining the learning objective, selecting a model, training its parameters, evaluating performance on data not used directly for parameter fitting and deploying the resulting model for inference. During training, the model receives examples, produces outputs and is evaluated according to a loss or reward signal. An optimisation algorithm then changes its parameters. Repeating this process many times can cause the model to encode patterns that support predictions on new data.
In supervised learning, each training example generally contains an input and a target output. Consider a model trained to classify photographs as containing cats or dogs. The input is the image, and the target is its assigned class. The model produces a prediction, and a loss function measures the discrepancy between the prediction and the target. The training algorithm uses this error information to adjust model parameters.
With a neural network, backpropagation calculates gradients through the computational graph and an optimiser such as stochastic gradient descent updates the weights. Across many examples and training iterations, the model can become increasingly effective at mapping image representations to the desired labels. The final model is then evaluated on examples it did not directly use for parameter fitting.
Regression uses a similar learning process but predicts numerical values rather than discrete categories. A model might estimate house prices from property characteristics, forecast demand from historical observations or predict a continuous physical measurement. The loss function could measure squared or absolute prediction error, and optimisation adjusts parameters to reduce the loss over the training data. Classification instead predicts categories or probability distributions over categories. More complex tasks can involve structured outputs, ranking, sequence prediction or generation. In every case, the learning process requires a defined objective because the algorithm needs some criterion by which alternative parameter values can be compared. What the system learns is therefore shaped not only by data but by how success is mathematically defined.
Unsupervised learning does not require explicit target labels in the same way. Clustering algorithms can group observations according to similarity, while dimensionality-reduction methods can produce compact representations that preserve selected aspects of data structure. Other unsupervised approaches model the distribution of data or identify unusual observations. Self-supervised learning is particularly important in modern AI because the training signal can be generated automatically from large datasets. For example, a language model can be trained to predict a missing or subsequent token using the surrounding text as context. The text itself supplies the information needed to construct the training objective, avoiding the need for humans to label every training example manually.
Reinforcement learning works through interaction rather than a fixed collection of input-target pairs. An agent observes a state, selects an action and receives information from the environment, often including a reward or penalty. The objective is to learn a policy or value representation that improves long-term reward. The problem can involve delayed consequences, exploration of actions and uncertainty about which behaviours will produce future benefits. Reinforcement learning has been used in games, robotics, resource management, recommendation and other sequential decision problems. It differs from ordinary supervised learning because the correct action is not necessarily supplied directly for each state; the system must learn from consequences and feedback.
Neural-network training commonly relies on gradient-based optimisation. The model computes an output through a sequence of differentiable operations. A loss function compares the output with a target or other training signal. Backpropagation applies the chain rule of calculus to calculate the gradient of the loss with respect to each parameter. An optimiser then updates parameters in a direction intended to reduce the loss, often using a learning rate and possibly additional mechanisms such as momentum or adaptive scaling. Training proceeds in batches of examples, with repeated parameter updates over multiple epochs or training steps. Large models can require substantial computational resources, including specialised accelerators, memory and distributed training systems.
Evaluation is essential because low training error does not necessarily imply useful real-world behaviour. A model may memorise characteristics of its training data, exploit accidental correlations or perform poorly on a changed population. Validation data can help select hyperparameters and model configurations, while a separate test set can provide an estimate of performance after model selection.
Evaluation metrics depend on the task: accuracy, precision, recall, F1 score, calibration, mean squared error, ranking metrics and task-specific measures can all be appropriate in different circumstances. Production monitoring can detect changes in input distributions, performance, latency and error rates. For safety-critical or high-impact applications, evaluation may also need robustness, fairness, security and human-factors testing.
After training, machine learning enters inference, where the learned model processes new inputs and produces outputs. Deployment can occur on servers, cloud infrastructure, mobile devices, browsers, embedded systems or specialised hardware. Real-world data may differ from training data, creating distribution shift and potentially degrading performance. Models can also become outdated as user behaviour, language, markets or physical environments change. Retraining, fine-tuning, recalibration or replacement may therefore be necessary.
Machine learning works successfully when the learning objective, data, model, optimisation process and deployment environment align with the desired task. It fails when those assumptions break down, which is why a trained model should be treated as a component of an engineered system rather than as an automatically reliable source of decisions.