Introduction to Machine Learning

Introduction to Machine Learning

What is Machine Learning

Machine Learning is a branch of AI (Artificial Intelligence) that is related to teaching a computer to learn without explicitly programming the logic. Machine Learning uses data (both input and output data) to iteratively learn patterns to a point where it can start predicting outputs based on input data.

For example, if you recall from the show Silicon Valley, in Episode 4 Season 4, one of the engineers developed a machine learning application to identify whether a picture contains a hotdog or not. For the application to do this, the engineer needed 100s of pictures containing different types of hotdogs for the machine learning algorithm to learn what a hotdog looks like. Once the application has learned from the pictures, it can now analyze new unseen pictures to predict if the picture contains a hotdog or not. As entertaining as this scene is, it illustrates a key algorithm of machine learning called classification and with enough data, the application can be expanded to identify many more types of food.

Stay tuned as I go into the different types of machine learning below but in the meantime enjoy the scene from Silicon Valley S4 E4.

Types of Machine Learning

Machine Learning algorithms consist of 3 main areas of specialization, namely Supervised Learning, Unsupervised Learning and Reinforcement Learning. I'll briefly go into detail about all 3 areas and provide some examples.

These 3 areas are based on the type of data and feedback provided during training.

Supervised Learning

Supervised Learning is a machine learning algorithm that uses labeled data to train a model. Labeled data means the input and output data is already known and the model will map the input data to the output data.

We already saw an example of this above in the scene from Silicon Valley where the application uses a classification algorithm to identify a hotdog. The data is already labeled and known, the model just needs to predict if a picture is a hotdog or not.

Another example of Supervised Learning is Regression, where we use continuous data (as opposed to categorical data like classification) to train a model and predict a continuous value based on a new input. Imagine training a model based on the last few years performance of a specific stock in the stock market, and trying to predict how it will perform in the future, or predicting weather patterns of a specific region based on its historical data.

Below we can see a stock price, where the blue line shows the historical data, the orange line shows the model prediction and the red line shows how the stock actually performed.

Supervised Learning has many applications, it's up to us to find ways to apply these algorithms to bring value to the world. Can you think of any interesting applications that could make your day-to-day better? That's the spirit of machine learning, trying to improve and automate to make life better. However, not all data comes labeled - that's where Unsupervised Learning shines.

Unsupervised Learning

Unsupervised Learning is a machine learning algorithm that does not rely on data being labeled but rather finds patterns and structure within the data. There are no fixed output variables, but the model learns from the data and starts to make sense of it as more data passes through.

Imagine you come back from a Euro trip where you visited multiple countries and cities. You took 100s of photos and can't wait to start posting them on TikTok. Suddenly, you have this artsy idea that you want to make multiple short-form videos of pictures, where each video has a theme of similar content. Without defining any specific categories, you use Unsupervised Learning to analyze your pictures and make use of an algorithm called clustering. This algorithm starts grouping photos with similar landscapes, colors or compositions. You sift through each group the algorithm created and start posting your pictures with themed titles and reminisce on an amazing trip.

Below we can see that the shapes are being grouped without any categories being defined.

Unsupervised Learning can be a powerful analysis tool in your toolbox to help uncover hidden patterns, it can also be a fun application to help you be more creative. As said with Supervised Learning, it's up to us to find ways to apply these algorithms to bring value to the world and our lives. Intuitively, you would think labeled and unlabeled data covers all of the types of machine learning, but that is not the case. The final type of machine learning is Reinforcement Learning. This algorithm introduces a model that learns through trial and error. Let's take a deeper look.

Reinforcement Learning

Reinforcement Learning trains a model (or more specifically an agent when we talk about Reinforcement Learning) to take an action and the environment rewards the agent for good behavior and penalizes for bad behavior. The agent will learn based on these rewards and penalties, and then make better decisions for the next iteration.

