Demystifying Machine Learning
By: Vishal Chandak
Tags: Machine Learning 101, Technology, Getting Started, Artificial Intelligence, Machine Learning

Machine Learning in action

“It sounds cool, but how is that it even possible.” — Your Brain

Hold your horses, we will get to that question in a minute. Before that, let’s understand how is it different than the “usual” way of solving a problem.

To understand this analogy better, let’s take a simple real-world example of — “Classifying shapes”.

Problem:

Given an image of a particular shape, let’s find out if the image is for a Square or Triangle.

Non Machine Learning Approach

The pseudo-code (fancy term programmers use to define “steps”) for that would look like:

1. Take the input Image

2. Find the number of corners in the image. This operation would basically include: (Don’t worry if you don’t understand all the terms below, neither do I)

Convert the image from RGB (i.e. Colored Image) to Grayscale (i.e. B/w)

Smooth-en out the image

Use thresholding to convert the image to Bi-Level Binary Image

Use an edge-detector algorithm to get the list of edges using pixel gradients

Use contours to get the list of corners in the image

3. Write an if-else block to return the shape of the object based on the number of corners returned

Here’s a small visualization to help you better visualize what the above steps might look like:

Huh! You must be thinking — That seems a lot of work for such a trivial task. You are not entirely wrong but this has been the general approach to solve such problems until a few years back. Even though this approach “worked”, it had a lot of issues. For starters, it only worked well with perfectly captured images i.e. pictures taken under proper light and clear background which means that it will have a high percentage of failure in real-world scenarios.

Machine Learning Approach to the rescue

Let’s see what the same would look like with Machine Learning:

1. Gather some images for different shapes — squares and triangles.

2. Feed it to a ML Algorithm (more technical term would be a Convolutional Neural Network)

3. Run the image to be tested on the above trained model

4. Sit back and relax!

Now you must be thinking “Ok. That seems to be awfully easy. But how does that even work?” Let me answer that question with a question of my own — How would you teach a child a difference between a square and a triangle?

You won’t start by telling him about the number of corners or that the angles between them should be 90; Rather you would show him some images and help him relate that one of them is called a square and other is called a triangle.

Exactly! This is the way Machine Learning works too — based on feedback from the label provided with the data.

The below image might help understand it better:

Let’s take off the training wheels and see how far our newly trained child can go:

“All that’s cool but I don’t need a machine to categorize shapes.” — Almost everyone

To give a little more perspective on its potential - Machine Learning is the magic behind how Google lets you find your favorite cat photos (Who doesn’t love cats!) on the internet. If you look closely, almost everything you interact with on a day-to-day basis has machine learning weaved into it — Amazon product recommendations, Netflix movie recommendations, predicting stock prices, Alexa Voice, Sales forecasting, Automatic subtitle generation, Language translation and a lot more. The details pertaining to those is outside the scope of this post.

The major advantages with the Machine Learning approach is that:

You don’t need any domain knowledge to get started

The same classifier which can recognize shapes can also recognize numerical digits, cats vs dogs etc. since the Machine trains itself based on the input data

Can be continuously improved based on its own performance

The few disadvantages with Machine Learning are:

Needs a lot of training data for better predictions

Needs a lot of processing power for training the model and deriving inferences

However, the advent of the information age, providing us with humongous amount of data, and the drastic reduction in CPU and GPU costs over the years have helped solve both the above problems. Thus, it makes sense now more than ever, to have a generalized solution for such cases rather than a problem-specific solution.

That’s where Machine Learning comes into play. Sounds really cool, doesn’t it? If it’s so fascinating, why isn’t everyone trying to get their hands dirty with Machine Learning?

I will be addressing this question in my next post. Stay Tuned!

Until then, That’s all folks!