0% found this document useful (0 votes)
13 views46 pages

Unit2 Unit3 Notes

The document explains the distinctions between Artificial Intelligence (AI), Machine Learning (ML), and Deep Learning (DL), highlighting their functionalities and applications. It details various ML models, including supervised, unsupervised, and reinforcement learning, along with their subcategories and examples. Additionally, it covers the structure and operation of neural networks, emphasizing their role in deep learning.

Uploaded by

sinanusinan881
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)
13 views46 pages

Unit2 Unit3 Notes

The document explains the distinctions between Artificial Intelligence (AI), Machine Learning (ML), and Deep Learning (DL), highlighting their functionalities and applications. It details various ML models, including supervised, unsupervised, and reinforcement learning, along with their subcategories and examples. Additionally, it covers the structure and operation of neural networks, emphasizing their role in deep learning.

Uploaded by

sinanusinan881
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

Differentiate between AI, ML, and DL

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.

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.

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.

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 within an 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:

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 in a 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

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.

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.

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

Rule Based Approach


Rule Based Approach refers to the AI modelling where the relationship or patterns in data are
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
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.
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.

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:

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 labelled data.

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 the user in
understanding what the data is about and what are 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 patterns which are already known to the user like colour
or it might even come up with something very 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 unlabelled dataset.

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.

Case 3: Analyze bank data for suspicious-looking transactions and flag the fraud transactions
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.

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

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.
Sub-categories of Supervised Learning Model
There are two types of Supervised Learning models: Classification model and Regression model.

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
• "hot" or "cold" weather tomorrow
• Classifying emails as spam or not
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


• Predicting temperature
• Predicting the price of the house
• Used Car Price Prediction

Identify the model: Classification or Regression?


Case 1: Predicting whether a customer is eligible for a bank loan or not?
Case 2: Predicting weather for next 24 hours
Model Unsupervised learning models can be further divided into two categories: Clustering
model and Association model.

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.
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 other customers, we can predict that there is high probability that
any customer x who buys bread will most probably buy butter. Therefore, such meaningful
associations can be useful to recommend items to customers. This is called Association Rule.

Summary of detailed classification of ML models


Let’s have knowledge check based on learning approaches and its types

Q1. Which learning approach uses labelled data for training?


a) Supervised Learning
b) Reinforcement Learning
c) Unsupervised Learning
Q2. The target variable is categorical in Problem?
a) Regression
b) Clustering
c) Classification
Q3. Which algorithmic model would you use when you have to predict a continuous valued
output?
a) Regression
b) Clustering
c) Classification
Q4. Which of the following is false about Reinforcement Learning?
a) Uses Reward Mechanism
b) Classification Target is to Maximize the Reward
c) Predicts a continuous value as output
Q5. Clustering is ………………….learning and its goal is to……………… ?
a) Supervised, Classify data points into different classes
b) Unsupervised, Divide the data points into different groups
c) 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 other

Artificial Neural Networks


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 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.
▪ 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.

Summary Points
1. AI Models are broadly categorized into:
▪ Rule-based models: Follow pre-defined rules and do not adapt to new data
▪ Learning-based models: Learn from data and adapt over time.
2. Machine Learning (ML) is a subset of AI, and Deep Learning (DL) is a subset of ML.
3. Supervised Learning uses labelled data to train models (e.g., spam detection, coin
recognition).
4. Unsupervised Learning works on unlabelled data to discover hidden patterns (e.g., customer
segmentation, fraud detection).
5. Reinforcement Learning is based on feedback from the environment (e.g., AI playing a game,
autonomous vehicles).
6. Classification vs. Regression: ▪ Classification → discrete output (example: spam or not) ▪
Regression → continuous output (example: house price prediction)
7. Clustering and Association are core unsupervised learning techniques: ▪ Clustering → group
similar data points ▪ Association → discover relationships between variables
8. Neural Networks simulate brain-like structure and are used to process complex data like
images and texts.
9. Artificial Neural Networks (ANNs) are made of input, hidden, and output layers. They use
weights, biases, and activation functions.

Multiple Choice Questions (1 Mark)


1. Which of the following is an example of supervised learning?
a) Clustering animals into groups b) Spam email classification
c) Discovering shopping patterns d) Grouping news articles
2. What type of data does supervised learning use?
a) Unlabelled b) Random c) Labelled d) Mixed
3. Which model works on the principle of reward and punishment?
a) Supervised Learning b) Unsupervised Learning c) Classification d)
Reinforcement Learning
4. Which sub-field of AI mimics the human brain structure?
a) Artificial Neural Networks b) Convolutional Networks
c) Decision Trees d) Rule-based Systems
5. What does ANN stand for?
a) Artificial Nerve Network b) Automated Neural Network
c) Artificial Neural Network d) Adaptive Node Network

6. Which type of learning is used when we do not know the output?


a) Supervised b) Unsupervised
c) Reinforcement d) Logical

7. Which of the following is not an application of machine learning and deep


learning?
a) Digit recognition b) Face detection
c) Spam email classification d) Rule-based chat

8. What does the input layer in a neural network do?


a) Feed data into the network b) Connect output nodes
c) Process information d) Decide final result

9. Which AI model uses fixed rules to make decisions?


