0% found this document useful (0 votes)
15 views38 pages

AI Modeling: Supervised & Unsupervised Learning

Uploaded by

simarkaur11010
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views38 pages

AI Modeling: Supervised & Unsupervised Learning

Uploaded by

simarkaur11010
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit-2: Advanced Concepts of Modeling in AI

Lesson Title: Advanced concepts of Modeling in AI Approach: Session + Activity

Summary: There are two main categories of AI models: Rule based and Learning based.
Learning based models can be further classified as: Supervised Learning, where machines are
taught using labeled data; Unsupervised Learning, where machines independently uncover
patterns from unlabeled data; and Reinforcement Learning, enabling computers to optimize
decisions for rewards without direct programming. Neural networks, mimicking the brain's
neurons, automatically extract data features through interconnected nodes, making them
efficient for processing large datasets like images.
Learning Objectives:

1. To familiarize students with supervised, unsupervised and reinforcement learning


based approach.
2. To Introduce students to the neural network.

Learning Outcomes:

1. Understand supervised, unsupervised and reinforcement learning based


approach.
2. Understand Neural Networks.

Pre-requisites: Essential understanding of Artificial Intelligence

Key-concepts:

1. Supervised, unsupervised and reinforcement learning based approach


2. Neural Networks

* Images shown here are the property of individual organisations and are used here for reference purpose only.
2.1 Revisiting AI, ML, DL

To build an AI based project, we need to work around Artificially Intelligent models or


algorithms. This could be done either by designing your own model or by using the pre-existing
AI models. Before jumping into modelling let us clarify the definitions of Artificial Intelligence
(AI), Machine Learning (ML) and Deep Learning (DL).

Differentiate between AI, ML, and DL


Purpose: To differentiate between Artificial Intelligence (AI), Machine Learning (ML) and
Deep Learning (DL).
Say: “As we enter the world of modelling, it is a good time to clarify something many of you may be
having doubts about. You may have heard the terms AI, ML and DL when research content online and
during this course. They are of course related, but how?

Artificial Intelligence, or AI for short, refers to any technique that enables computers to mimic
human intelligence. An artificially intelligent machine works on algorithms and data fed to it and gives the
desired output.

Machine Learning, or ML for short, enables machines to improve at tasks with experience. The machine here
learns from the new data fed to it while testing and uses it for the next iteration. It also takes into account
the times when it went wrong and considers the exceptions too.

Deep Learning, or DL for short, enables software to train itself to perform tasks with vast amounts of data.
Since the system has got huge set of data, it is able to train itself with the help of multiple machine
learning algorithms working altogether to perform a specific task.

Artificial Intelligence is the umbrella term which holds both Deep Learning as well as Machine Learning.
Deep Learning, on the other hand, is the very specific learning approach which is a subset of
Machine Learning as it comprises of multiple Machine Learning algorithms.”

As you can see in the Venn Diagram given below, Artificial Intelligence is the umbrella
terminology which covers machine and deep learning under it and Deep Learning comes
under Machine Learning. It is a funnel type approach where there are a lot of applications of
AI out of which few are those which come under ML out of which very few go into DL.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Machine Learning (ML)

Machine Learning, or ML, enables machines to improve at tasks with experience. The
machine learns from its mistakes and takes them into consideration in the next execution. It
improvises itself using its own experiences.

Block Representation – Machine Learning (ML)

This is just a broad representation of how a machine learning model works. Input (past or
historical data) is given to the ML model and the model generates output by learning from the
input data.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Here is an example which shows labelled images (every image is tagged either as apple or
strawberry) are given as input to the ML model. ML model learns from the input data to
classify between apples and strawberries and predicts the correct output as shown.

Examples of Machine Learning (ML)

Object Classification
Identifies and labels objects present withinan
image or data point. It determines the
category an object belongs to.

Anomaly Detection
Anomaly detection helps us find the
unexpected things hiding in our data. For
example, tracking your heart rate, and finding
a sudden spike could be an anomaly, flagging
a potential issue.

Deep Learning (DL)

Deep Learning, or DL, enables software to train itself to perform tasks with vast amounts of
data. In deep learning, the machine is trained with huge amounts of data which helps it into
training itself around the data. Such machines are intelligent enough to develop algorithms for
themselves. Deep Learning is the most advanced form of Artificial Intelligence out of these
three. Following is the block diagram of deep learning:

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Block Representation- Deep Learning (DL)

Input is given to an ANN, and after processing, the output is generated by the DL block. Here
is an example which shows pixels of a bird image given as input to the DL Model and the model
is able to analyze and correctly predict that it is a bird using a deep learning algorithm (ANN).

Examples of Deep Learning (DL)

Object Identification
Object classification in deep learning
tackles the task of identifying and labeling
objects within an image. It essentially uses
powerful algorithms to figure out what's
ina picture and categorize those things.

Digit Recognition
Digit recognition in deep learning tackles
the challenge of training computers to
identify handwritten digits (0-9) within
images.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Common terminologies used with data