You love playing tic-tac-toe but your friends think it's lame and boring. Deep down you know they are just noobs and making excuses. You decide to use Reinforcement Learning to train the agent on the game. You give the environment and agent their parameters and allow it to start training. You finally have a worthy opponent! You start playing against your new AI "friend" and quickly realize who the real noob is... Alas, you stop playing tic-tac-toe and concur that it's lame and boring. You reunite with your IRL (In Real Life) friends and live happily ever after.

In all fairness, machines can learn much faster than humans, so rest assured your ego can remain intact when competing against a bot. Also, you can't call a bot a noob, so consider it practice for when you play against humans and the wins are so much sweeter.

As quickly as I broke down the types of machine learning, the process of gathering data, training a model and using it isn't as simple as it may seem. In the next section, I will go into detail about why you should be interested in machine learning but more importantly why it's not for everyone.

Is Machine Learning for Everyone?

Is Machine Learning for Everyone? How can you not be interested in machine learning after the breakdown and explanation in the previous sections? I can list a hundred reasons why you should get into machine learning (AI is the future, it's cool, you can brag to your friends and the list goes on), but here I will focus on why you may not be interested in it.

Skill issue - the technical hurdle

If you come from a background that is non-technical or non-mathematical, the hurdle to getting into machine learning can be overwhelming.

You will need to get very comfortable with mathematical concepts like linear algebra, calculus, statistics and probability theory. Luckily we live in the age of information where we can learn all these concepts for free on platforms like YouTube and Khan Academy.

In addition to mathematical concepts, you will need to learn to code. Lucky for you, the most popular language for machine learning is one of the easiest to learn - Python. It doesn't stop at Python, you will need to get cozy with many tools within Python. If you have made it this far, why stop now?

Predicting a stock may seem simple at first, but when you dive deeper it goes far beyond the skill of analyzing a graph. This applies to many industries you may find yourself in. In addition to technical expertise, domain knowledge will play a significant role during your analysis.

Machine learning is a very technical path that requires massive learning curves. Mathematics can be very scary for a lot of people, and while there are tools that completely abstract it all away, I assure you, to be a good Machine Learning engineer, you must understand the underlying algorithms.

The data problem

How hard could it be to get data? We live in a world full of data, right? Generating terabytes of data every day. In the real world with real clients and real security measures, getting access to the correct data can prove to be a very challenging task. Some companies may have an easy data flow while some may have hurdles, think about accessing medical privacy documents versus your photo library!

Okay, we finally got access to a portion of the data, hooray! Oh no, what is this? Missing fields, invalid data, outliers, incomplete data... Data wrangling is a big part of machine learning. You will spend more time cleaning the data, preparing the data and making sense of the data than actually building a cool model to make predictions. So if you enjoy data wrangling more than your weekends, please do continue.

For another example, let's take the Supervised Learning example above relating to hotdog. Not all hotdog images were created equal and we need to account for all types of photos. Blurry, odd angles, different types of hotdogs, the list goes on. This teaches us that a simple classification of hotdog requires good-quality data.

If you do not have good-quality data, you won't be able to train a model that produces good-quality predictions.

The open-ended problem

Within many careers, once you finish a task, you can put it behind you and move on. This is not the case for machine learning. You can produce an amazing model that is performing well today, but six months later that same model could be performing suboptimal. How could this be? I had good-quality data, and the tests for the model were excellent, nothing changed. The reality is that even though models were initially performing well, data patterns change. The data initially collected had a certain pattern that the model trained on, however, that pattern within the data may have changed over the next six months. We now need to train the model to incorporate the new patterns in the data and update the running model.

A great example of this is the stock market example above. The stock performance can change over time and the model will need updating accordingly.

A model's performance needs to be checked regularly to ensure it is performing within acceptable ranges, thus the open-ended problem. Something to note, aim for an optimized result for the business purpose, as 'perfect' models are unrealistic.

So what?

You've made it this far and you saying, so what? I applaud your gumption! Remember, predicting stock trends or identifying a perfect hotdog is just the start! Behind those fun examples lies serious mathematics, messy real world data, and models that constantly evolve. If that journey excites you, the roadmap below can help you turn that 'so what?' into a fulfilling career.

Machine Learning Roadmap