UNIT I
Introduction to Machine Learning
End Semester Examination — 70 Marks
Detailed Questions & Answers with Diagrams & Numericals
Subject Machine Learning (ML)
Unit Unit I – Introduction to Machine Learning
Exam Type End Semester Examination
Total Marks 70 Marks
Coverage All 2-Mark topics expanded to exam-level answers
SECTION A — DEFINITIONS & CONCEPTS
Q1. Define Machine Learning. Explain its significance with an example. [7 Marks]
✅ ANSWER:
Definition:
Machine Learning (ML) is a subset of Artificial Intelligence (AI) that enables computer systems to
automatically learn and improve from experience without being explicitly programmed for every task. It
focuses on developing algorithms that can access data, learn from it, and make decisions or predictions.
Formal Definition (Arthur Samuel, 1959):
"Machine Learning is a field of study that gives computers the ability
to learn without being explicitly programmed."
Modern Definition (Tom Mitchell, 1997):
"A computer program is said to learn from Experience E, with respect
to Task T and Performance Measure P, if its performance on T, as
measured by P, improves with experience E."
Key Characteristics of ML:
• Learns patterns from data automatically
• Improves performance over time without manual reprogramming
• Generalizes from training examples to new unseen data
• Handles high-dimensional, complex datasets efficiently
Diagram – ML Workflow:
+------------------+ +------------------+ +------------------+
| Raw Data | --> | ML Algorithm | --> | Trained Model |
| (Training Set) | | (e.g., Decision | | (Mathematical |
| | | Tree, SVM) | | Function) |
+------------------+ +------------------+ +------------------+
|
v
+------------------+ +------------------+ +------------------+
| New Data | --> | Trained Model | --> | Prediction / |
| (Test/Real Data) | | (Inference) | | Decision |
+------------------+ +------------------+ +------------------+
Example – Email Spam Detection:
► Task (T): Classify emails as Spam or Not Spam
► Experience (E): 1 million labelled emails (spam/not-spam)
► Performance (P): Accuracy — % of emails correctly classified
The algorithm learns patterns like keywords ('lottery', 'free', 'click here') from training data and applies this
knowledge to new emails automatically.
Significance of ML:
• Automates complex decision-making processes
• Handles massive volumes of data beyond human capacity
• Powers real-world systems: search engines, recommendation systems, fraud detection
• Continuously improves without manual rule updating
📝 Examiner's Note: Expect students to define ML with Mitchell's formal definition (E, T, P framework).
Award 2 marks for correct definition, 3 marks for diagram/workflow, 2 marks for a valid example.
Q2. Differentiate between Traditional Programming and Machine Learning with a
suitable diagram and example. [7 Marks]
✅ ANSWER:
Traditional Programming:
In traditional programming, the programmer manually writes explicit rules (logic) that a computer follows to
process input data and produce output. The programmer must anticipate every scenario and code it
explicitly.
Input Data + Rules (Code) → Output
Machine Learning:
In ML, the system is given input data and the corresponding correct outputs (answers). The algorithm
automatically discovers the rules/patterns by itself.
Input Data + Output (Answers) → Rules (Model)
Diagram – Traditional vs ML Paradigm:
TRADITIONAL PROGRAMMING MACHINE LEARNING
───────────────────────────────── ─────────────────────────────────
Input Data ─┐ Input Data ─┐
├──► Computer ──► Output ├──► Computer ──► Rules
Rules ───────┘ (Execution) Answers ────┘ (Training) (Model)
Programmer writes rules manually Algorithm discovers rules from data
Detailed Comparison Table:
Parameter Traditional Programming Machine Learning
Approach Programmer defines explicit Algorithm learns rules from data
rules
Input Data + Rules (Code) Data + Expected Output
(Labels)
Output Final result/answer A trained model (rules)
Adaptability Cannot adapt; needs code Adapts automatically with new
change data
Example Tax computation using IF-ELSE Fraud detection from
transactions
Scalability Difficult for complex patterns Scales well with big data
Human Effort High (rules manually coded) Low (model learns
automatically)
Handling Noise Brittle; breaks with exceptions Robust; handles noisy data
Practical Example:
Detecting handwritten digits (0–9):
► Traditional: Programmer must code every pixel-pattern rule for each digit. Extremely complex and
impractical.
► ML Approach: Feed 60,000 labelled images of digits into a Neural Network. Model learns patterns
automatically and achieves 99%+ accuracy.
📝 Examiner's Note: Award 2 marks for correct definitions, 2 marks for the comparison table (min 4
differences), 2 marks for diagram, 1 mark for example.
Q3. List and explain the types of Machine Learning with diagrams and real-world
applications. [7 Marks]
✅ ANSWER:
Machine Learning is broadly classified into three major types:
1. Supervised Learning
The algorithm is trained on labelled data (input-output pairs). It learns to map inputs to outputs.
f(X) → Y where X = input features, Y = known labels
► Examples: Email spam detection, House price prediction, Image classification
► Algorithms: Linear Regression, Decision Tree, SVM, KNN, Neural Networks
2. Unsupervised Learning
The algorithm is given unlabelled data. It discovers hidden patterns, structures, or groupings on its own.
f(X) → Clusters / Patterns (no labels Y provided)
► Examples: Customer segmentation, Market basket analysis, Anomaly detection
► Algorithms: K-Means Clustering, DBSCAN, PCA, Autoencoders
3. Reinforcement Learning
An Agent interacts with an Environment, takes Actions, and receives Rewards or Penalties. It learns to
maximize cumulative reward over time.
Agent → Action → Environment → Reward/Penalty → Policy Update
► Examples: Game playing (Chess, AlphaGo), Robot navigation, Self-driving cars
► Algorithms: Q-Learning, Deep Q-Network (DQN), Policy Gradient
Diagram – Types of ML:
MACHINE LEARNING
|
┌───────────────────┼───────────────────┐
| | |
SUPERVISED UNSUPERVISED REINFORCEMENT
LEARNING LEARNING LEARNING
| | |
Labelled Data No Labels Agent + Reward
| | |
Classification Clustering Policy Learning
Regression Dim. Reduction Q-Learning
| | |
Spam Filter Customer Segment Self-Driving Car
Summary Table:
Type Data Required Goal Example
Supervised Labelled (X, Y) Learn mapping X→Y Spam Detection
Unsupervised Unlabelled (X only) Find hidden patterns Customer Segments
Reinforcement Reward signals Maximize reward Chess AI / Robots
📝 Examiner's Note: Students must name all 3 types (1 mark each), explain each with definition and example
(1 mark each), and draw a clear diagram (2 marks).
SECTION B — SUPERVISED & UNSUPERVISED LEARNING
Q4. Define Supervised Learning. Explain Classification and Regression with examples
and diagrams. [10 Marks]
✅ ANSWER:
Definition of Supervised Learning:
Supervised Learning is a type of ML where the model is trained on a labelled dataset — each training
example has an input (features X) and a corresponding correct output (label Y). The model learns to
predict Y for new unseen X.
Given: Training Set D = {(x₁,y₁), (x₂,y₂), ..., (xₙ,yₙ)}
Goal: Learn function f such that f(xᵢ) ≈ yᵢ for all i
Predict: ŷ = f(x_new) for unseen input x_new
Types of Supervised Learning:
• Classification — Predicts a discrete class label (e.g., Yes/No, Cat/Dog)
• Regression — Predicts a continuous numerical value (e.g., price, temperature)
A) Classification:
Classification is a supervised learning task where the goal is to predict which category (class) a new data
point belongs to.
Example — Medical Diagnosis:
► Input Features: Age, Blood Pressure, Cholesterol level, Blood Sugar
► Output Labels: Diabetic (1) or Non-Diabetic (0)
Classification Diagram – Decision Boundary:
Feature Space
● = Class A (Diabetic)
BP ↑ ○ = Class B (Non-Diabetic)
| ● ● ● ●
| ● ● ● Decision
| ● ● ● ───────────── Boundary
| ○ ○ ○
| ○ ○ ○
| ○ ○
└─────────────────────────── Age →
The model learns the boundary
that separates the two classes
Common Classification Algorithms:
Algorithm How it works Use Case
Logistic Regression Finds a linear decision boundary Binary classification
Decision Tree Splits data on feature thresholds Medical diagnosis
K-Nearest Neighbor Assigns class based on k neighbors Image recognition
(KNN)
Support Vector Machine Maximizes margin between classes Text classification
Random Forest Ensemble of decision trees Fraud detection
B) Regression:
Regression is a supervised learning task where the goal is to predict a continuous numerical output (not a
category) based on input features.
Example — House Price Prediction:
► Input Features (X): Area (sq ft), No. of Bedrooms, Location, Age of house
► Output (Y): Price in ₹ Lakhs (a continuous number)
Simple Linear Regression Equation:
ŷ = β₀ + β₁x
Where: ŷ = predicted price, x = area, β₀ = intercept, β₁ = slope
Numerical Example:
Given data:
House Area (sq ft) Price (₹ Lakhs)
H1 1000 50
H2 1500 70
H3 2000 90
H4 2500 110
From the data, every 500 sq ft increase → ₹20 Lakhs increase.
β₁ = ΔY/ΔX = 20/500 = 0.04
β₀ = 50 - 0.04 × 1000 = 50 - 40 = 10
Regression Equation: Price = 10 + 0.04 × Area
Prediction: For Area = 1800 sq ft → Price = 10 + 0.04×1800 = ₹82 Lakhs
Regression Diagram (Line of Best Fit):
Price ↑ (₹ Lakhs)
110 | ● /
90 | ● / ← Best Fit Line
70 | ● /
50 | ● /
30 | /
10 | /
└─────────────────────────── Area (sq ft) →
1000 1500 2000 2500
Key Difference: Classification vs Regression
Aspect Classification Regression
Output Type Discrete (class labels) Continuous (real number)
Example Output Spam / Not Spam ₹82 Lakhs
Evaluation Metric Accuracy, Precision, Recall MSE, RMSE, R² Score
Algorithms Logistic Reg, SVM, KNN Linear Reg, Polynomial Reg
📝 Examiner's Note: 10-mark question: 2 marks for supervised learning definition with formula, 3 marks for
classification (definition + diagram + example), 3 marks for regression (definition + numerical + diagram), 2
marks for comparison table.
Q5. Define Unsupervised Learning. Explain Clustering with K-Means algorithm,
numerical example, and diagram. [10 Marks]
✅ ANSWER:
Definition of Unsupervised Learning:
Unsupervised Learning is a type of ML where the training data has NO labels. The algorithm discovers
hidden patterns, structures, groupings, or relationships within the data on its own without any guidance.
Given: Dataset D = {x₁, x₂, ..., xₙ} (NO labels Y)
Goal: Find natural structure/groupings in X
Main Tasks in Unsupervised Learning:
• Clustering — Group similar data points together (e.g., customer segments)
• Dimensionality Reduction — Reduce features while preserving info (e.g., PCA)
• Association Rule Mining — Discover item relationships (e.g., Market Basket Analysis)
What is Clustering?
Clustering is an unsupervised learning technique that groups a set of data points into clusters such that:
• Points within the same cluster are highly similar to each other (intra-cluster similarity is high)
• Points in different clusters are dissimilar from each other (inter-cluster similarity is low)
► Application: Customer segmentation — group customers by purchasing behavior for targeted
marketing
K-Means Clustering Algorithm:
K-Means is the most popular clustering algorithm. It partitions n data points into K clusters by minimizing
the within-cluster sum of squared distances (WCSS).
Objective Function (Cost Function):
Minimize J = Σᵢ Σₓ∈Cᵢ ||x - μᵢ||²
Where: μᵢ = centroid of cluster i, ||x - μᵢ|| = Euclidean distance
K-Means Algorithm Steps:
• Step 1: Choose K (number of clusters). Randomly initialize K centroids.
• Step 2 (Assignment): Assign each data point to the nearest centroid.
C(x) = arg min ||x - μₖ||² for k = 1 to K
• Step 3 (Update): Recalculate centroids as the mean of all points in each cluster.
μₖ = (1/|Cₖ|) × Σ x for all x in cluster Cₖ
• Step 4: Repeat Steps 2 & 3 until centroids stop changing (convergence).
Numerical Example (K=2):
Data points (1D for simplicity): {2, 4, 5, 8, 9, 10}
Initial centroids: μ₁ = 2, μ₂ = 8
Iteration 1 — Assignment:
Point (x) Distance to μ₁=2 Distance to μ₂=8 Assigned Cluster
2 |2-2|=0 |2-8|=6 C1
4 |4-2|=2 |4-8|=4 C1
5 |5-2|=3 |5-8|=3 C1 (tie→C1)
Point (x) Distance to μ₁=2 Distance to μ₂=8 Assigned Cluster
8 |8-2|=6 |8-8|=0 C2
9 |9-2|=7 |9-8|=1 C2
10 |10-2|=8 |10-8|=2 C2
Iteration 1 — Update Centroids:
C1 = {2, 4, 5} → μ₁ = (2+4+5)/3 = 11/3 = 3.67
C2 = {8, 9, 10} → μ₂ = (8+9+10)/3 = 27/3 = 9.0
Iteration 2 — Assignment (μ₁=3.67, μ₂=9.0):
Point Dist to μ₁=3.67 Dist to μ₂=9.0 Cluster
2 1.67 7.0 C1
4 0.33 5.0 C1
5 1.33 4.0 C1
8 4.33 1.0 C2
9 5.33 0.0 C2
10 6.33 1.0 C2
Centroids unchanged → Algorithm converges!
Final Result: C1 = {2, 4, 5}, C2 = {8, 9, 10}
K-Means Diagram:
Before Clustering: After K-Means (K=2):
● ● ● ● ● ● ■ ■ ■ ★ ★ ★
2 4 5 8 9 10 2 4 5 8 9 10
All mixed, no labels ■ = Cluster 1 (Centroid: 3.67)
★ = Cluster 2 (Centroid: 9.0)
📝 Examiner's Note: Award 2 marks for definitions, 3 marks for K-Means steps with formulas, 3 marks for
numerical example with calculation, 2 marks for diagram.
SECTION C — REINFORCEMENT LEARNING
Q6. Explain Reinforcement Learning in detail. Define Agent, Environment, Reward, and
Policy with a diagram. [10 Marks]
✅ ANSWER:
Definition of Reinforcement Learning (RL):
Reinforcement Learning is a type of ML where an intelligent Agent learns to make decisions by interacting
with an Environment. The agent receives Rewards for correct actions and Penalties for incorrect ones,
and its goal is to maximize the total cumulative reward over time.
RL is inspired by behavioral psychology — the concept of learning through trial and error with
positive/negative feedback.
Core Components of RL:
1. Agent:
The learner or decision-maker that interacts with the environment. It observes the current state, selects an
action, and receives a reward.
► Example: A robot navigating a maze, an AI playing Chess, a self-driving car
2. Environment:
Everything the agent interacts with. The environment responds to the agent's actions by transitioning to a
new state and providing a reward.
► Example: The maze/chessboard/road that the agent operates in
3. State (S):
A representation of the current situation of the agent in the environment. The agent observes the state to
decide its next action.
State Sₜ = snapshot of environment at time step t
4. Action (A):
All possible moves/decisions the agent can take in a given state.
Action Set A = {a₁, a₂, ..., aₙ} (e.g., move Up/Down/Left/Right)
5. Reward (R):
A numerical feedback signal given to the agent after each action. Positive reward = good action; Negative
reward (penalty) = bad action.
Rₜ₊₁ = reward received after taking action aₜ in state Sₜ
6. Policy (π):
The strategy the agent uses to choose actions based on the current state. It maps states to actions.
Policy π: S → A (π(s) = action to take in state s)
Goal: Find optimal policy π* that maximizes: G = Σ γᵗ Rₜ
Where γ = discount factor (0 < γ ≤ 1), Rₜ = reward at step t
RL Interaction Loop Diagram:
┌────────────────────┐
│ ENVIRONMENT │
│ │
┌──────────────────┐ │ State: Sₜ₊₁ │
│ AGENT │◄─┤ Reward: Rₜ₊₁ │
│ │ │ │
│ Policy: π(Sₜ) │ │ (e.g., Maze, │
│ Observe Sₜ, Rₜ │ │ Chess Board, │
│ │──► Road for Car) │
└──────────────────┘ │ Action: Aₜ │
└────────────────────┘
Agent takes Action → Environment responds → New State + Reward
Agent updates policy → Repeat until task complete
Numerical Example — Maze Navigation:
Grid World (3×3 maze). Agent starts at cell (1,1). Goal: reach (3,3). Rewards:
• Reaching goal: +10
• Each step: -1 (to encourage shortest path)
• Hitting wall: -5
┌─────┬─────┬─────┐
│Start│ · │ · │ Optimal Policy (π*) found by Q-Learning:
│(1,1)│ │ │
├─────┼─────┼─────┤ (1,1)→Right→(1,2)→Right→(1,3)
│ · │WALL │ · │ →Down→(2,3)→Down→(3,3)[Goal]
│ │ XXX │ │
├─────┼─────┼─────┤ Total Reward = -1 + -1 + -1 + -1 + 10 = +6
│ · │ · │GOAL │ (Better than hitting wall path)
│ │ │(3,3)│
└─────┴─────┴─────┘
Q-Learning Update Rule:
Q(s,a) ← Q(s,a) + α[r + γ·max Q(s',a') - Q(s,a)]
Where α = learning rate, γ = discount factor, Q(s,a) = quality of action a in state s
Comparison: Supervised vs Reinforcement Learning:
Aspect Supervised Learning Reinforcement Learning
Feedback Correct labels provided Reward/penalty after action
Data Labelled dataset Trial and error interaction
Goal Minimize prediction error Maximize cumulative reward
Example Image classification Game playing AI (AlphaGo)
📝 Examiner's Note: Award 2 marks for RL definition, 1 mark each for Agent/Environment/Reward/Policy (4
marks), 2 marks for diagram, 2 marks for numerical/example.
SECTION D — APPLICATIONS & PYTHON LIBRARIES
Q7. Explain any four major applications of Machine Learning with real-world examples
and diagrams. [7 Marks]
✅ ANSWER:
1. Healthcare — Disease Diagnosis & Drug Discovery:
ML models analyze patient data (symptoms, lab reports, medical images) to diagnose diseases faster and
more accurately than manual diagnosis.
► Example: Google's DeepMind AI detects eye diseases from retinal scans with 94% accuracy —
comparable to expert doctors
► Algorithm Used: Convolutional Neural Networks (CNN) for medical imaging
► Impact: Early cancer detection, personalized treatment plans, drug discovery (COVID-19 vaccine
development accelerated using ML)
2. E-Commerce — Recommendation Systems:
ML analyzes user behavior, purchase history, and ratings to recommend relevant products, movies, or
songs, significantly improving user engagement and sales.
► Example: Amazon recommends 'Customers who bought X also bought Y'; Netflix recommends shows
based on watch history
► Algorithm: Collaborative Filtering, Matrix Factorization, Deep Learning
► Impact: Amazon attributes 35% of its revenue to ML-powered recommendations
3. Finance — Fraud Detection:
ML models analyze millions of credit card transactions in real-time to detect anomalous or fraudulent
patterns.
► Example: Visa and Mastercard use ML to flag suspicious transactions — if your card is used in
Mumbai and then New York within minutes, ML triggers an alert
► Algorithm: Isolation Forest, Autoencoders, Random Forest (anomaly detection)
► Impact: Reduces credit card fraud losses by billions of dollars annually
4. Natural Language Processing (NLP) — Chatbots & Translation:
ML enables computers to understand, generate, and translate human language, enabling smart assistants
and real-time translation.
► Example: Google Translate converts text between 100+ languages; ChatGPT answers complex
questions in natural language
► Algorithm: Transformer models (BERT, GPT), Recurrent Neural Networks (RNN)
► Impact: Enables customer service automation, real-time language translation for 7+ billion users
ML Applications Summary Diagram:
┌─────────────────────────┐
│ MACHINE LEARNING │
│ APPLICATIONS │
└─────────────────────────┘
│
┌─────────────┬───────────┼────────────┬─────────────┐
│ │ │ │ │
Healthcare Finance E-Commerce NLP/AI Transport
Disease Fraud Product Chatbots Self-Driving
Diagnosis Detection Recommend. Translation Cars
│ │ │ │ │
CNN Model Random Collab. Transformer Deep RL
Forest Filtering Models (Tesla)
📝 Examiner's Note: Award 1.5 marks per application (up to 4 applications = 6 marks) + 1 mark for the
summary diagram. Students must mention the algorithm/technique used for each.
Q8. Explain NumPy, Pandas, and Scikit-learn as Python libraries for ML. Include code
examples and their key features. [12 Marks]
✅ ANSWER:
A) NumPy — Numerical Python:
NumPy (Numerical Python) is a fundamental Python library for scientific computing. It provides powerful
N-dimensional array objects and mathematical functions that are the backbone of ML computation.
Key Features of NumPy:
• Provides the ndarray — fast, memory-efficient multi-dimensional array
• Supports vectorized operations (no explicit loops needed)
• Contains linear algebra, Fourier transforms, random number functions
• 100x faster than Python lists for numerical operations
• Foundation for Pandas, Scikit-learn, TensorFlow, PyTorch
NumPy Code Example:
import numpy as np
# Create array
a = [Link]([1, 2, 3, 4, 5])
b = [Link]([10, 20, 30, 40, 50])
# Vectorized arithmetic
print(a + b) # [11, 22, 33, 44, 55]
print(a * 2) # [2, 4, 6, 8, 10]
print([Link](a)) # 3.0
print([Link](a)) # 1.4142...
# 2D Matrix
M = [Link]([[1,2],[3,4]])
print([Link](M)) # Matrix inverse
print([Link](M, M)) # Matrix multiplication
NumPy Numerical Example — Euclidean Distance:
Distance = √[(x₂-x₁)² + (y₂-y₁)²]
p1 = [Link]([2, 3])
p2 = [Link]([5, 7])
distance = [Link]([Link]((p2 - p1)**2))
# = √[(5-2)² + (7-3)²] = √[9+16] = √25 = 5.0
print(distance) # Output: 5.0
B) Pandas — Panel Data Analysis:
Pandas is a Python library built on top of NumPy that provides flexible, high-performance data structures
(Series and DataFrame) for data manipulation, analysis, and preprocessing — essential steps before ML
modeling.
Key Data Structures:
• Series — 1D labelled array (like a column in Excel)
• DataFrame — 2D labelled table with rows and columns (like an Excel spreadsheet)
Key Features of Pandas:
• Load data from CSV, Excel, SQL, JSON, APIs with a single line
• Handle missing values (NaN) — fill, drop, interpolate
• Filter, sort, group, merge, and reshape data efficiently
• Descriptive statistics (mean, std, min, max, quartiles)
• Data visualization integration with Matplotlib
Pandas Code Example:
import pandas as pd
# Load dataset
df = pd.read_csv('[Link]')
# View data
print([Link]()) # First 5 rows
print([Link]) # (rows, columns)
print([Link]()) # Stats summary
print([Link]().sum()) # Count missing values
# Filter + Group
topStudents = df[df['marks'] > 80]
avg = [Link]('branch')['marks'].mean()
# Handle Missing Values
df['age'].fillna(df['age'].mean(), inplace=True)
[Link](inplace=True)
C) Scikit-learn (sklearn) — ML Library:
Scikit-learn is the most widely used Python library for Machine Learning. It provides ready-to-use
implementations of hundreds of ML algorithms with a consistent, easy-to-use API built on NumPy and
Pandas.
Key Features of Scikit-learn:
• Complete ML pipeline — Preprocessing → Training → Evaluation → Tuning
• Algorithms: Linear/Logistic Regression, SVM, KNN, Random Forest, K-Means, PCA, etc.
• Model evaluation metrics: accuracy, precision, recall, F1-score, confusion matrix
• Cross-validation, hyperparameter tuning (GridSearchCV)
• Data preprocessing: StandardScaler, LabelEncoder, OneHotEncoder, train_test_split
Scikit-learn Code Example — Full ML Pipeline:
from [Link] import load_iris
from sklearn.model_selection import train_test_split
from [Link] import StandardScaler
from [Link] import SVC
from [Link] import accuracy_score, classification_report
# Step 1: Load Data
data = load_iris()
X, y = [Link], [Link] # Features & Labels
# Step 2: Split Data
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42)
# 80% training (120 samples), 20% testing (30 samples)
# Step 3: Preprocess
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = [Link](X_test)
# Step 4: Train Model
model = SVC(kernel='rbf', C=1.0)
[Link](X_train, y_train)
# Step 5: Evaluate
y_pred = [Link](X_test)
print('Accuracy:', accuracy_score(y_test, y_pred))
# Output: Accuracy: 0.9667 (96.67%)
print(classification_report(y_test, y_pred))
Library Comparison Table:
Library Primary Use Key Data Structure ML Role
NumPy Numerical Computing ndarray (N-D array) Mathematical operations,
matrix algebra
Pandas Data Analysis & Prep DataFrame & Series Load, clean, explore,
transform data
Scikit-learn ML Algorithm Library NumPy arrays / Train, evaluate, tune ML
DataFrames models
Typical ML Workflow using all 3 Libraries:
Raw Data (CSV/DB)
│
▼
PANDAS: Load → Clean → Explore → Feature Engineer
│
▼
NUMPY: Matrix operations, distance calculations, transformations
│
▼
SCIKIT-LEARN: Split → Scale → Train → Predict → Evaluate
│
▼
Trained Model → Deployed for Predictions
📝 Examiner's Note: 12-mark question: Award 4 marks each for NumPy, Pandas, and Scikit-learn. Each
must include: definition (1 mark), ≥3 key features (1 mark), code example (1 mark), purpose/role in ML
pipeline (1 mark).
SECTION E — NUMERICAL PROBLEMS & QUICK ANSWERS
Q9. Calculate Mean Squared Error (MSE) and Root Mean Squared Error (RMSE) for the
following regression predictions. [5 Marks]
✅ ANSWER:
Given Data:
Sample Actual Value Predicted Value Error (y - ŷ) (y - ŷ)²
(y) (ŷ)
1 50 48 2 4
2 70 73 -3 9
3 90 88 2 4
4 110 115 -5 25
5 130 128 2 4
Calculation:
MSE = (1/n) × Σ(yᵢ - ŷᵢ)²
MSE = (1/5) × (4 + 9 + 4 + 25 + 4)
MSE = (1/5) × 46 = 9.2
RMSE = √MSE = √9.2 ≈ 3.033
Interpretation: On average, the model's predictions deviate from actual values by approximately ₹3.033
Lakhs.
📝 Examiner's Note: Award 1 mark for correct MSE formula, 2 marks for correct error calculations, 1 mark for
MSE = 9.2, 1 mark for RMSE = 3.033.
Q10. Answer the following 2-mark questions precisely as expected in an end-semester
exam. [5 Marks]
✅ ANSWER:
(a) What is Regression?
Regression is a supervised learning task that predicts a continuous numerical output based on input
features. Unlike classification (discrete classes), regression outputs real-valued numbers.
Example: f(house_area) = ₹82 Lakhs price
► Common Algorithms: Linear Regression, Ridge, Lasso, Polynomial Regression
(b) What is Clustering?
Clustering is an unsupervised learning technique that groups unlabelled data points into clusters based on
similarity — points in the same cluster are similar, points in different clusters are dissimilar.
► Key Property: High intra-cluster similarity + Low inter-cluster similarity
► Example: K-Means groups customers into segments: High-Value, Medium, Bargain Hunters
(c) What is an Agent in Reinforcement Learning?
An Agent is the learner/decision-maker in an RL system that observes the environment's current state,
selects an action using its policy, and receives a reward. It updates its policy to maximize cumulative
future rewards.
► Examples: Robot arm, Chess AI (AlphaZero), Autonomous vehicle (Tesla Autopilot)
(d) What is NumPy?
NumPy (Numerical Python) is a Python library that provides fast, memory-efficient multi-dimensional
arrays (ndarray) and mathematical functions. It is the foundation of scientific computing and ML in Python,
enabling vectorized operations ~100x faster than native Python loops.
(e) What is Pandas used for?
Pandas is a Python data analysis library used for loading, cleaning, exploring, and transforming structured
data before ML modeling. It provides two key data structures — Series (1D) and DataFrame (2D) — and
supports data from CSV, Excel, SQL, and JSON sources.
EXAM MARKS DISTRIBUTION — 70 MARKS
[Link] Topic Type Marks
.
Q1 Define Machine Learning with diagram & Long Answer 7
example
Q2 Traditional Programming vs ML (Table + Long Answer 7
Diagram)
Q3 Types of ML with diagram & applications Long Answer 7
Q4 Supervised Learning: Classification + Long Answer 10
Regression + Numericals
Q5 Unsupervised Learning: Clustering + K-Means Long Answer 10
Numerical
Q6 Reinforcement Learning: Agent, Env, Reward, Long Answer 10
Policy + Diagram
Q7 Applications of ML (any 4 with examples) Long Answer 7
Q8 NumPy, Pandas, Scikit-learn with code Long Answer 12
examples
Q9 Numerical: MSE and RMSE calculation Numerical 5
Q10 Short notes: Regression, Clustering, Agent, Short Answer 5
NumPy, Pandas
TOTAL 70
Examiner's Checklist for Evaluation:
• Definitions must include formal/technical language — not just casual explanations
• Every definition should be accompanied by a relevant formula where applicable
• Diagrams must be labelled clearly — all components named
• Numerical examples must show step-by-step working — not just the final answer
• Code examples must be syntactically correct Python
• Comparison tables must have at least 4 meaningful differences/attributes
• Examples must be from real-world applications (not hypothetical)
📝 Examiner's Note: Students scoring full marks should demonstrate conceptual clarity, proper use of
technical terminology, correct numericals with intermediate steps, and well-labelled diagrams. Penalize
vague or incomplete definitions.