What is Data?
▪ Data is information in any form
▪ For e.g. A table with information about
fruits is data
▪ Each row will contain information about
different fruits
▪ Each fruit is described by certain features

What do you mean by Features?


• Columns of the tables are called features
• In the fruit dataset example, features may be
name, color, size, etc.
• Some features are special, they are called
labels

What are Labels?


Data Labeling is the process of attaching
meaning to data
• It depends on the context of the problem we are
trying to solve
• For e.g. if we are trying to predict what fruit it is
based on the color of the fruit, then color is the
feature, and fruit name is the label.
• Data can be of two types – Labeled and
Unlabeled

Labeled Data
▪ Data to which some tag/label is attached.
▪ For e.g. Name, type, number, etc.
Unlabeled Data
▪ The raw form of data
▪ Data to which no tag is attached.

What do you mean by a training data set?


▪ The training data set is a collection of examples given to the model to analyze and
learn.
▪ Just like how a teacher teaches a topic to the class through a lot of examples
and illustrations.
▪ Similarly, a set of labeled data is used to train the AI model.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
What do you mean by a testing data set?
▪ The testing data set is used to test the accuracy of the model.
▪ Just like how a teacher takes a class test related to a topic to evaluate the
understanding level of students.
▪ Test is performed without labeled data and then verify results with labels.

2.2 Modelling
Purpose: Classification of Models into Rule-based approach and Learning approach.
Say: “In general, there are two approaches taken by researchers when building AI models. They either
take a rule-based approach or learning approach. A Rule based approach is generally based on the data
and rules fed to the machine, where the machine reacts accordingly to deliver the desired output.
Under learning approach, the machine is fed with data and the desired output to which the machine
designs its own algorithm (or set of rules) to match the data to the desired output fed into the machine”

AI Modelling refers to developing algorithms, also called models which can be trained to get
intelligent outputs. That is, writing codes to make a machine artificially intelligent.

Types of AI Models
Generally, AI models can be classified as follows:

Supervised Learning

Unsupervised
Machine Learning
Learning

Reinforcement
Learning
Learning Based

AI Models
Artificial Neural
Networks
Rule Based
Deep Learning
Convolution Neural
Networks

Rule Based Approach


Rule Based Approach refers to the AI modelling where the relationship or patterns in data are

* Images shown here are the property of individual organisations and are used here for reference purpose only.
defined by the developer. The machine follows the rules or instructions mentioned by the
developer, and performs its task accordingly.
Rule-based Chatbots are commonly used on websites to answer frequently asked questions
(FAQs) or provide basic customer support. Here's an example:

Scenario: A clothing website has a Chabot to answer questions about order tracking.
1. Data: The Chabot doesn't require a massive dataset for training. It relies on a
predefined set of questions and corresponding answers.
2. Rules: The Chabot uses a decision tree approach with clearly defined rules to
understand user queries and provide responses. Here's a simplified example:
o Rule 1: If the user's message contains keywords like "track order," "shipment
status," or "delivery," proceed to order tracking options.
o Rule 2: Under order tracking options:
▪ If the user asks for their order number, prompt them to enter it.
▪ If the user enters a valid order number, retrieve the tracking
information from the database and display it.
▪ If the user enters an invalid order number, provide an error message
and ask them to re-enter it.
o Rule 3: If the user's message doesn't match any defined rules, offer a message
like "Sorry, I can't help you with that. Perhaps you can try searching our FAQs
or contact customer support."
3. Interaction: When a user chats with the bot, their message is analyzed based on the
defined rules. The Chabot responds with a pre-written answer or prompts the user for
additional information depending on the scenario.

A drawback/feature for this approach is that the learning is static. The machine once trained,
does not take into consideration any changes made in the original training dataset. That is, if
you try testing the machine on a dataset which is different from the rules and data you fed it
at the training stage, the machine will fail and will not learn from its mistake. Once trained,
the model cannot improvise itself on the basis of feedbacks. Thus, machine learning gets
introduced as an extension to this as in that case, the machine adapts to change in data and
rules and follows the updated path only, while a rule-based model does what it has been
taught once.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Learning Based Approach
A learning-based approach is a method where a computer learns how to do something by looking at
examples or getting feedback, similar to how we learn from experience. Instead of being explicitly
programmed for a task, the computer learns to perform it by analyzing data and finding patterns or rules
on its own.

For example, suppose you have a dataset of


1000 images of random stray dogs of your
area. Now you do not have any clue as to what
trend is being followed in this dataset as you
don’t know their breed, or colour or any other
feature. Thus, you would put this into a
learning approach-based AI machine and the
machine would come up with various patterns
it has observed in the features of these 1000
images. It might cluster the data on the basis of
colour, size, fur style, etc. It might also come up
with some very unusual clustering algorithm
which you might not have even thought of!

Learning Based AI Model