a) Reinforcement model b) Learning-based model
c) Rule-based model d) Regression model

10. Which of the following is a feature in a dataset?


a) Labels only b) Column attributes
c) Output values d) Predefined answers

11. Which learning type is most suitable for anomaly detection?


a) Unsupervised b) Reinforcement
c) supervised d) Regression

12. Which of the following is a classification problem?


a) Predicting stock prices
b) Grouping books by genre
c) Estimating house prices
d) Predicting whether a customer will buy a product or not
13. In reinforcement learning, what happens when the agent performs incorrectly?
a) It is terminated b) It is rewarded
c) It is penalized d) It resets

14. Deep learning is best applied in which scenario?


a) large image datasets b) Structured tabular data
c) small dataset d) Binary classification

15. Which of the following best describes a regression model?


a) Classifies data into clusters b) Predicts continuous values
c) Finds associations d) Uses feedback for learning

16. Which learning model would you choose for a stock price prediction system?
a) Clustering b) Classification
c) Regression d) Association

17. Which of the following is valid according to Neural Networks?


a) Neural Network contain 4 layers (input, processing, hidden and output layers)
b) In Neural Networks every node is essentially a machine learning algorithm.
c) Use the Neural Network if the dataset is small only.
d) The input layers processes the data with algorithms and supply to next layer.

18. What differentiates reinforcement learning from supervised learning?


a) Uses labelled data b) Uses reward-based feedback
c) Works only with images d) Is used for classification

19. Which layer of a neural network performs most of the computation?


a) Input layer b) Output layer
c) Hidden layer d) Bias layer

20. In neural networks, what are weights and biases used for?
a) Visualizing features b) Scaling output
c) Adjusting influence of input nodes d) Measuring data size

21. In association models, what kind of insight is generated?


a) Labels b) Predictions
c) Relations between variables d) Probabilities
22. A smart assistant recommends songs based on listening history. Which type of
learning is it using?
a) Supervised b) Unsupervised
c) Reinforcement d) Regression
23. A company wants to forecast next quarter's revenue. Which model should they
use?
a) Classification b) Regression
c) Clustering d) Reinforcement

24. An AI robot improves its performance by navigating a maze through repeated


tries. What learning type is this?
a) Supervised b) Unsupervised
c) Reinforcement d) Regression

25. A retail store wants to understand which products are frequently bought
together. Which model fits?
a) Classification b) Regression
c) Clustering d) Association

26. An app filters spam messages using a pre-trained dataset. What learning
approach does it use?
a) Supervised b) Unsupervised
c) Reinforcement d) Association

27. What is the main purpose of the bias in a perceptron model?


a) To increase the number of input features
b) To adjust the learning rate
c) To shift the decision boundary
d) To reduce overfitting

28. Which of the following is a real world application of Neural Networks?


a) Facial Recognition b) Customer support Smart bot
c) Weather forecast analysis d) All the above
29. Which of the following statements best describes a perceptron?
a) A simple neural network that performs linear classification.
b) A non-linear machine learning model used for complex tasks.
c) A complex deep learning network with multiple hidden layers.
d) A type of reinforcement learning algorithm.

30. The perceptron algorithm can only solve which type of problems?
a) Non-linear classification
b) Multi-class regression
c) Linearly separable classification
d) Time-series forecasting

Assertion and Reason based Questions:


31) Assertion (A): Supervised learning uses labelled data to train AI models.
Reason (R): Labels help the model understand the correct output for each input.
a) Both A and R are true and R is the correct explanation of A
b) Both A and R are true but R is not the correct explanation of A
c) A is true but R is false
d) A is false but R is true

32)Assertion (A): Unsupervised learning can identify hidden patterns in data.


Reason (R): Unsupervised learning requires data that is already labelled for
classification.
a) Both A and R are true and R is the correct explanation of A
b) Both A and R are true but R is not the correct explanation of A
c) A is true but R is false
d) A is false but R is true

33) Assertion (A): Neural Networks have multiple layers for processing
information.
Reason (R): The hidden layers of a neural network help the machine perform
calculations and learn patterns.
a) Both A and R are true and R is the correct explanation of A
b) Both A and R are true but R is not the correct explanation of A
c) A is true but R is false
d) A is false but R is true
34)Assertion (A): Reinforcement learning works without labeled data.
Reason (R): The model learns by receiving feedback from its actions.
a) Both A and R are true and R is the correct explanation of A
b) Both A and R are true but R is not the correct explanation of A
c) A is true but R is false
d) A is false but R is true

35)Assertion (A): Regression models are used when output is a category like spam
or not spam.
Reason (R): Regression works with continuous numerical values, not
categories.
a) Both A and R are true and R is the correct explanation of A
b) Both A and R are true but R is not the correct explanation of A
c) A is true but R is false
d) A is false but R is true
Short Answer Questions with Answers
Q1. Define Machine Learning (ML) with examples.
Answer: Machine Learning enables machines to learn from data and improve
from experience.
Examples: Object Classification, predicting house prices, predicting
temperature, Predicting stock prices, Anomaly detection in emails.

Q2. Write a difference between Training Data and Testing Data.


Answer:
Training Data Testing Data

Training dataset is a collection of samples Testing data is a collection of samples


given to the model to analyse and learn. given to the model to test its accuracy.

