What Is Machine Learning? How Computers Learn From Data

Yash Ahuja, founder and editor of The Knowledge Pot
Yash Ahuja - Founder & Editor
15 Min Read

Quick answer

Machine learning is a branch of artificial intelligence in which computers learn patterns from examples instead of being programmed with explicit rules. You give a program lots of data, such as photos labelled “cat” or “dog”, and it adjusts its internal settings until it can make accurate predictions on new data it has never seen. It powers spam filters, recommendations, voice assistants, translation and chatbots.

Traditional software follows rules that programmers write by hand. That works well for calculating tax or sorting a list, but it is hopeless for recognising a face or understanding speech. Nobody can write down every rule for what a cat looks like.

Machine learning flips the approach. Instead of writing the rules, we show the computer examples and let it find the rules itself. This guide explains how that works, the main types of machine learning and where it goes wrong. For the bigger picture, see our introduction to artificial intelligence.

Rules vs learning: a simple example

Imagine building a spam filter. The old approach was to write rules: if an email contains the word “lottery”, mark it as spam. Spammers quickly changed their wording, and the rules became a never-ending list.

A machine learning spam filter is trained on millions of emails that people have already marked as spam or not spam. It learns which combinations of words, senders, links and formatting tend to appear in spam, including patterns no human would have thought to write down. When spammers change tactics, the filter can be retrained on new examples.

Traditional programming• Humans write the rules• Input + rules = answer• Breaks on unexpected cases• Easy to explainMachine learning• Computer learns rules from data• Input + examples = rules• Handles messy real-world data• Harder to explain whyTraditional programming• Humans write the rules• Input + rules = answer• Breaks on unexpected cases• Easy to explainMachine learning• Computer learns rules from data• Input + examples = rules• Handles messy real-world data• Harder to explain why
Machine learning learns the rules from examples

How a model learns

At the heart of machine learning is a model: a mathematical function with many adjustable settings, called parameters. At first, the parameters are random, so the model’s predictions are poor.

1Collect dataExamples withknown answers2MakepredictionsModel guesses ontraining data3Measure errorCompare guesses tocorrect answers4AdjustparametersNudge settings toreduce error5Repeat andtestCheck on data ithas never seen1Collect dataExamples with known answers2Make predictionsModel guesses on training data3Measure errorCompare guesses to correct answers4Adjust parametersNudge settings to reduce error5Repeat and testCheck on data it has never seen
The basic training loop behind most machine learning

During training, the model makes predictions, measures how wrong they are, and nudges its parameters slightly to reduce the error. This repeats millions of times. Google’s free Machine Learning Crash Course describes this as minimising a loss function, a number that represents how wrong the model is.

Finally, the model is tested on data held back from training. This shows whether it has learned a genuine pattern or simply memorised the examples, a problem called overfitting.

The three main types of machine learning

Supervised• Learns from labelled examples• Predicts a known answer• Spam filters, price predictionUnsupervised• Finds structure in unlabelled data• Groups and anomalies• Customer segments, fraud spottingReinforcement• Learns by trial and reward• Chooses actions• Game playing, roboticsSupervised• Learns from labelled examples• Predicts a known answer• Spam filters, price predictionUnsupervised• Finds structure in unlabelled data• Groups and anomalies• Customer segments, fraud spottingReinforcement• Learns by trial and reward• Chooses actions• Game playing, robotics
The three main ways machines learn

Supervised learning

The model learns from labelled examples, where the correct answer is provided. It is used for tasks like predicting house prices, recognising objects in photos and detecting fraud. Most practical machine learning is supervised.

Unsupervised learning

The model receives data without labels and looks for structure on its own, such as grouping customers with similar buying habits or spotting unusual transactions. It is useful when you do not know in advance what you are looking for.

Reinforcement learning

The model learns by trial and error, receiving rewards for good actions and penalties for bad ones. It has been used to master games like chess and Go, to control robots and to fine-tune chatbots based on human feedback.

In practice, these approaches are often combined. Large language models, for example, are first trained on huge amounts of unlabelled text, a method called self-supervised learning, then fine-tuned on labelled examples, and finally refined with reinforcement learning from human feedback.

Deep learning and neural networks

Deep learning is a type of machine learning that uses artificial neural networks with many layers. Each layer transforms the data a little, picking out increasingly complex features. In an image model, early layers might detect edges, middle layers shapes, and later layers whole objects like faces or cars.

Deep learning took off in the 2010s thanks to three things: huge amounts of digital data, powerful graphics chips (GPUs) that can do many calculations at once, and better training techniques. It is the foundation of today’s large language models and image generators.

1950Alan Turing asks whether machines can think1959Arthur Samuel coins the term machine learning with a draughts-playing program1997IBM's Deep Blue beats chess champion Garry Kasparov2012AlexNet wins an image contest by a wide margin, sparking the deep learning boom2016DeepMind's AlphaGo beats Go champion Lee Sedol2022ChatGPT brings machine learning to a mass audience1950Alan Turing asks whether machines canthink1959Arthur Samuel coins the term machinelearning with a draughts-playing program1997IBM's Deep Blue beats chess championGarry Kasparov2012AlexNet wins an image contest by a widemargin, sparking the deep learning boom2016DeepMind's AlphaGo beats Go champion LeeSedol2022ChatGPT brings machine learning to amass audience
Milestones in machine learning