We can say that it refers to the AI modelling where the machine learns by itself. Under the
Learning Based approach, the AI model gets trained on the data fed to it and then is able to
design a model which is adaptive to the change in data. That is, if the model is trained with X
type of data and the machine designs the algorithm around it, the model would modify itself
according to the changes which occur in the data so that all the exceptions are handled in this
case.
For example, A learning-based spam email filter is a computer program that automatically
identifies whether an incoming email is spam or not. Instead of being explicitly programmed
with rules for identifying spam, the filter learns from examples of labeled emails during a
training phase.

During training, the filter is provided with a large dataset of emails, each labeled as either
spam or legitimate (non-spam). The filter analyzes the content and characteristics of these
emails, such as words used, sender information, and presence of attachments. Using machine
learning algorithms, the filter learns to recognize patterns that distinguish spam from
legitimate emails.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Once trained, the filter can classify new incoming emails as spam or not spam based on the
patterns it learned. It continuously adapts and improves its accuracy over time as it encounters
new examples. This learning-based approach allows the filter to effectively identify and filter
out spam emails, helping users manage their email inbox more efficiently.

Categories of Machine learning based models


Learning-based approaches are indeed a broad category that encompass both machine
learning and deep learning. Machine learning can further be divided into three parts:
Learning Based Approach

Supervised
(Machine Learning)

Learning

Unsupervised
Learning

Reinforcement
Learning

Supervised Learning
In a supervised learning model, the dataset which is fed to the machine is labelled. In other
words, we can say that the dataset is known to the person who is training the machine only
then he/she is able to label the data. A label is some information which can be used as a tag
for data. For example, students get grades according to the marks they secure in
examinations. These grades are labels which categorize the students according to their marks.

▪ Supervised Learning indicates having a supervisor as a


teacher
▪ For e.g. A math teacher teaches the class by making the
students learn using a lot of solved examples(training) and
then test the knowledge gained by giving the class, problems
to solve on their own.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
▪ Similarly, Supervised Learning is when you make the machine learn by teaching or
training the machine using labeled data.

Supervised Learning – Example


▪ Let’s consider the example of currency coins.
▪ Problem Statement: Build a model to predict the coin based on its weight.
▪ Assume that we have different currency coins (dataset) having different weights.
▪ 1 Euro weighs 5 grams

▪ 1 Dirham weighs 7grams


▪ 1 Dollar weighs 3grams
▪ 1 Rupee weighs 4 grams and so on
▪ Feature – Weights
▪ Label – Currency

So, if a model is trained in tagging the features i.e., the weights of the coin with the targets
i.e., currency, the trained model can be further be used to identify a coin based on its
weight (since it has already learnt).
▪ In the example shown in the
image, the model has learned
from labeled input data and
produces output to classify them
as dogs and cats.
▪ Therefore, you can see that the
model learns from the training
data and then applies the same
knowledge to test data.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Unsupervised Learning
An unsupervised learning model works on unlabelled
dataset. This means that the data which is fed to the
machine is random and there is a possibility that the
person who is training the model does not have any
information regarding it. The unsupervised learning
models are used to identify relationships, patterns and
trends out of the data which is fed into it. It helps theuser
in understanding what the data is about and whatare the
major features identified by the machine in it.
For example, you have a random data of 1000 dog images and you wish to understand some
pattern out of it, you would feed this data into the unsupervised learning model and would
train the machine on it. After training, the machine would come up with patterns which it
was able to identify out of it. The Machine might come up with patternswhich are already
known to the user like colour or it might even come up with somethingvery unusual like the
size of the dogs.

▪ Unsupervised Learning is a type of learning without any guidance


▪ For e.g. A child learning to swim on his own without any supervision. Here, the child is
the model trying to discover ways and techniques to swim and the swimming pool is
similar to the unknown data fed to the model.
▪ Here, the machine is responsible to discover patterns, similarities, and differences on
its own based on the unlabeled dataset.

Unsupervised Learning - Example


Let’s consider the example of a supermarket
Assume that we have a customer database with records of their
products bought over a period.
Now you being the marketing manager decides to send a
grocery offer message to those customers who buys grocery
regularly.
• Note that there was no customer labeled as grocery shoppers and non-grocery
shopper.
• Model could discover patterns on its own and could come up with these two
clusters/groups.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
• In the example shown in the image, the model
has to process information without any labels.
• It has to analyze and process the data to identify
hidden patterns and attributes and then uses
that to classify the animals into two categories
based on similarities
As you observe in the image, input is not labeled but
the model can come up with two clusters by identifying similar patterns and attributes and
have grouped them together-
• All Cats have been grouped into cluster 1
• All Dogs have been grouped into cluster 2

Test Yourself:
Identify the model: Supervised or Unsupervised?
Case 1: Social Media platforms identify your friend in a picture from an album of tagged
photographs

It is supervised learning. Here social media platform is using tagged photos to recognize the
person. Therefore, the tagged photos become the labels of the pictures and we know that
when the machine is learning from labeled data, it is supervised learning.
Case 2: OTT platform Recommendations based on someone’s watch history

