ARTIFICIAL INTELLIGENCE
PART B UNIT 2
AI MODELLING
[Link] between Rule-based and Learning-based AI Models
Rule-based AI Learning-based AI
● Follows manually coded ● Learns patterns from data
IF-THEN rules
● Cannot adapt to new ● Continuously improves with
data unless rules are new data
changed manually
● Very little or no data ● Requires large amounts of
required data for training
● Chatbots with fixed ● Image recognition, speech-
answers, form validation to-text, recommendation
systems
● Rigid — only follows ● Flexible — can generalize and
what it’s told adapt
● Knowledge encoded by ● Models trained on historical
experts datasets
Q2. What is supervised, unsupervised and reinforcement learning?
Explain with examples.
Supervised Learning:
● The model is trained on a dataset that includes both input and
the correct output (label).
● Goal: Learn a function that maps inputs to known outputs.
● Example: Predicting house prices based on features like size,
location, etc.
Unsupervised Learning:
● No labels are provided; the system finds patterns or groupings
on its own.
● Goal: Discover hidden structure or relationships in data.
● Example: Grouping customers based on purchase behavior.
Reinforcement Learning:
● The model (agent) interacts with an environment and learns by
receiving rewards or penalties.
● Goal: Maximize cumulative reward.
● Example: A robot learning to walk or a game-playing AI like
AlphaGo.
Q3. Explain neural networks. Also give the function of its three
layers.
A neural network is a computer model inspired by how the human
brain processes information. It is made up of layers of neurons (also
called nodes) that help the system learn complex patterns.
Three Layers of Neural Network:
1. Input Layer:
● Takes the raw data (e.g., pixels in an image, or values like
height/weight).
● Passes it to the next layer.
2. Hidden Layer(s):
● Performs computations using weighted connections and
activation functions.
● Extracts features and finds patterns.
● There can be one or many hidden layers.
2. Output Layer:
● Produces the final result (prediction).
● For classification, it may output probabilities for each
class.
● For regression, it may output a number.
Q4. Differentiate between classification and regression model.
Feature Classification Regression
● Discrete class ● Continuous value (like
Output
(like A or B) a number)
Type of
● Predict category ● Predict value
Problem
● Predicting if
Example ● Predicting house price
email is spam
Model Goal ● Assign to a class ● Estimate a value
Classification Example: Predict if a tumor is "benign" or "malignant"
Regression Example: Predict the salary of an employee based on
experience
Q5. Identify the type of learning (supervised, unsupervised,
reinforcement) for each case:
Case Study Description Learning Type
a) Predict Uses labeled examples Supervised
customer churn (churn / not churn) Learning
b) Recommend No labels, groups users Unsupervised
content to users based on behavior Learning
Learns through trial and Reinforcement
c) Self-driving car
reward Learning
d) Personalized Finds patterns without Unsupervised
treatments labeled treatment labels Learning
e) Detect
Uses labeled examples of Supervised
anomalies in
normal/anomalous Learning
machines
Q6. Identify the model type used in each case:
Case Study Description Model Type
a) Loan default Predict category (default /
Classification
prediction not default)
b) Predict house
Predict a number (price) Regression
price
c) Segment Group similar data (no
Clustering
customers labels)
d) Products bought Association
Identify item combinations
together Model
Q7. Healthcare model types:
Model
Task Description
Type
a) Predict short or long Choose between two Classificati
stay categories on
Predict a continuous
b) Predict number of days Regression
number
c) Segment patients for
Grouping without labels Clustering
treatment
d) Identify treatment Discover item
Association
patterns relationships
Q8. Convert to perceptron:
a) Work-from-home Decision:
Context: Manager deciding WFH approval.
Factors as binary inputs (1 = Yes, 0 = No)
Inp Example
Question
ut Weight
x1 Employee performs well remotely? +3
x2 Team collaboration needed? –2
x3 Policy supports WFH? +2
Beneficial to company and
x4 +3
employee?
Perceptron Output
Score=3x1−2x2+2x3+3x4
Then we compare this score with 3:
● If the score is 3 or more, the answer is "Approve" (output 1)
● If the score is less than 3, the answer is "Deny" (output 0)
3x1 - 2x2 + 2x3 + 3x4 ≥ 3
3x1−2x2+2x3+3x4 ≥ 3,
then Approve (1); else Deny (0)
Suppose:
● x1=1 (employee performs well)
● x2=0 (collaboration not needed)
● x3=1 (policy supports WFH)
● x4=0(not beneficial to both)
Now calculate score:
3(1)−2(0)+2(1)+3(0)=3+0+2+0=5
Is 5 ≥ 3? ✅ Yes → Output = 1 (Approve WFH)
[Link] the Model: Classification or Regression
🔹 Case 1: Predicting whether a customer is eligible for a bank loan
or not
✔ Model Type: Classification
✔ Reason: This is a binary classification problem because the output
is discrete — either "Yes" (eligible) or "No" (not eligible).
✔ Use Case: Helpful in banking to filter eligible applicants.
🔹 Case 2: Predicting weather for the next 24 hours
✔ Model Type: Regression
✔ Reason: This is a regression problem because the output
(temperature, humidity, etc.) is continuous and varies over time.
✔ Use Case: Useful in meteorology and climate monitoring.
[Link] Yourself – Identify the Model: Supervised or
Unsupervised?
🔹 Case 1: Social Media friend identification using tagged photos
Q: Which model is used – Supervised or Unsupervised?
Answer: ✅ Supervised Learning
Explanation: Tagged photos act as labeled data, helping the system
recognize the person based on previous tags.
🔹 Case 2: OTT platform recommending movies/songs based on
watch history
Q: Which model is used – Supervised or Unsupervised?
Answer: ✅ Unsupervised Learning
Explanation: The system groups users or content based on similar
preferences without labeled outcomes.
🔹 Case 3: Analyzing bank data for fraud detection when fraud is not
predefined
Q: Which model is used – Supervised or Unsupervised?
Answer: ✅ Unsupervised Learning
Explanation: Since fraud labels are not available, the system looks
for anomalies or unusual patterns, making it an unsupervised model.