Q3. Give two real-life examples of reinforcement learning.


Answer:
a. An AI playing a video game and improving by receiving rewards and
penalties.
b. A Self driving car trying to park in empty parking slot.

Q4. What is an Artificial Neural Network (ANN)?


Answer:
ANN is a computing system inspired by the human brain, consisting of layers of
interconnected nodes that process data and learn patterns. Each Node in ANN
acts as a Machine learning algorithm.

Q5. What are features in a dataset? Identify the Label and feature from the given table.
Answer:
▪ Features are individual measurable properties or characteristics of a
dataset.
▪ If we are predicting the company based on the model than Company is
Label and Model is Feature.
Q6. A social media app tags your friends in photos using previously tagged
data. Identify the learning type and justify.
Answer:
It is Supervised Learning because the model uses labelled (tagged) data to make
predictions.
Q7. How is a rule-based AI model different from a learning-based model
Answer:
Rule-based model Learning-based model
A rule-based model follows predefined A learning-based model learns from data
rules and does not adapt/change. and can adapt to changes
Data and Rules are supplied to Rule based Data and Results/answers are supplied to
model gives results/answers Learning based model gives rules(patterns
to understand data)

Q8. An autonomous vehicle is learning to navigate through a city and receives


rewards for safe driving and penalties for violations.
a) What kind of learning is being implemented?
b) How does this method help the AI system learn to perform the task better
over time?
Answer:
a) Reinforcement Learning
b) Reinforcement learning helps the AI agent learn through trial and error. It
gets feedback in the form of rewards or penalties. Over time, the system
optimizes its actions to maximize positive outcomes, making better decisions in
similar situations in the future.

Q9. You are building a model to group customers based on buying habits
without prior labels. Which learning type will you use? Why?
Answer:
Unsupervised Learning approach, because it finds hidden patterns, trends in the
unlabelled data.
Q10. Differentiate between classification and regression models.
Classification Regression
This model deals with discrete outputs This model works on continuous data. (e.g.,
which means the data need not be temperature).
continuous. (e.g., spam or not spam)
Example: Classifying the house to a Example: Predicting the Price of a house.
particular category i.e., Luxury, Midrange, i.e., in numbers
affordable
Example: Predict weather condition to Example: Predicting the temperature in
particular category i.e., Sunny, Cloudy, degree Celsius.
Rainy.

Q11. 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.
a) What type of learning approach is being used here?
b) Explain how this approach helps in deriving insights from the dataset.
Answer:
a) Unsupervised Learning
b) In unsupervised learning, the system works with unlabelled data. It identifies
patterns, similarities, and differences on its own. In this case, the machine
clusters patients based on shared characteristics, which can lead to grouped
treatment plans for patients with similar profiles.

Q12. How can a regression model help predict real estate prices?
Answer: Regression model works on continuous data. (numeric data)
It uses features like size, location, and number of bedrooms to estimate a
house’s price as a continuous output.
Q13. What are the differences between Clustering and Classification
Answer:

Q14. If a machine identifies similar songs based on listening habits, which


model and method is being used? Identify the Learning approach and Model.
Answer:
Unsupervised learning approach.
Clustering model.
Q15. You are asked to represent the decision-making process of going out to a
park based on four conditions: having a jacket, having an umbrella, current
weather, and weather forecast.
a) Explain how a Perceptron model works in this context.
b) Illustrate the concept of weights, bias, and threshold in making the decision.
Answer:

a)
A perceptron takes inputs (example: jacket = 1, umbrella = 0), multiplies them
by weights (importance), adds a bias, and calculates a weighted sum.
b) If the weighted sum exceeds a value >=0 (go out); otherwise, <0 (stay in).
For example:
Output = w1*x1 + w2*x2 + w3*x3 + w4*x4 - b
If Output >=0
→ Go to park
Else
→ Stay at home
Long Answer Questions with Answers

Q1. Explain neural networks. Describe the three layers of neural networks.
Answer:
An Artificial Neural Network (ANN) is a model inspired by the human brain. It consists of layers
of interconnected nodes ("neurons") that process information. 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.

Layer 1: 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.

Layer 2: Processing/Hidden Layer


▪ Each node of these hidden layers has its own machine learning algorithm which it executes on
the data received from the input layer.
▪ Each node Learns patterns, relationships in the input received.
▪ Why “Hidden”? Not directly visible; it processes internal computations.
▪ There can be multiple hidden layers in a neural network that depends upon the complexity of
the function.

Layer 3: Output Layer


▪ Produces final prediction/output.
▪ 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.
Q2. Identify the type of learning (supervised, unsupervised, reinforcement learning) and justify
the following case studies most likely based on?
Case Study 1: A company wants to predict customer churn based on past purchasing
behaviour, demographics, and customer interactions. They have a dataset with labelled
examples of customers who churned and those who did not.
Case Study 2: A social media platform wants to group users based on their interests and
behaviour to recommend relevant content. They have a large dataset of user interactions but no
predefined categories.
Case Study 3: 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.
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.
Answer:
Case Study 1: Predicting customer churn
● Type of Learning: Supervised Learning
● Justification: The company has a labelled dataset with examples of customers who churned
and those who did not. Since the goal is to predict a labelled outcome (churn or not) based on
input features purchasing behaviour, this is a supervised learning scenario.

