Comparison of Machine Learning with Traditional Programming

Machine Learning and Data Science are some of the most exciting areas in which people are attracted to make a career. As per several industrial surveys, the demand for jobs in these sectors is at its peak. Companies across every industry are collecting data in some form. For example, a vehicle company collects data about how their vehicle performs on the road and is devoted to making their customers' experience "the best". At the same time, a milk farming company collects data on their sale and analyses when their firm needs an extra amount of milk to serve their customers better.

Similarly, every company talks about collecting data, analyzing it, extracting meaning, and finally building technologies around it. Each stage creates job opportunities like Data Analyst, Data Scientist, Machine Learning Engineer, and many more. Through this article, we will start our career-focused journey toward one of these emerging technologies, i.e., Machine Learning. Here, we will explore the most fundamental and first ideas about this technology.

Key Takeaways from this blog

  1. Analogy behind Machine Learning technique
  2. What is Machine Learning?
  3. Difference between traditional programming and Machine Learning.
  4. Why do we need Machine Learning?
  5. Problems that traditional programming will be unable to solve, but ML can.
  6. Amazing facts in Machine Learning.

So, let’s begin our journey towards knowing this beautiful technology and find the answers to the above questions.

An analogy from Human Brain

Have we ever thought about how our brain works? Let's start from there itself.

Indeed, the brain is the most complex part of our body, and the knowledge about its working principle is still big research underway. But to understand it, let's take one simplest example. Suppose we want to catch the ball coming towards us. What would be our first reaction? We will use our hands to catch it, right?

Let's correlate this scenario in the format of input and output data. Our eyes sensed the incoming ball and sent the input signals to our brains. Brain received these signals, analyzed them, and finally generated the output reaction of moving our hands towards the coming ball to catch it.

To explain the same phenomena in biological terms, we can say that brain cells have perceptrons/receivers, named Dendrites, which receive the electrical signals as the input data from our sensory organs (Nose, Eyes, Skin, etc.). They analyze and respond to those signals by releasing reaction signals through the Axon terminals as the output data.

brain cells dendrites and axons

But were we able to catch it in our childhood days?

In our childhood days, we might have faced difficulty in catching balls. We practiced more and more, and finally, our brains learned how to catch a ball. Similarly, there will be different sets of signals for any other task. The brain gives a matching set of output signals through axons when any known or similar set of inputs is received from dendrites. Saying more explicitly, it learns the mapping function from the input set to the output set.

Brain learning a function

This learning of mapping function through several experiences is known as intelligence in living things. But what if some non-living things started doing the same?

Can we develop the same capability for our computers?

That's where the buzzword "Machine Learning" comes into the picture. Let's move towards understanding it in detail.

What is Machine Learning?

We saw that human brains have a unique characteristic of learning from different experiences and evolving to do their best for similar experiences. Continuing the same example of catching the ball, suppose we want to make a Robot catch the ball by providing human intelligence. Can we guess "how" we can do that?

There are two possibilities:

Method 1: Using traditional programming

We can write a function-based computer program that will take the ball's location as the input parameter and give us the output position to place our robot to catch the ball. This method can also be called traditional programming.

if ball position is X1:
     place robot at Y1
elif ball position is X2:
     place robot at Y2
elif ball position is X3:
     place robot at Y3
.
.
.
So on....

Robot catching the ball for different positions

Method 2: Using machine learning

We recorded some data for the ball positions and corresponding robot positions (placed manually) to catch the ball perfectly.

(X1, Y1), (X2, Y2), (X3, Y3), ..., (Xn, Yn)

Later, we asked our robot to predict its possible positions for the recorded ball positions one after the other. Let's say we asked our robot to guess where it should be present to catch the ball, given the ball position is X1. Initially, the robot made very wrong guesses about its positions. Let's say it guessed Y1', and the difference between Y1 and Y1' was very high.

Machine predicting very wrong position