A worked example: predicting house prices

Imagine an estate agency with records of 10,000 past home sales. Each record lists features, such as size, number of bedrooms, location and age, along with the final sale price. A supervised learning model is shown these records and learns how each feature tends to affect the price.

At first its guesses are wildly off. After many rounds of adjustment, it learns, for example, that an extra bedroom adds a certain amount, that some neighbourhoods command a premium and that very old houses vary more in price. The agency then tests it on 2,000 sales it never saw during training. If its predictions are close, the model can be used to estimate prices for new listings. If the market changes, such as after a sharp rise in mortgage rates, the model has to be retrained on recent sales.

Where you meet machine learning every day

Everyday useWhat the model does
Email spam filtersClassifies messages as spam or not
Streaming and shopping recommendationsPredicts what you are likely to enjoy or buy
Maps and ride appsPredicts traffic and arrival times
Phone camerasRecognises faces and improves photos
Bank fraud alertsFlags unusual card activity
Voice assistants and translationTurns speech into text and between languages
ChatbotsPredicts the next words in a reply
Common uses of machine learning

The limits and risks

  • Garbage in, garbage out: a model is only as good as its training data. Poor or unrepresentative data leads to poor predictions.
  • Bias: if historical data reflects unfair decisions, a model can learn and repeat that unfairness, for example in hiring or lending.
  • Black boxes: complex models can be hard to explain, which is a problem in medicine, finance and law.
  • Brittleness: models can fail in strange ways when faced with situations unlike their training data.
  • Privacy: training often requires large amounts of personal data.

Because of these risks, governments are introducing rules. The European Union’s AI Act, for example, sets stricter requirements for systems used in high-risk areas such as employment and credit.

Do you need maths to learn machine learning?

To use machine learning tools, no. Many services now let anyone train simple models with a few clicks. To build models professionally, it helps to understand basic statistics, linear algebra and programming, usually in Python. Free courses from universities and technology companies are a good starting point.

A practical path for beginners is to learn basic Python, work through an introductory course, then practise on public datasets from sites such as Kaggle. Building a small project, such as predicting local house prices or classifying photos of plants, teaches more than reading alone.

Machine learning and jobs

Machine learning is automating parts of many jobs, especially repetitive tasks involving sorting, predicting and summarising information. At the same time, it is creating demand for new skills, from data engineering to AI safety and model evaluation. Most economists expect it to change the tasks within jobs more than to eliminate whole professions quickly, but the effects will vary by industry and country, and they are an active area of research.

Key takeaways

  • Machine learning lets computers learn patterns from data instead of following hand-written rules.
  • Training repeatedly adjusts a model’s parameters to reduce its errors.
  • The three main types are supervised, unsupervised and reinforcement learning.
  • Deep learning uses many-layered neural networks and powers modern AI.
  • It is behind spam filters, recommendations, fraud alerts and chatbots.
  • Its results depend on data quality and can reflect bias in that data.

Frequently asked questions

Is machine learning the same as AI?

Machine learning is one way of building AI, and today the most important one. AI is the broader goal of making machines perform tasks that need human-like intelligence.

What is a model in machine learning?

A model is the mathematical system that has learned from data and makes predictions. Training adjusts its internal settings, called parameters.

How much data does machine learning need?

It depends on the task. Simple models can work with hundreds of examples; large language models are trained on trillions of words.

What is overfitting?

Overfitting happens when a model memorises its training examples instead of learning general patterns, so it performs poorly on new data.

What programming language is used for machine learning?

Python is the most popular, with libraries such as scikit-learn, PyTorch and TensorFlow.

Can machine learning be biased?

Yes. If training data reflects unfair patterns, the model can learn them. Careful data selection and testing are needed to reduce bias.

What is the difference between AI, machine learning and deep learning?

AI is the broad field, machine learning is a way of building AI by learning from data, and deep learning is a type of machine learning that uses large neural networks.

Can I try machine learning without coding?

Yes. Tools such as Google’s Teachable Machine let you train simple image or sound models in a web browser.

How long does it take to train a model?

Anything from seconds for a small model on a laptop to months on thousands of specialised chips for the largest AI systems.

Sources

  1. Google: Machine Learning Crash Course
  2. IBM: What is machine learning?
  3. European Commission: AI Act

Keep Reading

Share This Article
Yash Ahuja, founder and editor of The Knowledge Pot
Founder & Editor
Follow:
Yash Ahuja is the founder and editor of The Knowledge Pot. Based in Jaipur, India, he works in digital marketing, SEO and web development, and started The Knowledge Pot to explain tech, money and science in plain English. Every explainer is researched against primary sources and checked before it is published.