Case Study 2: Grouping users for content recommendation


● Type of Learning: Unsupervised Learning
● Justification: The goal is to group users based on their behaviour and interests without
predefined categories or labels. This task involves finding patterns or clusters in the data, which
is characteristic of unsupervised learning.

Case Study 3: Autonomous vehicle learning to navigate


● Type of Learning: Reinforcement Learning
● Justification: The autonomous vehicle learns by interacting with the environment, receiving
rewards for good behaviour (reaching the destination safely) and penalties for bad behaviour
(traffic violations). This feedback-based trial-and-error approach is typical of reinforcement
learning.

Case Study 4: Identifying patterns in patient data


● Type of Learning: Unsupervised Learning
● Justification: The healthcare provider aims to find hidden patterns in patient data without
predefined labels or outcomes. This suggests clustering or dimensionality reduction to support
treatment personalization, which falls under unsupervised learning.

Q3. Identify the type of learning (supervised, unsupervised, reinforcement learning) and justify
the following case studies most likely based on?
Case Study 1: An online learning platform wants to predict student performance in upcoming
tests based on their previous quiz scores, course engagement data, and demographic
information. The platform has labelled data indicating whether students passed or failed in past
tests.
Case Study 2: A factory installs sensors on machines to collect data such as temperature,
vibration, and noise levels. They want to detect abnormal machine behaviour that could
indicate a malfunction. They do not have labelled examples of failures but want to monitor
anomalies in real-time.
Case Study 3: A farming organization wants to optimize irrigation by using a drone that learns to
adjust water levels based on crop health, weather conditions, and soil moisture. The drone
receives a reward when crop yield improves and a penalty when overwatering occurs.
Case Study 4: A retail chain wants to segment its customers based on their purchasing habits to
tailor marketing campaigns. They have large amounts of transaction data but no predefined
customer segments.
Answer:
Case Study 1: Predicting student performance
● Type of Learning: Supervised Learning
● Justification: The dataset includes labelled outcomes (e.g., passed or failed), and the goal is
to predict a specific outcome based on input features. This clearly fits the supervised learning
model, where the model is trained on known inputs and outputs to make future predictions.

Case Study 2: Detecting abnormal machine behaviour


● Type of Learning: Unsupervised Learning
● Justification: Since there are no labelled outcomes (i.e., no specific examples of what
constitutes a failure), the goal is to identify anomalies or patterns in sensor data. This is a
typical application of unsupervised learning, especially using techniques like anomaly
detection or clustering.
Case Study 3: A drone learning irrigation optimization
● Type of Learning: Reinforcement Learning
● Justification: The drone receives feedback in the form of rewards (high yield) or penalties
(overwatering) and adjusts its actions accordingly. This trial-and-error learning with a focus on
maximizing cumulative rewards is a characteristic of reinforcement learning.
Case Study 4: Segmenting customers based on purchase behaviour
● Type of Learning: Unsupervised Learning
● Justification: The objective is to group customers based on similarities in purchasing habits
without existing labels or segments. This is a classic clustering problem in unsupervised
learning, often used for customer segmentation in marketing.
Q5. Identify the type of model (classification, regression, clustering, association model) and
justify the following case studies most likely based on?
Case Study 1: 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.

Case Study 2: 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.

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

Case Study 4: 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.

Answer:
Case Study 1: Predicting Loan Default
● Type of Model: Classification
● Justification: The goal is to predict a categorical outcome — whether a
customer will "default" or "non-default" on a loan. Since the outcome is binary (two classes),
this is a classification problem.

Case Study 2: Predicting House Prices


● Type of Model: Regression
● Justification: The objective is to predict a continuous numeric value — the selling price of a
house based on various features such as size, location, number of bedrooms, and bathrooms
This falls under regression model.
Case Study 3: Customer Segmentation
● Type of Model: Clustering
● Justification: The goal is to group customers into segments based on behaviour, without
predefined labels. This is a clustering task, a type of unsupervised learning.
Case Study 4: Product Association Analysis
● Type of Model: Association Model
● Justification: The task is to identify relationships between items purchased together, such as
"customers who buy bread also buy butter." This is best addressed with association rule, making
it an association model.
Q6. Identify the type of model (classification, regression, clustering, association model) and
justify the following case studies most likely based on?
Case Study 1: An investment firm wants to predict the future stock price of a company based on
historical stock data, trading volume, market indicators, and financial reports.
Case Study 2: A social media platform wants to identify communities of users with similar
interests and interactions for better content personalization. They have data on likes,
comments, shares, and followed pages.
Case Study 3: A school wants to determine whether students will pass or fail a standardized
exam based on features such as attendance, homework completion rate, quiz scores, and
participation.
Case Study 4: An agricultural analytics company wants to find combinations of fertilizers and
crop types that are frequently used together across different farms, to optimize supply chain
and product bundling.
Answer:
Case Study 1: Predict the future stock price
● Type of Model: Regression
● Justification: The goal is to predict a continuous numerical value, the future stock price,
based on past and present data. This clearly represents a regression problem.
Case Study 2: Identify communities of users
● Type of Model: Clustering
● Justification: The task is to group users based on patterns in their behaviour without
predefined labels. This is a clustering problem used to uncover structure in user interaction
data.
Case Study 3: Whether students will pass or fail.
● Type of Model: Classification
● Justification: The goal is to predict a categorical outcome (pass or fail), making this a
classification problem.
Case Study 4: Find combinations of fertilizers and crop type
● Type of Model: Association Model
● Justification: The objective is to discover associations or frequent patterns among items
(fertilizers and crops) used together, which is a typical use case for an association model.

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.
Unit-3: Evaluating Models
Importance of Model Evaluation
What is evaluation?
▪ Model evaluation is the process of using different evaluation metrics to understand a machine
learning model’s performance
▪ An AI model gets better with constructive feedback
▪ You build a model, get feedback from metrics, make improvements and continue until you
achieve a desirable accuracy
Evaluation
■ Process of using different evaluation metrics to understand a
machine learning model’s performance.
○ Need of model evaluation
■ Helps you understand its strengths, weaknesses, and suitability for the task at hand.
● Splitting the training set data for Evaluation
○ Train-test split
■ Technique for evaluating the performance of a machine learning algorithm.
■ It can be used for any supervised learning algorithm.
■ The procedure involves taking a dataset and dividing it into two subsets:
● The training dataset
● The testing dataset
■ The train-test procedure is appropriate when there is a sufficiently large dataset available.
Need of Train-test split
■ Because our model will simply remember the whole training set, and will therefore always
predict the correct label for any point in the training set.
■ This is known as overfitting.