But our robot did not lose hope. It learned from its mistakes and corrected the predictions for every recorded ball position (X1, X2, …, Xn). Continuously trying for all these instances, it achieved the intelligence and started predicting its correct or near-correct positions (Y1', Y2', …, Yn').

This type of Computer Intelligence gained from learning via different recorded experiences is known as the Machine Learning.

Once this learning has been done, it can predict the robot's position for similar ball positions that were not recorded earlier. Let's say for Xn+1, it will be able to give some output Yn+1', and we will decide the success by outcome whether it caught the ball or not.

Machine predicting correct position

Difference Between Machine Learning and Traditional Programming

Traditional Programming

Let's say our robot was nothing but just a tiny computer. Suppose we try to represent the traditional programming process using a block diagram. In that case, we provide a program (multiple if-else conditions) to our computer along with the input data of the ball's position. Our computers executed that program for that input data and provided the corresponding robot position as output.

Machine Learning

But in Machine Learning, we provided our computer with historical experiences in the form of Ball position (as input data) and corresponding robot position (as output data). Our computer somehow learns a way to convert Input data into output data. Or we can also say it discovered the program we had to write explicitly in the traditional programming section. Isn't it fascinating?

Once our computer learns this program, it will perform similar functionality as traditional programming for any newer ball position (we don't know the corresponding robot position for this ball position). It will take the newer ball position as the input data and use the learned program to calculate the corresponding robot position. That's Machine Learning for you.

Machine learning process for un-recorded dataset

Machine Learning Definition

Before moving forward, let's define "Machine learning" formally.

  • In 1950, the inventor of this term, Arthur Samual, said, Machine learning is the science of getting computers to act without being explicitly programmed.
  • And Wikipedia says: Machine Learning is a computer science field that allows computers to learn without being explicitly programmed.

Did we notice something similar between these two definitions? 

In machine learning, we are not writing programs/functions. Instead, it is learning by itself based on historical data, and that's the core reason why both definitions include the term "without explicit programming".

Here computer takes Input Data and Output Data as input parameters and tries to produce the best suitable function that maps Input Data to Output Data. The machine learns a mapping function that maps the input data to the output data using existing experiences (Similar to the brain's functioning). But still, one question is not straightforward:

Why do we even need Machine Learning?

We already had traditional programming using which we could have written thousands of lines of code. Then why do we need Machine Learning? In the earlier example of ball catching robot, what if we cover all the cases of robot positions using if/else conditions, and the robot can catch balls perfectly. Then why ML?

The answer is simple: The positions that a robot can take are finite. This means it can be anywhere inside the defined arena where we perform this process of robots catching the ball. But using if/else conditions would be challenging to cover all the scenarios.

Suppose we need to code the self-driving car on the road. Will it be possible for someone to cover all the cases using traditional programming? Obviously not! The possibilities of scenarios can be infinite there. That’s where we need Machine Learning that can learn automatically for the different scenarios and modify the experience based on several new adventures.

Other Example Applications that can not be programmed traditionally

Handwritten character recognition: There are billions of people out there, and two persons' handwriting barely matches. If we opt for traditional programming to identify the characters in handwritten documents, we might never cover all the cases in the world.

Email Spam/Non-spam classification: Based on the content of the email, we classify whether that is spam or non-spam. Every professional person in the world daily gets around 150 emails on average. Suppose we traditionally programmed our computer that if an email contains these sets of words/links/phrases, then mark it as spam. Don't you think spammers will quickly get the hint that their emails are marked as spam when they are sending these sets? They will easily find an alternative, and now we have to program our computer again for those alternatives.

Face Recognition: All computer vision tasks involve billions of image pixels (one unit of image). We can not explicitly write programs to perform functions on various pixels.

Note: There can be many more such applications around us. If you can find some, please share them in the message below. 

If we have to define the technology application term "Automation", we could say that human involvement is minimised. We generally take the help of machines by programming them.

So if a computer program is automation, then Machine Learning is automating the automation process.

Traditional programming and machine learning

Some facts related to machine learning

  1. A Machine Learning model can learn to play the games from the expert's experiences and beat the same expert. Google's AlphGo is an ML model that defeated 18-time world champion Lee Sedol in a chess game.
  2. Google's Deepmind has a separate branch of Alphafold that focuses on discovering drugs using machine learning. ML learns the working patterns of different medicines from earlier experiences and proposes drugs for any new disease.
  3. ML can be used for Code anonymization. Suppose a company has 600 programmers. Seniors decided to take eight code samples from each employee and train the ML model over that. Once trained, the algorithm could predict who wrote the code with 83% accuracy. Imagine how useful this could be whenever there are any Ransomware attacks.

Critical Questions to Explore

Question 1: Why did someone term it "Machine Learning"?
Question 2: What makes traditional programs different from ML algorithms?
Question 3: How can ML algorithms help in cyber-security?
Question 4: Why can some applications not be hand programmed?

Conclusion

In this article, we learned about machine learning and traditional programming. We understood how machine learning mimics human brains with an exciting example of a robot catching a ball. We hope you enjoyed the article.

Enjoy learning! Enjoy algorithms!

Share feedback with us

More blogs to explore

Our weekly newsletter

Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.

© 2022 Code Algorithms Pvt. Ltd.

All rights reserved.