It is unsupervised learning. This is what OTT platforms like Netflix, Pandora, and Spotify do all
the time; they collect the songs/movies that you like already, evaluate the features based on
your likes/dislikes and then recommend new movies/songs based on similar features.
* Images shown here are the property of individual organisations and are used here for reference purpose only.
Case 3: Analyze bank data for suspicious-looking transactions and flag the fraud transactions
[Note that suspicious transactions are not defined in this case]

It is unsupervised learning. In this case, the suspicious transactions are not defined, hence
there are no labels of "fraud" and "not fraud". The model tries to identify outliers by looking
at anomalous transactions and flags them as 'fraud'.
Supervised Vs. Unsupervised Learning

Reinforcement Learning
This learning approach enables the computer to make a series of decisions that maximize a
reward metric for the task without human intervention and without being explicitly
programmed to achieve the task.
Reinforcement Learning – Example

▪ Reinforcement learning is a type of learning in which a machine learns to perform a


task through a repeated trial-and-error
method.
▪ Let’s say you provide an image of an apple to
the machine and ask the machine to predict it-
▪ The machine first predicts it as ‘cherry’ and
you give negative feedback that it’s incorrect.
▪ Now, the machine learns that it’s not a cherry.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
▪ Then again, you ask the machine to
predict the fruit by giving an image of an
apple as input;
▪ Now, it knows it is not a cherry.

▪ It predicts it as an apple and you give positive


feedback that it’s correct.
▪ So, now the machine learns that this is an apple.

What makes it different?


1. For supervised learning and unsupervised learning, you need to have a pretty good
idea of the data that you have, what’s going on, and how to solve the problem.
2. However, you will frequently encounter situations where you have to deal with large
complex problem spaces.
3. You may need to respond to unforeseen environments, and you don’t have
sufficient data on those specific scenarios.

4. The environment may change. Hence your system needs to be adaptive.


Reinforcement Learning will be important because it doesn’t require a lot of pre-
existing knowledge or data to provide useful solutions.

Examples of Reinforcement Learning

Parking a car Humanoid walking

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Summary of ML Models

• Supervised learning models are used when we want to determine relationships


through training.
• Unsupervised learning models are used when we want to discover new patterns from
data.
• Reinforcement learning models are used when we want to implement machine
learning through a reward mechanism.

Family of
ML Models

Supervised Unsupervised Reinforcement


Learning Learning Learning

Determine Learn by
Discover New
relationships Rewarding
Patterns
through training Actions

Sub-categories of Supervised Learning Model

There are two types of Supervised Learning models: Classification model and Regression
model.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Classification Model

Here the data is classified according to the


labels. For example, in the grading system,
students are classified on the basis of the
grades they obtain with respect to their
marks in the examination. This model
works on discrete dataset which means
the data need not be continuous.

Examples of the Classification Model

In this case, the model would be trained on historical weather data that includes
temperature information labeled as "hot" or "cold". The model would learn the patterns
that differentiate hot and cold weather based on
factors like:

• Location (average temperatures vary


geographically)
• Season (summer vs. winter)
• High and low temperatures
• Humidity

When presented with weather data for tomorrow, the


trained classification model would analyze these
factors and predict the most likely category - "hot" or "cold" weather tomorrow.

Classifying emails as spam or not: The model is shown tons of emails, both real ones (like
from friends or colleagues) and spam. The model learns what makes an email look like spam.
Once trained, the model sees a new email. It analyzes the clues in the email and decides: is
this spam or not? It assigns a category - "spam" or "not spam" - just like sorting your mail.

In modern-day Email, classifiers identify if the email is spam and have evolved into other
categories such as social, advertisement, notifications, etc. Similar models are increasingly
being used in messaging applications.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Regression Model
Regression: Such models work on continuous data. For
example, if you wish to predict your next salary, then you
would put in the data of your previous salary, any
increments, etc., and would train the model. Here, the data
which has been fed to the machine is continuous.

▪ Regression algorithms predict a continuous value based on the input variables.


▪ Continuous values as Temperature, Price, Income, Age, etc.

Examples of the Regression Model


Example 1: Predicting temperature
Temperature is a continuous variable, meaning it can
take on any value within a range. Regression models are
well-suited for predicting continuous outputs.
Example 2: Predicting the price of the house
Predicting the price of the house based on some parameters:
1. [Features/Independent Variables]
1. No of bedrooms
2. Carpet Size
3. Garage Area
2. [Label/Dependent Variable]
1. Price [Label/Dependent Variable]
▪ In the House Price Prediction Problem, we are trying to predict the price (dependent
variable) based on certain parameters like the number of bedrooms, carpet size, and
garage area (independent variables).
Example 3: Used Car Price Prediction
This model predicts the selling price of the car with the help of a few parameters like
▪ fuel type,

