Introduction to Machine Learning and Comparison with Traditional Programming

Machine Learning and Data Science are some of the most exciting areas to make a career. The idea is simple: every company talks about collecting data, analyzing it, extracting meaning, and building technologies around it. Each of these stages creates job opportunities like Data Analyst, Data Scientist, Machine Learning Engineer, and many more. For example, a vehicle company collects data about how their vehicle performs on the road to improve customers' experience. Similarly, a milk farming company collects data of their sale and analyzes when their firm needs an extra amount of milk to serve their customers better.

Key Takeaways from this blog

  • An analogy to understand Machine Learning
  • What is Machine Learning?
  • Difference between traditional programming and Machine Learning.
  • Why do we need Machine Learning?
  • Problems that traditional programming will be unable to solve, but ML can.
  • 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?

Our brain is one of the most complex parts 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 brain. 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 would you be able to catch it in your childhood days?

In our childhood days, we might have difficulty catching the balls. We practiced more and more; our brains perfectly 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 the best for similar experiences. Continuing the same example of catching the ball, suppose we want to make a Robot catch the ball by providing him a human intelligence. Can you 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 instances 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 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 Machine Learning.

Once this learning has been done, it can predict the robot's position for any 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 process of traditional programming using a block diagram. We can provide a program to our computer along with the input data of the ball's position. Our computers will execute that program for input data and give the corresponding robot position as output.

Machine Learning

In the case of Machine Learning, we can provide our computer with some recorded experiences in the form of Ball position as input data and corresponding robot position as output data. Our computer will learn a way to convert Input data into output data. Or we can also say it will discover a program that we need 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.

Machine learning process for un-recorded dataset

Machine Learning Definition

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."
  • Wikipedia definition says: "Machine Learning is a computer science field that gives computers the ability to learn without being explicitly programmed."

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

Here computer takes Data and Output as its input parameters and tries to produce the best suitable function that maps Data to Outputs. The machine learns a mapping function that maps the input data to the output data using existing experiences (Similar to the brain's functioning).

Why do we 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 a lot of emails. 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 for that, 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 such a wide variety of 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 term "Automation," we could say when human involvement is minimized. We generally take the help of machines by programming them. So if a computer program is an automation, then Machine Learning is automating the automation process.

Traditional programming and machine learning

Some critical facts related to machine learning

  • A Machine Learning model can learn to play the games from the expert’s experiences and then beat the same expert. Google’s AlphGo is an ML model that defeated 18-time world champion Lee Sedol in a chess game.
  • 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.
  • 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. This is a famous quote by Bill Gates: "A breakthrough in machine learning would be worth ten Microsofts."

If you have any queries/doubts/feedback/other ideas, please share in the message below or write us at contact@enjoyalgorithms.com. Enjoy machine learning, Enjoy algorithms!

More From EnjoyAlgorithms

Our weekly newsletter

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

Follow Us:

LinkedinMedium

© 2020 EnjoyAlgorithms Inc.

All rights reserved.