Generative AI for Beginners: Part 2 — Understanding Machine Learning

Raja Gupta
7 min readFeb 13, 2024

Introduction

This blog is part of the series Generative AI for Beginners, where we are learning basics of Generative AI, one simple step at a time.

To make it easy to grasp, I have divided the entire series in small parts. Each blog requires maximum 15–20 minutes to learn. After finishing the series, you will get a clear idea on fundamentals of Generative AI and its various aspects.

Part 1 — Introduction to AI

Part 2 — Understanding Machine Learning [current blog]

Part 3 — Basics of Deep Learning

Part 4 — Introduction to Generative AI

Part 5 — What is Large Language Model (LLM)?

Part 6 — Prompt Engineering: The Art of Communicating with AI

Part 7 — Ethical Considerations in Generative AI

Part 8 — Challenges and Limitations in Generative AI

This is the 2nd blog in this series where we will understand Machine Learning.

Side Note: You may subscribe me to get an email when I publish the next blog in this series.

Machine Learning (ML) — From a Kid’s Perspective

In our previous blog, while understanding AI, we talked about enabling the robot to identify a dog. Imagine we want to enable the robot to identify several animals.

To do so, we will show him pictures of various dogs, cats, bunnies and other animals and label each picture with the name of the animal. We train the robot to identify animals based on size, colour, body shape, sound etc.

Once the training is completed, the robot will be able to identify these animals we trained him for.

All dogs do not look alike. However, once robot has seen many pictures of dogs, it can identify any dog even if it does not exactly look like a specific picture. We need to show lots of pictures of dog to the robot. More pictures it sees, more efficient it will be.

This is Machine Learning Teaching a robot (or any machine) by giving lots of example pictures (or any other information).

To summarize, Machine Learning is:

  • A subset of Artificial Intelligence.
  • Which enables machines (or computers) to learn from data and make decisions.

Types of Machine Learning

Machine learning can be broadly categorized into three main types:

  1. Supervised learning
  2. Unsupervised learning
  3. Reinforcement learning.

Each type serves different purposes and involves different approaches to learning from data. Let’s have a close look into all these types.

Supervised Learning

Let’s take the same example where we enabled the robot to identify an animal.

When we trained our robot by showing pictures of animals, we labelled each picture with the name of the animal. So, we acted as a teacher to him. We first told him how does a dog or a cat look like and then only he was able to identify them.

In Machine Learning we call this Supervised Learning.

Below image summarizes important points on supervised learning.

Real-life Examples of Supervised Learning

Supervised learning is widely used in various real-life applications where the algorithm is trained on labelled data to make predictions or classifications. Here are some examples:

Email Spam Filtering

Classifying emails as spam or not spam based on features derived from the content, sender information, and other relevant attributes.

Image Classification

Identifying objects or patterns within images, such as classifying animals, recognizing handwritten digits, or detecting objects in self-driving cars.

Facial Recognition

Identifying and verifying individuals based on facial features, used in security systems or for unlocking devices.

Financial Fraud Detection

Identifying potentially fraudulent transactions by analyzing patterns and anomalies in financial data.

Speech Recognition

Converting spoken language into text, as seen in voice assistants such as Siri or Google Assistant.

Unsupervised Learning

Let’s understand this from a kid’s school example. When kids go to their class first day, they meet lots of classmates. At first all classmates are same to them. But with time, they themselves categorized them in different groups:

  • They find some classmates very good and want to be friend with them.
  • They find some rude or irritating and want to avoid them.
  • They find some very good in sports and want to be in the same team as they are.
  • And so on…

When kids categorized their classmates, nobody told them how to do that. They did that without anyone’s help. — This is how unsupervised learning works.

Let’s take a proper machine learning example. Imagine we showed lots of pictures of dogs, cats, bunnies etc. without any label to our robot and told him — “I’m not going to tell you which one is which. Go explore and figure it out”.

The robot starts to look at these animals, noticing things such as their fur, size, and how they move. It doesn’t know their names yet, but it’s trying to find patterns and differences on its own.

After exploring, the robot might notice that:

  • Some animals have long ears (bunnies)
  • Some animals have soft fur and a tail (cats)
  • Some animals have wagging tails (dogs)

It figures out these categories without you telling it directly.

In the end, the robot might not know the names of the animals, but it can say that “These animals are similar in some ways, and those are different in other ways.” — This is Unsupervised Learning.

Below image summarizes important points on unsupervised learning.

Real-life Examples of Unsupervised Learning

Unsupervised learning is used in various real-life scenarios where the data is not labelled, and the algorithm needs to discover patterns, structures, or relationships within the data. Here are some examples:

Clustering Customer Segmentation

Businesses use unsupervised learning, specifically clustering algorithms like k-means, to segment customers based on their purchasing behavior. This helps in targeted marketing and personalized services.

Anomaly Detection in Cybersecurity

Unsupervised learning is employed to identify unusual patterns or behaviors in network traffic. Any deviation from the normal behavior can be flagged as a potential security threat.

Recommendation Systems

Unsupervised learning is used in recommendation systems. By identifying patterns in user behavior, these systems can suggest products, movies, or content that a user might like.

Reinforcement Learning

Imagine teaching a dog a new trick — you reward it with a treat when it does the trick correctly and give no treat when it doesn’t. Over time, the dog learns to perform the trick to get more treats.

Similarly, Reinforcement Learning is:

  • Training a computer to make decisions
  • By rewarding good choices and punishing bad ones
  • Just as you might train a dog with treats for learning tricks

In reinforcement learning, there’s an agent (for example a robot or computer program) that interacts with an environment. Let’s take an example of teaching a computer program to play a game, for example chess.

  • In this case, computer program is agent and chess game is the environment.
  • The computer program can make different moves in the game, such as moving a chess piece.
  • After each move, it receives feedback (reward or penalty) based on the outcome of the game.
  • If the program wins the game, it receives a positive reward.
  • If it loses the game, it receives a negative reward, or a ‘penalty.
  • Through trial and error, the program learns which moves lead to the best rewards, helping it figure out the best sequence of moves that leads to winning the game.

Reinforcement learning is powerful because it allows machines to learn from their experiences and make decisions in complex, uncertain environments — similar to how we learn from trial and error in the real world.

Below image summarizes important points on reinforcement learning.

Real-life Examples of Reinforcement Learning

Game playing is one of the main use-case of reinforcement learning.

AlphaGo, developed by DeepMind, is a computer program that uses reinforcement learning to play the board game Go at a superhuman level. It defeated world champions and demonstrated the power of reinforcement learning in mastering complex games.

Another example is Self-driving cars. Reinforcement learning is used in the development of self-driving cars. Agent learns how to navigate traffic, make decisions at intersections, and respond to various driving conditions through continuous learning from simulated and real-world experiences.

Reinforcement learning is also used in algorithmic trading to make decisions on buying or selling financial instruments. The agent learns optimal trading strategies based on historical market data and real-time market conditions.

Summary

Machine Learning is a subset of AI where we enable computers to learn from examples and experiences. We don’t explicitly program but let the machine learn from data and figure things out on its own. Whether it’s recognizing our favourite songs, understanding our voice commands, or even helping doctors analyze medical images, Machine Learning is already part of our daily lives.

If you still have any query, please let me know in comment or get in touch with me in LinkedIn!

Next Blog

Generative AI for Beginners: Part 3 — Basics of Deep Learning

Enjoyed Reading? Follow me for more such insights on AI and beyond!

--

--

Raja Gupta

Author ◆ Blogger ◆ Solution Architect at SAP ◆ Demystifying Tech & Sharing Knowledge to Empower People