▪ Accuracy and Error


○ Accuracy
■ metric that allows you to measure the total number of predictions a model gets right.
○ Error
■ The difference between a model's prediction and the actual outcome. It quantifies how often
the model makes mistakes.
Evaluation metrics for classification
What is Classification?
■ Classification usually refers to a problem where a specific type of class label is the result to
be predicted from the given input field of data
● For example, A classifier model which identifies the fungal infections in paddy crops.

Classification Metrics
Popular metrics used for classification model
▪ Confusion matrix
▪ Classification accuracy
▪ Precision
▪ Recall
Confusion matrix
● The confusion matrix is a tabular presentation of the accuracy of a model with two or more
classes.
● The table presents the actual values on the y-axis and predicted values on the x-axis.
● The numbers in each cell represents the number of predictions made by a machine learning
algorithm that falls into that particular category

True Positive (TP) is the outcome of the model correctly predicting the positive class
True Negative (TN) is the outcome of the model correctly predicting the negative class
False Positive (FP) is the outcome of the model wrongly predicting the negative class as
positive class
False Negative (FN) is the outcome of the model wrongly predicting the positive class as the
negative class
Example:Consider that a model has been developed to test specimens of paddy plants to
diagnose fungal infections. The confusion matrix is shown below.
From the total 43 observations conducted
● 12 observations correctly identified the fungal infection(True positives).
● 04 observations incorrectly identified the fungal infection.(False positives)
● 21 observations correctly identified the absence of fungal infection(True negatives).
● 06 observations failed to identify the fungal infection. (False negatives)

Classification accuracy
● Accuracy from Confusion matrix
● Classification accuracy is the number of correct predictions made as a ratio of all predictions
made.
It is only suitable when there is an equal number of observations in each class, i.e., a
balanced dataset (which is rarely the case), and that all predictions and prediction errors are
equally important. In cases of unbalanced data, we should use other metrics such as Precision,
Recall or F1 Score.

Precision
Precision is the ratio of the total number of correctly classified positive examples and the total
number of predicted positive examples.

When to use?
Used for unbalanced datasets when dealing with the False Positives become important, and the
model needs to reduce the FPs as much as possible.
■ Recall
Measure of our model correctly identifying True Positives
When to use?
used for unbalanced dataset when dealing with the False Negatives become important and the
model needs to reduce the FNs as much as possible.
F1 score
provides a way to combine both precisions and recall into a single measure that captures both
properties where the dataset is unbalanced, and we are unable to decide whether FP is more
important or FN, we should use the F1 score as the suitable metric.

Ethical concerns around model evaluation


○ Bias
■ The evaluation metrics chosen should not result in any kind of bias
○ Transparency
■ Clarity in the explanation of the evaluation of model without any hidden information
○ Accountability
■ Taking the responsibility of the choice of evaluation metrics

Multiple Choice questions with answers

1. A _____ is a table that lists the predicted values of an AI model and the actual/correct
outcome values.
a) Classification Matrix b) Regression Matrix
c) Confusion Matrix d) Deep learning Matrix

2. When both predicted value of the AI model and actual value are positive, it is called
_____________
a) True Positive b) True Negative
c) False Positive d) False Negative

3. Statement1: The output given by the AI model is known as reality.


Statement2:The real scenario is known as Prediction.
(a)Both Statement1 and Statement2 are correct
(b)Both Statement1 and Statement2 are incorrect
(c) Statement1 is correct but Statement2 is incorrect
(d) Statement2 is correct but Statement1 is incorrect

4. Anjali has made a model which predicts the performance of students in the various
examinations in India. She collected the data of students’ performance with respect to state,
age, school and curriculum. Her model works with good accuracy and precision value. Which
of the statements given below is incorrect?
(a) Data gathered with respect to state, age, school and curriculum is known as
Testing Data.
(b) Data given to an AI model to check accuracy and precision is Testing Data.
(c) Training data and testing data are acquired in the Data Acquisition stage.
(d) Training data is always larger as compared to testing data.

