Unit2 Unit3 Notes
Unit2 Unit3 Notes
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, 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.
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, 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).
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
What is Data?
• In the fruit dataset example, features may be name, color, size, etc.
• 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.
Labeled Data
▪ Data to which some tag/label is attached. ▪ For e.g. Name, type, number, etc.
Unlabeled Data
▪ 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.
Types of AI Models
Generally, AI models can be classified as follows:
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.
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.
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.
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.
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.
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.
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
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.
16. Which learning model would you choose for a stock price prediction system?
a) Clustering b) Classification
c) Regression d) Association
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
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
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
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.
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)
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.
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:
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.
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: 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.
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.
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.
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
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?
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
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
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
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 )
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
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.