Skip to content
Cosvexa – Cosvexa home

Research · Foundations

Machine learning explained

Machine learning is the part of artificial intelligence in which a program improves at a task by learning patterns from data instead of following rules a person wrote by hand. A model is shown examples, measures how wrong its outputs are, and adjusts its internal parameters to be less wrong. The result is a function that can make predictions on new data it has never seen.

Cosvexa team · Published

Abstract editorial illustration of scattered data points flowing into a layered funnel and emerging as a smooth fitted curve, in muted blues and warm accents.

Key points

  • Machine learning replaces hand-written rules with parameters fitted to example data.
  • The three classic settings are supervised, unsupervised and reinforcement learning.
  • Training minimises a loss function; the real test is performance on new, unseen data.
  • Overfitting, biased data and distribution shift are the most common ways models fail.
  • Deep learning and large language models are machine learning at very large scale.

What machine learning is

Machine learning (ML) is a way of building software in which the behaviour of a program is not fully specified by its author. Instead, the author chooses a family of possible functions, called a model, and an algorithm that picks the best member of that family by looking at data. The data shapes the program. Arthur Samuel used the term in the title of his 1959 paper on a checkers-playing program that improved with experience, for example by remembering positions it had already seen and evaluated, which is one of the earliest well-documented examples of a computer getting better at a task through experience.

A widely used textbook definition comes from Tom Mitchell's 1997 book *Machine Learning*: a program learns when its performance on some class of tasks, measured in a stated way, improves with experience. The definition is useful because it forces three questions for any ML system: what is the task, how is success measured, and what experience (data) does the system learn from?

Machine learning sits inside the broader field of artificial intelligence. Not all AI is machine learning: early AI systems such as expert systems encoded human knowledge as explicit rules. Most AI in use today, from spam filters to large language models, is machine learning, because learning from data has proved far more practical than writing rules for messy real-world problems.

How it works: data, model, loss and optimisation

Almost every machine learning system has the same four ingredients.

  • Data. A collection of examples. In supervised learning each example has an input (say, the text of an email) and a target (spam or not spam).
  • A model. A function with adjustable numbers called parameters or weights. A linear model might have one weight per input feature; a modern neural network can have billions.
  • A loss function. A number that says how wrong the model's predictions are on the training examples. Lower is better.
  • An optimiser. A procedure that changes the parameters to reduce the loss. For neural networks this is usually a form of gradient descent, which nudges each parameter in the direction that lowers the loss most quickly.

Training repeats a simple loop many times: take a batch of examples, compute predictions, compute the loss, work out how each parameter contributed to the error, and adjust the parameters slightly. When the loop ends, the parameters are frozen and the model is used for inference, which simply means making predictions on new inputs.

A worked example: predicting house prices

Suppose you have records of 5,000 house sales, each with floor area, number of rooms, distance to the city centre and sale price. You want to predict the price of a house that is about to go on the market.

  1. 1

    Split the data

    Keep about 80% of the sales for training and hold back the rest as a test set the model never sees during training.

  2. 2

    Choose a model

    Start with linear regression: price is predicted as a weighted sum of the features plus a constant. The weights are the parameters.

  3. 3

    Choose a loss

    Use mean squared error: the average of the squared differences between predicted and actual prices.

  4. 4

    Fit

    Run an optimiser to find the weights that minimise the loss on the training set. For linear regression this can even be solved in closed form.

  5. 5

    Evaluate

    Measure the error on the held-out test set. That number, not the training error, is the honest estimate of how the model will do on future houses.

If the error is too high, you might add features (the year the house was built), try a more flexible model (a gradient-boosted tree ensemble or a neural network), or collect more data. This cycle of trying models and measuring them on held-out data is most of the day-to-day work of applied machine learning.

The main kinds of machine learning

SettingWhat the data looks likeTypical tasksExample
Supervised learningInputs paired with correct outputs (labels)Classification, regressionDetecting spam; predicting prices
Unsupervised learningInputs only, no labelsClustering, dimensionality reduction, density estimationGrouping customers by behaviour
Self-supervised learningUnlabelled data where the target is part of the inputPredicting missing or next piecesA language model predicting the next token
Reinforcement learningAn agent's actions and the rewards they earnSequential decision-makingGame-playing programs; robot control

Supervised learning is the most common in industry because the goal is clear: match the labels. Its main cost is labelling, since someone has to provide correct answers for thousands or millions of examples.

Unsupervised learning looks for structure without labels. Clustering algorithms such as k-means group similar examples; methods such as principal component analysis compress data into fewer dimensions while keeping most of its variation.

Self-supervised learning creates labels from the data itself. A model reading text can be asked to predict the next word, and the true next word is already in the text. This is how the pretraining of large language models works, and it is the reason those models can learn from enormous amounts of unlabelled text.

Reinforcement learning (RL) trains an agent that takes actions in an environment and receives rewards. There is no label telling it the right move, only a signal about how good the outcome was. RL is also used after pretraining to shape the behaviour of language models, as in RLHF.

Generalisation: the point of it all

A model that memorises its training data is useless: the goal is to do well on data it has not seen. This ability is called generalisation. Two failure modes frame most of the practical advice in machine learning.

  • Underfitting. The model is too simple to capture the pattern. Training and test error are both high. A straight line cannot fit a curved relationship.
  • Overfitting. The model fits the training data, including its noise, so closely that it does worse on new data. Training error is low but test error is high.

Common defences against overfitting include more training data, regularisation (penalties that discourage extreme parameter values), early stopping (halting training when error on a validation set stops improving), and cross-validation, which rotates which part of the data is held out so that the estimate of performance is less dependent on one lucky split.