* Images shown here are the property of individual organisations and are used here for reference purpose only.
▪ years of service,
▪ the number of previous owners,
▪ kilometers driven,
▪ transmission type (manual/automatic)
This type of model will be of type regression since it will predict an approximate price
(continuous value) of the car based on the training dataset.

Test Yourself:
Identify the model: Classification or Regression?
Case 1: Predicting whether a customer is eligible for a bank loan or not?

It is Classification. Binary Classification; since the model is going to predict whether or


not the customer is eligible for a loan- The output will be either yes or no (discrete
values)

Case 2: Predicting weather for next 24 hours

It is Regression because predicting weather for next 24 hours will be a continuous range
(it will keep changing over the period of 24 hours)

Sub-categories of Unsupervised Learning Model


Unsupervised learning models can be further divided into two categories: Clustering model
and Association model.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
What is Clustering?

In this example, we have input data with no class labels (unlabeled data), and this input data
comprises of birds and animals. Note that, even though there were no class labels, the
unsupervised learning model was able to divide this data into two clusters based on clustering.
The two clusters have been formed based on the similarity of characteristics. The first cluster
comprises all the animals, and the second cluster comprises all the birds.

Difference between Clustering and Classification


▪ Classification uses predefined classes in which objects are assigned.
▪ Clustering finds similarities between objects and places them in the same cluster and
it differentiates them from objects in other clusters.

Clustering – Example
Jim enjoys listening to music. Jim likes to listen to music having slow tempo and soft
intensity whereas he dislikes songs having fast tempo and high intensity.
▪ We have grouped all the songs having slow tempo and soft intensity into 1 cluster that
he likes
▪ While, songs with a fast tempo and high intensity into another cluster
▪ Now if he listens to a new song X with a slow tempo and soft intensity. Could you
predict will he like the song X or not?
This is how clustering techniques work. The clustering model will be able to identify
clusters based on some similarities or patterns which are not defined in the input. For
example, tempo and intensity are the only features known, but clusters based on likes and
dislikes have been grouped together and given as output. Similar techniques are used in
OTT platforms like Netflix/Spotify for recommendations.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Association
Association Rule is an unsupervised learning method that is used to find interesting
relationships between variables from the database.

Based on the purchase pattern of customers A and B, can you predict any Customer X who
buys bread will most probably buy?

Based on the purchase pattern of other customers, we can predict that there is highprobability
that any customer x who buys bread will most probably buy butter.
Therefore, such meaningful associations can be useful to recommend items to customers. Thisis
called Association Rule.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Summary of detailed classification of ML models

Test Yourself:

Let’s have knowledge check based on learning approaches and its types!
Q1. Which learning approach uses labelled data for training?

Supervised Learning Reinforcement Learning

Unsupervised Learning

Q2. The target variable is categorical in Problem?

Regression Clustering Classification

Q3. Which algorithmic model would you use when you have to predict a continuous
valued output?

Regression Clustering Classification

Q4. Which of the following is false about Reinforcement Learning?

Uses Reward Mechanism Target is to Maximize the Reward

Predicts a continuous value as output

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Q5. Clustering is learning and its goal is to ?

Supervised, Classify data points Unsupervised, Divide the data


intodifferent classes points into different groups

Unsupervised, Predict the output based


on input data points

Sub-Categories of Deep Learning


Deep Learning enables software to train itself to perform tasks with vast amounts of data.
In deep learning, the machine is trained with huge amounts of data which helps it to train
itself around the data. Such machines are intelligent enough to develop algorithms for
themselves. There are two types of Deep Learning models: Artificial Neural Networks (ANN)
and Convolution Neural Network (CNN).

Artificial Neural networks (ANN) - Artificial Neural networks are modelled on the human brain
and nervous system. They are able to automatically extract features without input from the
programmer. Every neural network node is essentially a machine learning algorithm. It is
useful when solving problems for which the data set is very large.

Convolutional Neural Network (CNN) - Convolutional Neural Network is a Deep Learning


algorithm which can take in an input image, assign importance (learnable weights and
biases) to various aspects/objects in the image and be able to differentiate one from the o

* Images shown here are the property of individual organisations and are used here for reference purpose only.
2.3 Artificial Neural Networks

Purpose: To understand and experience what a neural network is like.

Brief:
Neural networks are loosely modelled after how neurons in the human brain behave.
The key advantage of neural networks is that they are able to extract data features
automatically without needing the input of the programmer. A neural network is essentially
a system of organizing machine learning algorithms to perform certain tasks. It isa fast and
efficient way to solve problems for which the data set is very large, such as in images.

What is Neural Network?


Neural networks are loosely modelled after
how neurons in the human brain behave. The
key advantage of neural networks is that they
are able to extract data features
automatically without needing the input of
the programmer. A neural network is
essentially a system of organizing machine
learning algorithms to perform certain tasks.
It is a fast and efficient way to solve problems
for which the dataset is very large, such as in images.

This is a representation of how neural networks work:

▪ A Neural Network is divided into multiple layers and each layer is further divided into
several blocks called nodes. Each node has its own task to accomplish which is then
passed to the next layer.

