top of page
  • Writer's pictureCraig Risi

What is Machine Learning and How Does It Work

Updated: Aug 5, 2022

This article first appeared on Snapt.

In a previous article, we provided an introduction to artificial intelligence (AI) and the different learning types. Machine learning (ML) is one of the biggest types of AI development—and the one that gets the most attention from many companies.

The rapid evolution of ML has caused a subsequent rise in the use cases and demands. Big data has also become a buzzword. Machine learning has also changed the way data extraction and interpretation are done, sometimes replacing traditional statistical techniques.

But why are so many companies investing vast amounts of money in the field of ML? What exactly is ML, and how does it work?

This guide will introduce you to ML concepts, types of learning, and why it’s important.

What Is Machine Learning, Exactly?

At its core, ML is the ability of software applications to learn from experience (or to be accurate, from data) like humans do, without direct programming. When exposed to new data, these applications learn, grow, change, and develop by themselves. In other words, ML involves computers finding insightful information without being told where to look. Instead, they do this by leveraging algorithms that learn from data in an iterative process.

Machine learning can also be described as the ability of a machine to adapt to new data independently and through iterations. Applications learn from previous computations and transactions and use “pattern recognition” to produce reliable and informed results.


The nature of this “learning” is not infinite, though, and a computer’s ability to learn and make decisions is still confined by the algorithms that have shaped its learning process, the purpose of the algorithm, the problem it is trying to solve, and the data that is being fed to it.

How Does Machine Learning Work?

Machine learning is undoubtedly one of the most exciting subsets of artificial intelligence. It accomplishes the task of learning from data with specific inputs to the machine. It’s important to understand what makes ML work and, thus, how it can be used in the future.

Maths and Coding

Although the description given earlier in this article says that ML doesn’t involve direct programming, that doesn’t mean it works without code—far from it. Rather, the various models and algorithms that shape how a machine learns are all driven by code and computer science principles. This is why there is such a big need for coding skills in the ML space: even if you have a data scientist devise a mathematical model that can help shape different data into a line of thinking, this still needs to be programmed.


The way a computer approaches learning, though, is all built around models. These models are largely mathematical and consist of a series of algorithms built around a limited data set. Once the models are devised and developed, we can measure their effectiveness by inputting training data into the developed algorithm and analyzing its output. The training data are often a combination of known and unknown data used to develop the final ML algorithm, depending on the needs of the specific learning model.

Testing and Adaptation

New input data are fed into the ML algorithm to test whether the algorithm works correctly. The prediction and result are then checked against each other. If the prediction and result don’t match, the algorithm is either re-trained multiple times until the data engineers get the desired outcome or the algorithm adapts to better lead the machine toward the desired result. This enables the ML algorithm to continually learn on its own and produce the optimal answer, gradually increasing its accuracy over time.

Growth vs Efficiency

One of the key differences between ML algorithms and traditional computer programming is that whereas most software solves a specific problem by taking inputs and producing a set of outputs, in ML, we are less interested in trying to find the shortest way to a solution but rather in how a computer can process the data and learn from it. The idea is that this will help the computer analyze the data, perhaps identify better solutions, and gain insight from the data that could not be derived from traditionally structured code.

What Are the Different Types of Machine Learning?

We know that ML involves computers learning from data. But how exactly does it do this? What are the different approaches to ML and how can they produce different outputs?

There are many types of learning algorithms, but they are commonly categorized into supervised or unsupervised learning.

Each learning type is useful for different purposes, forms of data, and predictive capabilities.

Approximately 70% of ML is supervised learning, while unsupervised learning accounts for anywhere from 10% to 20%. The remainder is taken up by reinforcement learning.

1. Supervised Learning

In supervised learning, we use known or labeled data for training. Since the data are known, the learning is therefore supervised (i.e., directed into successful execution). The input data goes through the ML algorithm and is used to train the model. Once the model is trained based on known data, you can run the model on unknown data to get a new response.

Image recognition tools represent a common example of this type of application. If we use a supervised learning approach for image recognition, the model will try to figure out whether the data represents an apple or another fruit. Once the model has been trained well, it will identify that the data represents, for example, an apple and consistently give the desired response.

Supervised Learning Algorithms

Popular algorithms that use this technique are:

  • Polynomial regression

  • Random forest

  • Linear regression

  • Logistic regression

  • Decision trees

  • K-nearest neighbors

  • Naive Bayes.

2. Unsupervised Learning

In unsupervised learning, the training data are unknown and unlabeled, meaning that no one has looked at the data before. Without the aspect of known data, the input cannot guide the algorithm, which is where the unsupervised term originates from.

These data are fed to the ML algorithm and used to train the model. The trained model tries to search for a pattern and gives a response. It is often as if the algorithm is trying to break a code—like the Enigma machine—but without the human mind being directly involved.

Going back to our image recognition use case, if we use unsupervised learning, the unknown data might consist of apples and pears, which look similar to each other. The trained model tries to put them all together so that you get the same things in similar groups.

Unsupervised Learning Algorithms

Popular unsupervised learning algorithms include:

  • Partial least squares

  • Fuzzy means

  • Singular value decomposition

  • K-means clustering

  • Apriori

  • Hierarchical clustering

  • Principal component analysis

3. Reinforcement Learning

As in the case of traditional types of data analysis, a reinforcement learning algorithm discovers data through a process of trial and error and then decides what action results in higher rewards.

Three major components make up reinforcement learning: the agent, the environment, and the actions. The agent is the learner or decision-maker, the environment includes everything that the agent interacts with, and the actions are what the agent does.

Reinforcement learning occurs when the agent chooses actions that maximize the expected reward over a given time. This is easiest to achieve when the agent is working within a sound policy framework.

Why Is Machine Learning Important?

So why do we make computers learn rather than just programming them to perform certain tasks for us more efficiently?

Well, the reason is that we need computers to handle not just the expected but also the unexpected and be able to adapt and make decisions in a changing world.

Much like we, humans, don’t just ride a bicycle the same way all the time but need to adjust our path based on weather, traffic, and other riders, we need machines to adapt and identify better decisions based on these unknowns.

This is not something that can be achieved easily through a set of decision statements that will lead the computer down the desired path because, often, the quantity of data and complexity of the decision is too much for traditionally structured code.

Instead, we need to train machines to learn through different types of data so that over time they will be able to adapt, make the necessary decisions themselves, and provide the required insight.

Machine Learning Use Cases

It’s perhaps helpful to look at the different scenarios where engineers are trying to use ML to solve problems.

Consider things like self-driving cars, cyber fraud detection, and online recommendation engines from Facebook, Netflix, and Amazon. Machine learning makes all these things possible by filtering useful pieces of information and piecing them together based on patterns to get accurate results.

In each of these examples, using traditionally structured code would inevitably mean that there are gaps in its capabilities, which could lead to tragic consequences.

Think of a self-driving car that is unable to respond to an unexpected occurrence on the road or a fraud detection algorithm that is rendered useless because people can identify the gaps in the rules it uses to identify fraud and can thereby easily mitigate them.

Using a learning algorithm, we allow the machines to identify misalignments themselves and take corrective action—even when dealing with issues not initially considered.

In previous articles, we looked at how Snapt uses machine learning to improve threat intelligence and enhance bot detection. ML is at the core of Snapt products.

I think ML is a vital part of our software future and that by understanding how it works and what it is capable of, we can use it correctly in our applications and allow ML algorithms to identify and solve some exciting problems for us.


Thanks for subscribing!

bottom of page