Algorithms — Machine Learning

Isha Dua
4 min readMay 12, 2021

I have a background in software engineering and DevOps so I understand algorithms but had never used/experienced them in the AI/ML domain.

How is an algorithm different from a heuristic function?

What kind of algorithms are used in ML?

How do we know which algorithm best fits a specific use case?

Lets start answering them one by one and try to understand these algorithms better. Remember, different use cases will need different algorithms which may have different needs based on data density, processing power and performance.

An algorithm is a series of steps which if/when replicated result in the same outcome. You can expect an algorithm to behave consistently and unambiguously. Lets try to understand this statement with a real world example; if we want to troubleshoot an issue with the car battery, we would generally go through a series of steps to narrow down the possibilities and reach the solution.

In contrast, a heuristic can be thought of as a “rule of thumb” or a “short-cut” that will help guide you to perform a task however will not guarantee a consistent outcome. This could be as simple as; we may like this new pizza place because we LOVEE pizza but that may or may not be true since we do not go into the details of how that Pizza was bakes/cooked/created/sourced. Heuristics are often based on our own prior experiences which creates a bias in the results.

Why do we use Algorithms in Machine Learning?

In the ML process, we want to make as much generalization as possible, drive away the bias, have the model span through a much wider and spread out dataset hence covering more ground and generating worldly aka real world results. Computers cant make assumptions, they need a finite set of steps that need to be followed to come to a solution hence the use of algorithms vs heuristics.

Types of Algorithms

Supervised Learning : A teacher/parent/guide helps you learn by giving you examples and feedback. We use a training and a testing data set. When you train the model, have labelled data and tell the algorithm what is correct and what is incorrect, its considered supervised. The algorithm understands from the data what the right and wrong answers for a different data points/entries. It should then, be able to tell you the correct answer with a certain level of accuracy when a new data point is presented to the algorithm. Example, we have a model that is trying to predict the market value of a house. We can use a dataset that has the price of houses based on its size, age, location etc and use that labeled dataset to predict a price for a certain house.

Unsupervised Learning : No formal training process. Think of this like “on the job training”. The algorithm is given a dataset and asked to find relationships, groupings, patterns, correlations, clusters of similar kind of data points. For example, these algorithms can look at datasets from social media such as Facebook, Instagram etc and tell us which are the most cohesive friend circles. It can also help you identify different market segments if you have customer data which comes real handy in the e-commerce industry.

Reinforcement Learning : This is usually a trial and error process where we reinforce desired behavior and discourage undesired behavior. We provide reinforcement to the model as a reward for doing the right things. For example, simulation based optimization wherein we create a simulated world, run our agent through the world and reward the agent for doing the right things. This is used very often in autonomous driving use cases such as creating a reward function that maximizes if the vehicle stays on track and no reward if it steers away from the track.

I will be diving deeper into each category of algorithms for my upcoming posts. If you have any thoughts/suggestions/feedback, I would be happy to hear them.

--

--

Isha Dua

Solutions Architect@AWS | AWS Technical Evangelist | Cloud Computing | DevOps | Containers and AI/ML Enthusiast