▪ Neural Network consists of an input layer, hidden layer which performs computation
using weights and biases on each node and finally, information is passed through these
layers to reach the output layer.

• The first layer of a Neural Network is known as the input layer. The job of an input
layer is to acquire data and feed it to the Neural Network. No processing occurs at
the input layer.

• Next to it, are the hidden layers. Hidden layers are the layers in which the whole
processing occurs. Their name essentially means that these layers are hidden and are
not visible to the user. Each node of these hidden layers has its own machine
learning algorithm which it executes on the data received from the input layer.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
▪ The hidden layer performs computation by means of weights and biases Information
passes from one layer to the other after the value found from this calculation passed
through a selected activation function.

▪ The process of finding the right output begins with trial and error until the network
finally learns.

▪ With each try, the weights are adjusted based on the error found between the
desired output and the network output.

There can be multiple hidden layers in a neural network system and their number
depends upon the complexity of the function for which the network has been
configured. Also, the number of nodes in each layer can vary accordingly. The last
hidden layer passes the final processed data to the output layer which then gives it to
the user as the final output. Similar to the input layer, output layer too does not process
the data which it acquires. It is meant for user-interface.

Real-world applications of neural network are facial recognition, customer support


chatbot, vegetable price prediction etc.

How does AI make a Decision?


Let's say you want to go out to the park today. What would be your thought process? What
would you consider?

Most of us would want to avoid getting soaked in the rain. These are possible factors that
may influence your decision whether to go out. So, the first question that you may ask is,
“Should I bring a rain jacket?”
Then, you may also ask, “Should I bring an umbrella?”Or
you may also ask, “What is the weather now?”

And finally, “What will the weather be like, later in the day?”

Do I have a jacket? Do I have an umbrella? Is it raining now? What is the weather


forecast for later?

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Now, you have the factors that will influence your
decision to go out. But take note, not all factors are
equal. Some factors are more important, while some
are not.
Let's see which one is more important. Let us rank
them from the most important to the least
important.
For me, “is it sunny now” is more important than
“the weather forecast later”. And “having a jacket”
is more important than “having an umbrella. We can
put the ranking for this example.

Now let us convert this to perceptron.

Going back to the earlier example, we have four inputs. So, let’s draw the perceptron with
four inputs (from X1 to X4). Next, we have their weights (from W1 to W3). Then, we also
have the bias B, with weight WB.
Finally, we sum them all up, compare with threshold, and we will get our output.

Now we will fill in the four inputs with the factors that we have listed out.
•Do I have a jacket?
•Do I have umbrella?
•Is it sunny now?
•What is the weather forecast for later?

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Now we will fill in the importance. But the importance is not very useful in mathematical
calculations.
Next, let us assign some numbers to them. At the same time, we will also assign a numberfor
the bias weight (WB).
How do we know what should be the actual values for the weights? We will not know whatare
the actual weights. However, we can make some assumptions.

The values for the weights can come from experience. He may have an experience being
sunny now would most likely mean a bright day ahead, hence the high importance there.
It can also come from personal preference. A person may judge a particular factor more
heavily as compared to another person. For example, she may be more concerned with
the weather forecast, hence the higher importance there.

The values for WB are also based on personal preference. If a person is more cautious,
he may set the value for WB to be higher, hence his decision would gear towards staying
indoors unless he is sure that it would not rain. On another hand, a person who is more
daring will have a lower WB, hence he is more likely to go out regardless of the current
situation. In this example, we choose 4 as we want to be more cautious.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Therefore, there is no right or wrong answers in coming up with the values for the
weights. However, the effects of the values will determine the outcome that the person
is going to take, whether to go out or not. That is the reason why everyone comes up
with a different decision, even though the situation is the same for everyone.
For this example, let’s say: I have a jacket, I don’t have an umbrella, it is sunny now, and
the weather forecast is going to rain. We can convert the yes and no to numbers 1 and
0. For bias, we will always take 1.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
From this calculation, the output is 0.5. Since this is higher than the threshold (which is
zero), the result is I will go out to the park.

Now let us change for another example.


let’s say: I don’t have a jacket, I have an umbrella, it is not sunny now, and the weather
forecast is ok. We will convert the yes and no to numbers 1 and 0. And similarly, for bias,
we will take1.

From this calculation, the output is -0.5. Since this is lower than the threshold (which is
zero), the result is I will not go out to the park.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Activity 1
Human Neural Network – The Game

Session Preparation

Logistics: For a class of 40 students [Individual Activity]

Materials Required:

ITEM QUANTITY
Images (To be kept with the facilitator) 2
Post-It Notes 80
Sketch-pens 40

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Purpose: To understand and experience what a neural network is like.
Brief:

Students will now experience how Neural networks work with the help of an activity. Each
of the students will be considered as the node of either Input Layer,1 st Hidden Layer, 2nd
Hidden Layer or the Output Layer. The instructions and rules have been mentioned in the
Students Handbook.

