NATIONAL INSTITUTE OF TECHNOLOGY ROURKELA
Department of Electrical Engineering
I NTRODUCTION TO AI AND ML (CS2011)
Session: 2025–26 (Autumn)
B.Tech. 3rd Semester
Assignment 7: Classification and Clustering
AL INSTITUTE OF TECHNOLOGY
1. A logistic regression model predicts whether a loan applicant will default (y = 1) or not (y = 0) using two
ROURKELA
features: annual income (x ) and credit score (x ). Given θ̄ = [0.2 0.4 − 0.5] and learning rate η = 0.1,
1
⊤
2
update θ̄ for one iteration using gradient descent technique.
Example
x1
x2
Class
1
3.0
5.0
0
2
6.0
2.5
1
3
4.5
4.0
0
2. A logistic regression classifier is trained to detect spam emails based on two features: frequency of
promotional words (x1 ) and total number of links (x2 ). Given θ̄ = [−2 0.3 0.5]⊤ and learning rate η = 0.05,
compute the predicted probability for each input pattern and update θ̄ for one iteration using gradient
descent technique.
Example
x1
x2
Spam (1/0)
1
5
3
1
2
1
0
0
3
4
2
1
4
2
1
0
3. The training data for a binary classifier are given below. Compute the decision boundary equation for
logistic regression and sketch it.
Example
x1
x2
Class
1
1.0
2.0
0
2
2.0
3.0
0
3
3.0
5.0
1
4
4.0
6.0
1
4. For a logistic regression classifier, the decision boundary is given by θ0 + θ1 x1 + θ2 x2 = 0. If θ0 = −3,
θ1 = 1, and θ2 = 2, determine whether the point (x1 , x2 ) = (1, 1) belongs to class 0 or 1. Compute the
probability and justify the decision.
5. A logistic regression model is trained to predict whether a tumor is malignant (y = 1) or benign (y = 0)
based on three features: tumor size (x1 ), texture score (x2 ), and smoothness index (x3 ). Given θ̄ =
[−0.1 0.05 0.03 − 0.02]⊤ , and learning rate η = 0.01, compute the predicted output for each input pattern
and update θ̄ for one epoch using gradient descent.
© Ananyo Sengupta
CS2011
Assignment 7: Classification and Clustering
Example
x1
x2
x3
Class
1
1.5
3.0
0.8
0
2
2.1
2.9
1.5
0
3
3.5
4.2
1.8
1
4
4.0
3.9
2.2
1
Page 2 of 3
6. Given the logistic regression hypothesis
1
1 + e−θ̄⊤ x̄
hθ̄ (x̄) =
derive expressions for the gradient of the loss function with respect to θ̄. Use binary cross-entropy loss.
7. A KNN classifier with k = 3 is used to classify a new sample (x1 , x2 ) = (4, 3). Use the following dataset
and compute the predicted class using Euclidean distance.
Example
x1
x2
Class
1
1
2
C1
2
2
3
C1
3
3
3
C2
4
5
4
C2
5
6
5
C2
8. A KNN model with k = 3 is trained to predict whether a customer will buy a product (Y = 1) or not (Y = 0)
based on income (x1 ) and spending score (x2 ). Predict the class of the test sample (x1 , x2 ) = (40, 65)
using Euclidean distance.
Example
x1
x2
Class
1
25
30
0
2
30
40
0
3
35
60
1
4
45
70
1
5
50
80
1
6
60
20
0
9. Apply K-Means clustering with K = 2 to the dataset below. Initialize centroids C1 = (2, 10) and C2 = (5, 8).
Perform one iteration: assign points to clusters (Euclidean distance) and compute new centroids.
Example
x1
x2
1
2
10
2
2
5
3
8
4
4
5
8
5
7
5
6
6
4
10. Apply K-Means with K = 3 to the data below. Initialize centroids C1 = (1, 2), C2 = (5, 8), C3 = (7, 10).
Perform two iterations (assignment + centroid update).
© Ananyo Sengupta
CS2011
Assignment 7: Classification and Clustering
Example
x1
x2
1
1
2
2
1
4
3
3
2
4
5
8
5
6
9
6
7
10
Page 3 of 3
11. Given the 3-D points below, run K-Means with K = 2 initialized at C1 = (1, 2, 3) and C2 = (6, 5, 4). Perform
one iteration and compute updated centroids.
Example
x1
x2
x3
1
1
2
3
2
2
1
2
3
6
5
4
4
7
6
5
12. Cluster the 3-D points below with K-Means (K = 2). Use initial centroids C1 = (2, 3, 1) and C2 = (8, 7, 5);
do one iteration and report new centroids.
Example
x1
x2
x3
1
2
3
1
2
3
2
2
3
8
7
5
4
9
6
6
5
10
8
7
13. Apply K-Means with K = 3 to sensor readings below using initial centroids (1, 1), (4, 3), (8, 7). Perform
two iterations and compute updated centroids.
Example
x1
x2
1
1
1
2
2
1
3
4
3
4
5
4
5
8
7
6
9
6
14. Explain the basic principle of the K-Means clustering algorithm. What is the main objective function
minimized in K-Means? Describe the two main steps of the K-Means algorithm. How are cluster assignments
and centroids updated in each iteration?
15. Differentiate between supervised and unsupervised learning. Under which category does K-Means clustering
fall and why?
© Ananyo Sengupta