Machine Learning and Artificial Intelligence (AI) are two terms that, arguably, have become the most prominent associations with the tech sector from an outsider’s perspective. Whilst this means it almost devolves into a buzzword, it remains a huge concept with significant tangible results for your business if you choose to utilise machine learning technology.  

Founder of TalkIT, David Ringsell, recognised the potential power of incorporating machine learning in your technological strategy but noticed a mishap perceptions people had about machine learning. In this guest blog, he outlines how you can start deploying machine learning in your own work. 

Recently I have included machine learning in my coding courses. I found there was a lot of misunderstanding about machine learning; both what it is and how it can be practically used. This blog looks at the principles of Machine Learning, but if you want to find out more look at our complete training course in Advanced Python Development.

Machine Learning Concepts

What exactly is machine learning? Let’s start with a definition.

According to Wiki:

“Machine learning is a field of computer science that uses statistical techniques to give computer systems the ability to ‘learn’ (e.g., progressively improve performance on a specific task) with data, without being explicitly programmed.

“Evolved from the study of pattern recognition and computational learning theory in artificial intelligence, machine learning explores the study and construction of algorithms that can learn from and make predictions on data – such algorithms overcome following strictly static program instructions by making data-driven predictions or decisions, through building a model from sample inputs.”

To understand this in use, we can think about some scenarios. Machine learning is all about building a mathematical model that helps you understand data, then using this model to make decisions. Many companies sit on huge stores of raw data and they can now use this data to solve business problems, for example:

  • Email filtering (spam or not-spam)
  • Forecasting (e.g., stock market trends)
  • Spotting outliers (rogue datapoints)
  • Data mining (commercial insights)
  • Recommendations (Facebook, Netflix)

There are two categories of machine learning – supervised learning and unsupervised learning. With the former, you start with known ‘training data’, which allows you to create a model that describes data relationships. You can then apply the model for ‘test data’, to predict results and make decisions. Classification is an example of supervised learning; it uses training data to determine how new data should be labelled into existing distinct categories.

Regression is another example. This is like classification, except new data is labelled into continuous categories (rather than distinct categories). For example, predicting individual life expectancy based on lifestyle data.

On the other hand, unsupervised learning is essentially using unsupervised data, instead, you try to model the data in its own terms.

Clustering is an example of unsupervised learning. This takes an unlabelled dataset and identifies patterns and trends; it clusters similar inputs into logical groups. Feature reduction is another example. This reduces the number of random variables under investigation, by obtaining a set of principal features. The motivation is to reduce the noise, and then data analysis can then be done more accurately.

Classification of Training Data

In this section we’ll show a hypothetical example that will help you understand how classification works. Recall, classification is an example of supervised learning.

  • You start off with some training data
  • You fit a model to the training data
  • You can then use the model to classify (predict) future outcomes

The following diagram plots 2-dimensional data (i.e., the data contains two features). E.g., feature 1 is a person’s age, feature 2 their academic score. The colour of the dot is an observed label, e.g., how did the person vote in a referendum.

Based on the observed training data, here’s the challenge: How can you predict how other people will vote? i.e. If you measure feature 1 and feature 2 for another person, how can you predict how to label that person (yellow or blue)?

There are several ways you can create a model based on this data, and then fit the model to the training data. A simple model would be to assume you can draw a straight line that separates the two categories – to fit the model to the data, just decide where to draw the line. Based on where you’ve chosen to draw the line, the model predicts that the new data point should be labelled as a yellow dot.

The example we just discussed is simple and obvious. We could have just guessed the outcome because the data is so clearly segregated; in the real world, data is much more complicated. There may be thousands or even millions of features (e.g. dubious words in emails).  Based on the counts of such words, we could produce a model that labels future emails as spam or not spam.

But what if you have a continuous label, e.g. life expectancy? How do you classify (predict) new data-points? One possible approach would be to treat the continuous label as another dimension, then try to find a model that fits the data. For new data-points, e.g. lifestyle features, you can then predict individual life expectancy.

Clustering of Data

In this section, we’ll show a hypothetical example that will help you understand how clustering works. Remember, clustering is an example of unsupervised learning; you don’t start off with any training data. Instead, you build a model that describes data that doesn’t have any known labels. The following diagram plots 2-dimensional data (i.e. the data contains two features). Note that the dots are uncoloured (i.e. the data is unlabelled).

Based on this data, here’s the challenge: How can you model the clustering? How can you define discrete groups, and then decide which group a particular data-point belongs to? There are several clustering algorithms available in machine learning – for example, k-means clustering.

This identifies k cluster centres by minimising the distance between a cluster centre and the data points in that cluster. Our example suggests 5 clusters:

After understanding the principles of machine learning, the next stage is to apply them – for example, you can create models from business data then use these to gain commercial insights. There are extensive ML libraries in the Python language to help you with this. If you’d like to learn more, take a look at this Advanced Python course outline.

Image credit: Thanks to Andy Olsen for his excellent course slides