After arranging the students at their positions and handing them sticky notes to write,
show the sample image print-out to the input layer students. Let the students
understand and do by themselves after this.

When to intervene?

Ask the students to play the game with honesty. No two nodes can discuss anything.
Each one of them has to use their own discretion to understand and play.

Let us develop a better understanding about this concept with the help of a game called
Human Neural Network.
Game Structure:

Layers Number of Students Number of chits


Input Layer 7 6
Hidden Layer 1 6 4
Hidden Layer 2 6 2
Output Layer 1 -
TOTAL 20 -

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Ground Rules:
● No one is allowed to talk or discuss till the game ends. Fun of the game lies in playing it
honestly.
● Each layer should sit distant to each other.
● The image should only be shown to the Input layer and no one else.
● The game is supposed to be played silently. This means that one has to write a word on the
chit and pass on the chit without speaking out aloud.
● One needs to process the data as fast as possible, hence not take much time can be taken
to write and pass on the chits.
● Input layer nodes cannot discuss the image shown with each other. Everyone has to use
their own discretion.
● No sentences or multiple words are to be written on the chit. Only one word per chit is
allowed.
● Once the task of a layer is finished, that layer needs to go and sit aside and not
disturb others till the game ends.

Game Instructions:
Input Layer:
7 students will be standing as the nodes of an input layer.
All of them will be shown an image. After looking at it, they need to write 6 different
words on 6 different chits. They have to choose the words which describe the image in
the best way possible. They can also repeat the words if needed.
After making these chits, they need to pass on one chit to each of the nodes of hidden
layer 1. That is, 1 chit will be given to one member.

Hidden Layer 1:
6 students will be standing as the nodes of hidden layer 1.
Each of them will receive 7 chits from 7 different input nodes. Now they have to take a
good look at the chits and then write down 4 different words on 4 different chits. For this,
they can either use the same words as the input layer did, or they can make their own
information (relevant to the context) and write it.
Now these 4 chits are to be given randomly to any 4 nodes of Hidden Layer [Link] of the
6 nodes of 2nd hidden layer, one can choose any 4 and give once chit to each. (For best
results, each node of hidden layer 2 should get almost same number of chits thus the
division should be done properly)

Hidden Layer 2:
6 Students will be standing as the nodes of hidden layer 2.
Each one of them will get some number of chits from the previous layer. Now they have
to perform the same task as hidden layer 1 and have to write down2 different words on
2 different chits and pass it on to the output layer.
Output Layer:
Finally, the output layer node will get 12 chits. Now s/he has to understand all the words
and has to guess which image was shown to the input layer initially.
Output layer will then write a summary out of all the words received to explain his/her
deduction. The summary should not be more than 5 lines.

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Finally, the output layer presents this summary in-front of everyone and the real image
is finally revealed to all.

If the summary is accurate enough, the whole network wins else they lose.

Test Yourself:
Choose the most appropriate answer for each question.

1. In which type of machine learning is the data labeled with the desired output?
a) Supervised Learning
b) Unsupervised Learning
c) Reinforcement Learning
d) Deep Learning

2. An email spam filter that learns to identify spam emails based on labeled examples is an
application of:
a) Supervised Learning
b) Unsupervised Learning
c) Reinforcement Learning
d) Transfer Learning

3. A machine learning algorithm that groups similar customer purchases into clusters for
recommendation systems uses:
a) Supervised Learning
b) Unsupervised Learning
c) Reinforcement Learning
d) Neural Networks

4. An AI agent playing a game and learning from its rewards and penalties is an example of:
a) Supervised Learning
b) Unsupervised Learning
c) Reinforcement Learning
d) Evolutionary Learning
* Images shown here are the property of individual organisations and are used here for reference purpose only.
5. Which of the following statements is NOT true about supervised learning?
a) Requires labeled data for training.
b) Used for classification and regression tasks.
c) Can be less efficient for large datasets.
d) Often used in image recognition applications.

6. In an unsupervised learning scenario, the goal is to:


a) Predict a specific output based on labeled data.
b) Identify patterns and relationships within unlabeled data.
c) Train an AI agent through rewards and penalties.
d) Develop complex neural network architectures.

7. Clustering algorithms are commonly used in unsupervised learning for:


a) Spam filtering
b) Image classification
c) Stock price prediction
d) Grouping similar data points

8. Reinforcement learning is particularly useful for scenarios where:


a) Large amounts of labeled data are available.
b) The desired outcome is clear, but the path to achieve it is unknown.
c) The data is structured and easily categorized.
d) The task requires reasoning and logical deduction.

9. Imagine an AI playing a game and learning to win by trial and error. This is an example of:
a) Supervised Learning
b) Unsupervised Learning
c) Reinforcement Learning
d) Natural Language Processing

* Images shown here are the property of individual organisations and are used here for reference purpose only.
10. Artificial neural networks are inspired by the structure and function of:
a) The human brain
b) Quantum computers
c) Complex mathematical models
d) High-speed processors