5. Amaira made a Forest Fire detector system for which she had collected the dataset and
used all the dataset to train the model. Then, she used the same data to evaluate the model
which resulted in the correct answer all the time but was not able to perform with unknown
dataset. Name the concept.
a)Best fit b) Overfitting c) underfitting d) Regression
6. Which condition of the evaluation does the following diagram indicate?

a) True Positive b) True Negative c) False Positive d) False Negative

7. Which evaluation parameter takes into consideration all the correct


predictions?
a)Precision b) Recall c) Accuracy d) F1 score

8. Statement 1: Overfitting is not recommended for evaluation of a model.


Statement 2: This is because the model will simply remember the whole training set, and will
therefore always predict the correct label for any point in the training set.
(a) Both Statement 1 and Statement 2 are correct.
(b) Both Statement 1 and Statement 2 are incorrect.
(c) Statement 1 is correct but Statement 2 is incorrect.
(d) Statement 2 is correct but Statement 1 is incorrect.

9. It is one of the parameters for evaluating a model's performance which is defined as the
percentage of true positive cases versus all the cases where the prediction is true. Which of the
following evaluation parameters is this?
(a) Precision (b)Recall (c) F1 score (d) accuracy

10. With respect to evaluation, for which of the following does the prediction and reality match?
(a) True positive and False positive
(b) True positive and True negative
(c) False positive and False negative
(d) True positive and False negative

11. Which of these reflect the correct decisions by an AI model?


a) True Positive b) True Negative c) False Positive d) False Negative

12. ____ is the percentage of times the predictions out of all the observations are correct.
a) Precision Rate b) Recallc) Accuracy Rate d) F1 score
13. ____ is the rate at which desirable predictions turn out to be correct.
a) Precision Rate b) Recall c) Accuracy Rate d) F1 score

14. A high F1 score generally suggests:


a) A significant imbalance between precision and recall
b) A good balance between precision and recall
c) A model that only performs well on specific data points
d) The need for more training data

15. When the predicted value of the AI model is positive but actual value is
negative, it is called __________
a) True Positive b) True Negative c) False Positive d) False Negative

16. The goal of evaluating an AI model is to:


a) Maximize error and minimize accuracy
b) Minimize error and maximize accuracy
c) Focus solely on the number of data points used
d) Prioritize the complexity of the model

17. In a binary classification problem, a model predicts 70 instances as positive out of which 50
are actually positive. What is the recall of the model?
a) 50% b) 70% c) 80% d) 100%

18. A teacher's marks prediction system predicts the marks of a student as 75, but the actual
mark obtained by the student is 80. What is the absolute error in the prediction?
a) 5 b) 10 c) 15 d) 20

19. Which of the following ethical concerns is related to taking the responsibility for the choice
of evaluation metrics.
a) Bias b) Accountability c) Transparency d) Translucency

20. How is the relationship between model performance and accuracy described?
a) Inversely proportional b) Not related c) Directly proportional d) Randomly fluctuating
Short Answer questions with answers(2 marks )

Q1. Define Evaluation.


Ans: Evaluation is a process of understanding the reliability of any AI model, based on outputs
by feeding the test dataset into the model and comparing it with actual answers.

Q2. Which two parameters are considered for Evaluation of a model?


Ans: Prediction and Reality are the two parameters considered for Evaluation of a [Link]
“Prediction” is the output which is given by the machine. “Reality” is the real scenario, when the
prediction has been made.

Q3. What is TruePositive?


Ans: True positive is the outcome of the model correctly predicting the positive class . The
predicted value matches the actual value.

Q4. What is TrueNegative?


Ans: True negative is the outcome of the model correctly predicting the negative class. Thee
predicted value matches the actual value.

Q5. What is FalsePositive?


Ans: False positive is the outcome of the model wrongly predicting the negative class as
positive class.

Q6. What is FalseNegative?


Ans: False Negative (FN) is the outcome of the model wrongly predicting the positive class as
the negative class.

Q7. What is meant by Overfitting of Data?


Ans: Overfitting is the scenario where the model remembers the data in the training set , and
always predicts the data in the training set with the correct label, for any point in the training set
and may fail to predict future observations in any unseen data set.
Q8. What is a confusion matrix? What is it used for?
Ans: A Confusion Matrix is a table that is often used to describe the performance of a
classification model on a set of test data for which the true values are known. It stores the
results of comparison between the prediction and reality. From the confusion matrix, we can
calculate parameters like recall, precision, F1 score which are used to evaluate the
performance of an AI model.
Q9. Draw the Confusion matrix with following data
the number of true positive = 100
the number of true negative 47
the number of false positive = 62
the number of false negative = 290

10. Explain the need for a train-test split with an example.


There is a need for a train test split since overfitting may occur. Overfitting is the scenario
where the model remembers the data in the training set , and always predicts the data in the
training set with the correct label, for any point in the training set and may fail to predict future
observations in any unseen data set. So The performance of the model is estimated with
the test data set, the data that is not used to train the model. Example : If there is a model to
classify the images of flowers and vegetables,it will correctly label the images given in the
training data set but may fail to label a new image which is not in the training set.