A related idea is the split into three sets: a training set to fit parameters, a validation set to choose settings such as model size or learning rate (the so-called hyperparameters), and a test set that is touched only once, at the end. Reusing the test set to make choices quietly turns it into a validation set and makes the final number optimistic.

Common algorithms, from simple to deep

Machine learning is a toolbox, not one method. Practitioners often start simple and move to more complex models only when the data and the problem justify it.

FamilyHow it works in one lineWhere it shines
Linear and logistic regressionWeighted sum of features, optionally squashed into a probabilitySmall data, interpretability, baselines
Decision treesA series of yes/no questions about the featuresReadable rules; mixed feature types
Random forests and gradient-boosted treesMany trees combined by averaging or by fitting each new tree to the previous errorsTabular business data
Support vector machinesFind the boundary with the widest margin between classesMedium-sized classification problems
k-nearest neighboursPredict from the most similar stored examplesSimple similarity tasks
Neural networksLayers of simple units whose weights are learned by gradient descentImages, audio, text and very large datasets

Neural networks with many layers are the subject of deep learning. Their advantage is that they learn useful features directly from raw data such as pixels or characters, rather than relying on features designed by people. On structured, tabular data, tree ensembles remain very competitive and are often the first choice.

Why machine learning matters

Many problems are easy for people to do but hard to describe as rules. Nobody can write down a complete rulebook for recognising a cat in a photo, understanding a spoken sentence or translating idioms. Machine learning sidesteps the rulebook: given enough examples, it finds a function that works well enough to be useful. Jordan and Mitchell's 2015 review in *Science* notes that for many applications it can be far easier to train a system by showing it examples of the desired input-output behaviour than to program it by hand.

The same approach scales from small to very large problems. A logistic regression trained on a spreadsheet and a language model trained on trillions of tokens share the same core logic: a parameterised function, a loss and an optimiser. What changed over the last two decades is the amount of data, the available computing power and the architectures that can use them well.

Limits and common misconceptions

  • "The model understands the task." A model learns statistical regularities in its training data. Whether that amounts to understanding is debated; what is not debated is that it can fail in ways a person would not, especially on inputs unlike its training data.
  • "More data always fixes it." More data helps, but more biased or mislabelled data reproduces the bias at larger scale. Data quality matters as much as quantity.
  • "The model is objective." Models inherit the patterns, including unfair ones, present in their data. See bias and fairness in AI.
  • "High accuracy means it works." Accuracy can mislead on imbalanced problems. If 99% of transactions are legitimate, a model that never flags fraud is 99% accurate and worthless. Precision, recall and cost-weighted metrics tell a fuller story.
  • "Once trained, done." The world changes. When the data a model sees in use drifts away from its training data, a problem called distribution shift, performance can fall quietly. Production systems need monitoring and retraining.

Correlation, not causation

Standard supervised learning finds features that predict the target. It does not by itself establish that changing a feature would change the outcome. Questions about cause and effect need causal methods or experiments.

Where machine learning is going

The dominant trend is toward large, general models trained once with self-supervision and then adapted to many tasks through fine-tuning or prompting. This has moved much everyday ML work from training models from scratch to selecting, adapting and evaluating existing ones. Alongside that, active research areas include learning from less labelled data, making models more efficient to run, making their decisions easier to inspect, and measuring reliably how they behave outside the conditions they were trained in.

Classical techniques are not going away. For many business problems with clean tabular data, a well-tuned tree ensemble is cheaper, faster and easier to explain than a large neural network, and the core discipline of holding out data and measuring honestly applies to every kind of model.

If you work with today's language models rather than training your own, the same habit applies: test candidate models on your own examples before choosing one. Cosvexa lists the models it offers, with their context windows and modalities, on Models, and you can run the same prompt on several of them in Compare.

Frequently asked questions

What is the difference between AI and machine learning?

Artificial intelligence is the broad goal of building systems that perform tasks associated with intelligence. Machine learning is one approach to that goal, in which the system learns from data. Most modern AI systems are built with machine learning, but rule-based systems are also a form of AI.

What is the difference between machine learning and deep learning?

Deep learning is a subset of machine learning that uses neural networks with many layers. It learns features directly from raw data and dominates tasks involving images, audio and language. Other machine learning methods, such as gradient-boosted trees, are often preferred for tabular data.

Do I need a lot of data to use machine learning?

It depends on the task and the model. Simple models can work with hundreds of examples, while deep networks trained from scratch usually need far more. Starting from a pretrained model and fine-tuning it can greatly reduce the data you need.

What is overfitting?

Overfitting happens when a model learns the training data, including its noise, so closely that it performs worse on new data. It shows up as low training error and much higher test error. More data, regularisation and early stopping are common remedies.

Is machine learning the same as statistics?

The two fields overlap heavily and share many methods. Statistics traditionally emphasises inference about how data was generated, while machine learning traditionally emphasises predictive accuracy on new data. In practice the boundary is blurry.

References

  1. Arthur L. Samuel (1959). Some Studies in Machine Learning Using the Game of Checkers
  2. Tom M. Mitchell (1997). Machine Learning
  3. M. I. Jordan and T. M. Mitchell (2015). Machine learning: Trends, perspectives, and prospects
  4. Yann LeCun, Yoshua Bengio and Geoffrey Hinton (2015). Deep learning

More in this section

Start free: 50 Cosvexa-1 questions a day

Every major model in one workspace; on the Free plan Cosvexa-1 answers 50 questions a day. No card needed to start.