11. The process of adjusting the weights in a neural network to improve performance is called:
a) Activation
b) Learning
c) Optimization
d) Training

12. A neural network with multiple layers of interconnected neurons is called a:


a) Single-layer network
b) Deep Neural Network
c) Linear network
d) Perceptron

13. Neural networks are particularly well-suited for tasks involving:


a) Simple calculations and mathematical operations
b) Recognizing patterns in complex data like images and text
c) Performing logical deductions and reasoning tasks
d) Storing and retrieving large amounts of information

14. Training a neural network often requires:


a) A small set of labeled data samples
b) A significant amount of data and computational resources
c) A specific set of programming instructions
d) A human expert to guide the learning process

* Images shown here are the property of individual organisations and are used here for reference purpose only.
Assertion and reasoning-based questions:
Q1. Assertion: Unsupervised Learning is a type of learning without any guidance.
Reasoning: Unsupervised learning models work on unlabeled datasets, where the data fed
into the machine is random and the person training the model may not have any prior
information about it.
Options:
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True

Q2. Assertion (A): Information processing in a neural network relies on weights and biases
assigned to nodes.

Reasoning (R): These weights and biases determine how strongly a node is influenced by its
inputs and its overall contribution to the next layer.

Reflection Time:
Answer the following questions:
Q1. Give difference between rule based and learning based AI models.
Q2. What is supervised, unsupervised and reinforcement learning? Explain with examples.
Q3. What is clustering and how is it different from classification?
Q4. Explain neural networks. Also give functions of three layers of neural networks.Q5.
Differentiate between classification and regression model.
Q6. What is neural network? Give the functioning of its three layers?
Q7. Identify the type of learning (supervised, unsupervised, reinforcement learning) are the
following case studies most likely based on?
a) Case Study 1:
A company wants to predict customer churn based on past purchasing behavior,
demographics, and customer interactions. They have a dataset with labeled examples
of customers who churned and those who did not.
b) Case Study 2:
A social media platform wants to group users based on their interests and behavior to
recommend relevant content. They have a large dataset of user interactions but no
predefined categories. Which type of learning is this case study most likely based on?
c) Case Study 3:
* Images shown here are the property of individual organisations and are used here for reference purpose only.
An autonomous vehicle is learning to navigate through a city environment. It receives
feedback in the form of rewards for reaching its destination safely and penalties for
traffic violations. Which type of learning is this case study most likely based on?
d) Case Study 4:
A healthcare provider wants to identify patterns in patient data to personalize
treatment plans. They have a dataset with various patient attributes but no predefined
labels indicating specific treatment plans. Which type of learning is this case study
most likely based on?
e) Case Study 5:
A manufacturing company wants to optimize its production process by detecting
anomalies in sensor data from machinery. They have a dataset with examples of
normal and anomalous behavior. Which type of learning is this case study most likely
based on?

Q8. Identify the type of model (classification, regression, clustering, association model) are
the following case studies most likely based on?
a) A bank wants to predict whether a loan applicant will "default" or "non-default" on
their loan payments. They have a dataset containing information such as income,
credit score, loan amount, and employment status.

b) A real estate agency wants to predict the selling price of houses based on various
features such as size, location, number of bedrooms, and bathrooms. They have a
dataset containing historical sales data.

c) A marketing company wants to segment its customer base into distinct groups based
on purchasing behavior for targeted marketing campaigns. They have a dataset
containing information such as purchase history, frequency of purchases, and amount
spent.

d) A grocery store wants to identify associations between different products purchased


by customers to understand which products are commonly bought together. They have
a transaction dataset containing records of items purchased together during each
transaction.

Q9. A healthcare provider wants to improve patient care by predicting the length of hospital
stays for different medical conditions. They have a dataset containing patient demographics,
medical history, and treatment details. The task involves:

a) To predict whether a patient will have a short or long hospital stay.


b) To predict the number of days a patient will stay in the hospital.
c) To segment patients into groups with similar characteristics for personalized treatment
plans.
d) To identify patterns in patient treatments and outcomes.
* Images shown here are the property of individual organisations and are used here for reference purpose only.
Identify the type of model (classification, regression, clustering, and association model) in the
above tasks.
Q10. Convert the following scenarios to perceptron:
a) Context: A manager is deciding whether to approve a work-from-home request
from an employee.
Factors:
- Does the employee perform well when working remotely?
- Are there any upcoming team meetings or collaborative projects?
- Does the company's policy support remote work?
- Is it beneficial for both the employee and the company?

b) Context: A homeowner is deciding whether to invest in solar panels for their


house.
Factors:

- Do I have a sufficient average amount of sunlight in my area?


- Are there any available incentives or rebates for installing solar panels?
- Does installing solar panels impact the value of my home?
- Does solar energy lead to environmental benefits?

* Images shown here are the property of individual organisations and are used here for reference purpose only.

You might also like