Long Answer questions(4 marks)

Q1. What is Accuracy? Mention its formula.


Ans: Accuracy is an evaluation metric that allows you to measure the total number of
Predictions a model gets [Link] accuracy of the model and performance of the model is
directly proportional, and hence better the performance of the model, the more accurate are
the predictions.
Correct prediction =TP+TN
Total Predictions=TP+TN+FP+FN
Accuracy =Correct Predictions /Total Predictions
=(TP+TN)/(TP+TN+FP+FN)

Q2. What is Precision? Mention its formula.


Ans: Precision is the ratio of the total number of correctly classified positive examples and the
total number of predicted positive examples.
Precision =Correct Positive Predictions /Total Positive Predictions
=(TP)/(TP+FP)
It is used for unbalanced datasets when dealing with the False Positives becomes important,
and the model needs to reduce the FPs as much as possible.

Q3. What is Recall? Mention its formula.


Ans: Recall is the measure of the model correctly identifying True Positives. It is also called
Sensitivity or True Positive Rate. It is generally used for unbalanced dataset when dealing with
the False Negatives becomes important and the model needs to reduce the FNs as much as
possible.
Recall =Correct Positive Predictions /Total Actual Positive Values
=(TP)/(TP+FN)

Q4. Identify which metric (Precision or Recall) is to be used in the following cases and why?
a. MailSpamming
b. GoldMining
c. ViralOutbreak
Ans:
a) Precision has to be used since False Positives (legitimate emails marked as spam) have to be
reduced as much as possible.
b) Precision has to be used since False Positives((incorrectly identifying a non-gold area as
containing gold) have to be reduced as much as possible.
c) Recall is important in this case since False negatives have to be reduced as much as
possible. False negatives in viral outbreak means failing to identify a person with disease, which
may have life threatening consequences.

Q5. An AI model made the following digital payment usage prediction in a state where
government has recently launched the facility of digital payments:
(i) Identify the total number of wrong predictions made by the model.
(ii) Calculate precision, recall and F1 Score.
Ans:
(i)The total number of wrong predictions made by the model is the sum of false positive and
false negative.= FP+FN
=40+12
= 52
(ii) Precision=TP/(TP+FP)
= 50/(50+40)
= 50/90
=0.55
Recall=TP/(TP+FN)
=50/(50+12)
=50/62
=0.81
F1 Score = 2*Precision*Recall/(Precision+Recall)
=2*0.55*.81/(.55+.81)
=.891/1.36
=0.65
Q6. An Al model has been developed to test specimens of paddy plants to diagnose
fungal,bacterial and viral infections. The model was tested on a data-set of about 630 tests and
the resulting confusion matrix is as follows:
▪ True Positives(TP): 110 tests correctly predicted the disease.
▪ False Positives(FP): 60 tests incorrectly predicted the disease
▪ True Negatives(TN): 410 tests correctly predicted the absence of
disease
▪ False Negatives (FN): 50 tests incorrectly predicted the absence of
disease
Calculate metrics such as accuracy, precision, recall, and F1-score.
Ans:
Accuracy= (TP+TN)/(FP+FN+TP+TN)
= (110+410)/(60+50+110+410)
= 520/630
= 0.825
Accuracy : 82.5%

Precision=TP/(TP+FP)
= 110/(110+60)
= 110/170
= 0.647

Recall=TP/(TP+FN)
=110/(110+50)
=110/160
=0.688
F1 Score = 2*Precision*Recall/(Precision+Recall)
=2*0.647*0.688/(0.647+0.688)
=0.890/1.335
= 0.667

Q7. In a sentiment analysis task, a model correctly predicts 120 positive sentiments out of 200
positive instances. However, it also incorrectly predicts 40 negative sentiments as positive.
What is the F1 score of the model?
Ans:
Given,
TP = 120
FP = 40
Total Actual Positive Values= 200
TP+FN =200
So, FN =200-TP
= 200- 120
=80
Recall = Correct Positive Predictions /Total Actual Positive Values
= (TP)/(TP+FN)
= 120/ 200
= 0.6

Precision = Correct Positive Predictions /Total Positive Predictions


=(TP)/(TP+FP)
=120/ (120+40)
= 120/180
= 0.75
F1 Score = 2*Precision*Recall/(Precision+Recall)
=2*0.75*0.6/(0.75+0.6)
= 2 * 0.45/1.35
=0.66

Test Yourself
Choose the most appropriate answer for each question.
1. In a medical test for a rare disease, out of 1000 people tested, 50 actually have the disease
while 950 do not. The test correctly identifies 40 out of the 50 people with the disease as
positive, but it also wrongly identifies 30 of the healthy individuals as positive. What is the
accuracy of the test?
A) 97%
B) 90%
C) 85%
D) 70%
2. A student solved 90 out of 100 questions correctly in a multiple-choice exam. What is the
error rate of the student's answers?
A) 10%
B) 9%
C) 8%
D) 11%
3. In a spam email detection system, out of 1000 emails received, 300 are spam. The system
correctly
identifies 240 spam emails as spam, but it also marks 60 legitimate emails as spam. What is the
precision of the system?
A) 80%
B) 70%
C) 75%
D) 90%
4. In a binary classification problem, a model predicts 70 instances as positive out of which 50
are actually positive. What is the recall of the model?
A) 50%
B) 70%
C) 80%
D) 100%
5. In a sentiment analysis task, a model correctly predicts 120 positive sentiments out of 200
positive instances. However, it also incorrectly predicts 40 negative sentiments as positive.
What is the F1 score of the model?
A) 0.8
B) 0.75
C) 0.72
D) 0.82
6. A medical diagnostic test is designed to detect a certain disease. Out of 1000 people tested,
100 have the disease, and the test identifies 90 of them correctly. However, it also wrongly
identifies 50 healthy people as having the disease. What is the precision of the test?
A) 90%
B) 80%
C) 70%
D) 60%
7. A teacher's marks prediction system predicts the marks of a student as 75, but the actual
marks obtained by the student are 80. What is the absolute error in the prediction?
A) 5
B) 10
C) 15
D) 20
8. The goal when evaluating an AI model is to:
A) Maximize error and minimize accuracy
B) Minimize error and maximize accuracy
C) Focus solely on the number of data points used
D) Prioritize the complexity of the model
9. A high F1 score generally suggests:
A) A significant imbalance between precision and recall
B) A good balance between precision and recall
C) A model that only performs well on specific data points
D) The need for more training data
10. How is the relationship between model performance and accuracy described?
A) Inversely proportional
B) Not related
C) Directly proportional
D) Randomly fluctuating
Reflection Time:
Q1. What will happen if you deploy an AI model without evaluating it with known test set data?
Q2. Do you think evaluating an AI model is that essential in an AI project cycle?
Q3. Explain train-test split with an example.
Q4. “Understanding both error and accuracy is crucial for effectively evaluating and improving
AI models.” Justify this statement.
Q5. What is classification accuracy? Can it be used all times for evaluating AI models?
Assertion and reasoning-based questions:
Q1. Assertion: Accuracy is an evaluation metric that allows you to measure the total number of
predictions a model gets right.
Reasoning: The accuracy of the model and performance of the model is directly proportional,
and hence better the performance of the model, the more accurate are the predictions.
Choose the correct option:
(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: The sum of the values in a confusion matrix's row represents the total number of
instances for a given actual class.
Reasoning: This enables the calculation of class-specific metrics such as precision and recall,
which are essential for evaluating a model's performance across different classes.
Choose the correct option:
(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
Case study-based questions:
Q1. Identify which metric (Precision or Recall) is to be used in the following cases and why?
a) Email Spam Detection
b) Cancer Diagnosis
c) Legal Cases (Innocent until proven guilty)
d) Fraud Detection
e) Safe Content Filtering (like Kids YouTube)
Q2. Examine the following case studies. Draw the confusion matrix and calculate metrics such
as accuracy, precision, recall, and F1-score for each one of them.
a. Case Study 1:
A spam email detection system is used to classify emails as either spam (1) or not spam (0). Out
of 1000 emails: - True Positives (TP): 150 emails were correctly classified as spam. - False
Positives (FP): 50 emails were incorrectly classified as spam. - True Negatives (TN): 750 emails
were correctly classified as not spam. - False Negatives (FN): 50 emails were incorrectly
classified as not spam. -
b. Case Study 2:
A credit scoring model is used to predict whether an applicant is likely to default on a loan
(1) or not (0). Out of 1000 loan applicants: - True Positives (TP): 90 applicants were correctly
predicted to default on the loan. - False Positives (FP): 40 applicants were incorrectly predicted
to default on the loan. - True Negatives (TN): 820 applicants were correctly predicted not to
default on the loan.
- False Negatives (FN): 50 applicants were incorrectly predicted not to default on the loan.
Calculate metrics such as accuracy, precision, recall, and F1-score.
c. Case Study 3:
A fraud detection system is used to identify fraudulent transactions (1) from legitimate ones
(0). Out of 1000 transactions: - True Positives (TP): 80 transactions were correctly identified as
fraudulent. - False Positives (FP): 30 transactions were incorrectly identified as fraudulent. -
True Negatives (TN): 850 transactions were correctly identified as legitimate. - False Negatives
(FN): 40 transactions were incorrectly identified as legitimate.
d. Case Study 4:
A medical diagnosis system is used to classify patients as having a certain disease (1) or not
having it (0). Out of 1000 patients: - True Positives (TP): 120 patients were correctly diagnosed
with the disease. - False Positives (FP): 20 patients were incorrectly diagnosed with the disease.
- True Negatives (TN): 800 patients were correctly diagnosed as not having the disease. - False
Negatives (FN): 60 patients were incorrectly diagnosed as not having the disease.
e. Case Study 5:
An inventory management system is used to predict whether a product will be out of stock
(1) or not (0) in the next month. Out of 1000 products: - True Positives (TP): 100 products were
correctly predicted to be out of stock. - False Positives (FP): 50 products were incorrectly
predicted to be out of [Link] Negatives (TN): 800
products were correctly predicted not to be out of stock. - True Negatives (TN): 800 products
were correctly predicted not to be out of stock. - - False Negatives (FN): 50 products were
incorrectly predicted not to be out of stock.

You might also like