Skip to main content

Chapter 4

Machine Learning

TU BCA past exam questions

Past questions and answers

30 questions set from this chapter. Most repeated first.

  • 2022 · 5 marks

What is Machine learning? Describe the types of learning.

Answer

Machine learning is a branch of artificial intelligence in which a computer learns patterns from data and improves its performance on a task with experience, without being explicitly programmed with rules. Formally (Mitchell): a program learns from experience EE with respect to task TT and performance measure PP if its performance on TT, measured by PP, improves with EE.

Types of learning

  1. Supervised learning: The training data contains inputs together with the correct labels. The model learns a mapping x→yx \rightarrow y. Classification (spam or not spam) predicts discrete labels and regression (house price) predicts continuous values. Examples: linear regression, decision tree, SVM, Naive Bayes, k-NN.
  2. Unsupervised learning: The data has no labels. The model finds hidden structure such as clusters or lower-dimensional representations. Examples: k-means, hierarchical clustering, PCA, association rules.
  3. Semi-supervised learning: A small amount of labelled data is combined with a large amount of unlabelled data (e.g. image classification with few labelled photos).
  4. Reinforcement learning: An agent interacts with an environment, takes actions and receives rewards or penalties. It learns a policy that maximises cumulative reward (game playing, robotics, self-driving).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

What is clustering? Describe the approaches used for clustering.

Answer

Clustering is an unsupervised learning technique that groups unlabelled data objects into clusters so that objects in the same cluster are highly similar to each other and dissimilar to objects in other clusters. Similarity is usually measured by a distance such as Euclidean distance. Uses include customer segmentation, document grouping and image segmentation.

Approaches to clustering

  • Partitioning methods: Divide nn objects into kk clusters (k is given in advance) and iteratively improve the partition, e.g. k-means and k-medoids.
  • Hierarchical methods: Build a tree of clusters (dendrogram). Agglomerative (bottom-up) merges the closest clusters step by step; divisive (top-down) splits one big cluster repeatedly.
  • Density-based methods: Clusters are dense regions separated by sparse regions. They find arbitrary-shaped clusters and handle noise, e.g. DBSCAN, OPTICS.
  • Grid-based methods: The space is divided into a grid of cells and clustering is done on cells, which is fast, e.g. STING.
  • Model-based methods: Assume data comes from a mixture of probability distributions and fit them, e.g. Gaussian Mixture Models with EM.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

What is sensitivity and specificity? Describe Confusion matrix with example.

Answer

Sensitivity (recall, true positive rate) is the proportion of actual positives that the model correctly identifies:

Sensitivity=TPTP+FN\text{Sensitivity} = \frac{TP}{TP + FN}

Specificity (true negative rate) is the proportion of actual negatives that the model correctly identifies:

Specificity=TNTN+FP\text{Specificity} = \frac{TN}{TN + FP}

Confusion matrix is a table that compares actual classes with predicted classes of a classifier.

Predicted PositivePredicted Negative
Actual PositiveTP (true positive)FN (false negative)
Actual NegativeFP (false positive)TN (true negative)

Example: A disease test on 100 people gives TP = 40, FN = 10, FP = 5, TN = 45.

  • Accuracy =(40+45)/100=0.85= (40+45)/100 = 0.85
  • Sensitivity =40/(40+10)=0.80= 40/(40+10) = 0.80
  • Specificity =45/(45+5)=0.90= 45/(45+5) = 0.90
  • Precision =40/(40+5)=0.889= 40/(40+5) = 0.889

Thus the test detects 80% of the sick people and correctly clears 90% of the healthy ones.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

What is linear regression? Explain gradient descent algorithm.

Answer

Linear regression is a supervised learning method that models the relationship between a dependent variable yy and one or more independent variables xx by fitting a straight line (hyperplane). For one feature the hypothesis is

hθ(x)=θ0+θ1xh_\theta(x) = \theta_0 + \theta_1 x

The parameters are chosen to minimise the cost function (mean squared error):

J(θ0,θ1)=12m∑i=1m(hθ(x(i))−y(i))2J(\theta_0,\theta_1) = \frac{1}{2m}\sum_{i=1}^{m}\left(h_\theta(x^{(i)}) - y^{(i)}\right)^2

Gradient descent is an iterative optimisation algorithm that finds the parameters minimising JJ.

  1. Initialise θ0,θ1\theta_0,\theta_1 (e.g. with 0 or random values).
  2. Choose learning rate α\alpha.
  3. Repeat until convergence, updating all parameters simultaneously:

θ0:=θ0−α1m∑i=1m(hθ(x(i))−y(i))\theta_0 := \theta_0 - \alpha\frac{1}{m}\sum_{i=1}^{m}\left(h_\theta(x^{(i)})-y^{(i)}\right)

θ1:=θ1−α1m∑i=1m(hθ(x(i))−y(i))x(i)\theta_1 := \theta_1 - \alpha\frac{1}{m}\sum_{i=1}^{m}\left(h_\theta(x^{(i)})-y^{(i)}\right)x^{(i)}

  1. Stop when JJ stops decreasing noticeably or after a fixed number of iterations.

The gradient gives the direction of steepest increase, so moving opposite to it reduces the cost. If α\alpha is too small, convergence is slow; if too large, the algorithm may overshoot and diverge. For linear regression JJ is convex, so gradient descent reaches the global minimum. Variants are batch, stochastic and mini-batch gradient descent.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

Describe training set, validation set and test set. Differentiate between training and testing.

Answer

  • Training set: The portion of data used to fit the model, i.e. to learn the parameters (weights). Typically about 60-70%.
  • Validation set: Data not used for fitting, used to tune hyperparameters (such as k, tree depth, learning rate), to select among models and to detect over-fitting. Typically 15-20%.
  • Test set: Data kept completely unseen until the end, used once to estimate the final generalisation performance of the chosen model. Typically 15-20%.

Training vs testing

TrainingTesting
The model learns patterns and parameters from labelled data.The trained model is evaluated on unseen data.
Aim is to minimise training error.Aim is to measure generalisation (accuracy, precision, recall).
Parameters are updated.Parameters are fixed.
Uses the larger part of the dataset.Uses a smaller, separate part.
Takes more time and computation.Quick, only prediction is done.
High training accuracy alone may mean over-fitting.Test accuracy shows how the model performs in real use.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

Describe line of best fit.

Answer

The line of best fit is the straight line that best represents the relationship between two variables in a scatter plot. It passes as close as possible to all the data points and is used to predict yy for a given xx.

y^=a+bx\hat{y} = a + bx

It is found by the least squares method, which minimises the sum of squared residuals ∑(yi−y^i)2\sum (y_i - \hat{y}_i)^2, where the residual is the vertical distance between an observed point and the line. The coefficients are

b=n∑xy−∑x∑yn∑x2−(∑x)2,a=yˉ−bxˉb = \frac{n\sum xy - \sum x \sum y}{n\sum x^2 - (\sum x)^2}, \qquad a = \bar{y} - b\bar{x}

Properties

  • It always passes through the mean point (xˉ,yˉ)(\bar{x},\bar{y}).
  • The sum of residuals is zero.
  • Slope bb shows the change in yy per unit change in xx; the intercept aa is the value of yy at x=0x=0.
  • The closeness of fit is measured by the correlation coefficient rr or R2R^2.

Example: For points (1,2), (2,4), (3,5), (4,6), (5,8): xˉ=3,yˉ=5\bar{x}=3,\bar{y}=5, b=14/10=1.4b = 14/10 = 1.4, a=0.8a = 0.8, so the line is y^=0.8+1.4x\hat{y}=0.8+1.4x.

In machine learning the same line is obtained by linear regression using the normal equation or gradient descent.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

What is naive bayes algorithm? How does it work? What are its merits and demerits?

Answer

Naive Bayes is a probabilistic supervised classifier based on Bayes' theorem with the "naive" assumption that all features are conditionally independent given the class.

How it works

For a class CkC_k and feature vector X=(x1,…,xn)X=(x_1,\dots,x_n):

P(Ck∣X)=P(X∣Ck) P(Ck)P(X)P(C_k\mid X) = \frac{P(X\mid C_k)\,P(C_k)}{P(X)}

With independence assumed,

P(X∣Ck)=∏i=1nP(xi∣Ck)P(X\mid C_k)=\prod_{i=1}^{n}P(x_i\mid C_k)

Steps:

  1. Compute the prior P(Ck)P(C_k) of each class from training data.
  2. Compute the likelihood P(xi∣Ck)P(x_i\mid C_k) of each feature value for each class (use Laplace smoothing to avoid zero probabilities).
  3. For a new instance, compute P(Ck)∏iP(xi∣Ck)P(C_k)\prod_i P(x_i\mid C_k) for every class.
  4. Predict the class with the largest value (the denominator P(X)P(X) is common and can be ignored).

Merits

  • Simple, very fast to train and predict.
  • Works well with small training data and high-dimensional data (text, spam filtering).
  • Handles multi-class problems and both discrete and continuous features.

Demerits

  • The independence assumption rarely holds in real data.
  • Zero-frequency problem unless smoothing is used.
  • Probability estimates are often poor; continuous features need distribution assumptions (e.g. Gaussian).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 10 marks

How does k-means algorithm work? Suppose following data k = 2 use k-means algorithm to cluster O1(1, 1.5), O2(1, 4.5), O3(2, 1.5), O4(2, 3.5), O5(3, 2.5), O6(3, 4)

Answer

K-means algorithm

  1. Choose the number of clusters kk and select kk initial centroids.
  2. Assign each object to the nearest centroid (Euclidean distance).
  3. Recompute each centroid as the mean of the objects assigned to it.
  4. Repeat steps 2-3 until the assignments (centroids) no longer change.

Solution (k=2k=2): take O1(1,1.5)O_1(1,1.5) and O2(1,4.5)O_2(1,4.5) as the initial centroids C1,C2C_1,C_2.

Iteration 1 (distances to C1(1,1.5)C_1(1,1.5) and C2(1,4.5)C_2(1,4.5))

Objectd to C1d to C2Cluster
O1 (1,1.5)03.00C1
O2 (1,4.5)3.000C2
O3 (2,1.5)1.003.16C1
O4 (2,3.5)2.241.41C2
O5 (3,2.5)2.242.83C1
O6 (3,4)3.202.06C2

New centroids:

C1=(1+2+33,1.5+1.5+2.53)=(2, 1.83)C_1 = \left(\frac{1+2+3}{3},\frac{1.5+1.5+2.5}{3}\right) = (2,\,1.83)

C2=(1+2+33,4.5+3.5+43)=(2, 4.0)C_2 = \left(\frac{1+2+3}{3},\frac{4.5+3.5+4}{3}\right) = (2,\,4.0)

Iteration 2 (distances to C1(2,1.83)C_1(2,1.83) and C2(2,4)C_2(2,4))

Objectd to C1d to C2Cluster
O11.052.69C1
O22.851.12C2
O30.332.50C1
O41.670.50C2
O51.201.80C1
O62.461.00C2

The assignments are unchanged, so the algorithm has converged.

Final clusters: Cluster 1 = {O1, O3, O5} with centroid (2, 1.83); Cluster 2 = {O2, O4, O6} with centroid (2, 4.0).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 10 marks

What is perceptron? Explain back propagation algorithm with suitable example.

Answer

Perceptron

A perceptron is the simplest artificial neuron and a linear binary classifier. It computes a weighted sum of inputs plus bias and passes it through a step activation:

y=f(∑i=1nwixi+b),f(z)={1z≥00z<0y = f\left(\sum_{i=1}^{n} w_i x_i + b\right), \qquad f(z)=\begin{cases}1 & z\ge 0\\ 0 & z<0\end{cases}

Learning rule: wi←wi+η (t−y) xiw_i \leftarrow w_i + \eta\,(t-y)\,x_i, where tt is the target and η\eta the learning rate. It can only solve linearly separable problems (AND, OR but not XOR). Multi-layer perceptrons overcome this using hidden layers and the back propagation algorithm.

Back propagation algorithm

Back propagation trains a multilayer feed-forward network by gradient descent on the error, propagating the error backward from output to input.

  1. Initialise weights and biases with small random values.
  2. Forward pass: for each training example, compute hidden outputs oj=σ(∑wijxi+bj)o_j=\sigma(\sum w_{ij}x_i+b_j) and then output outputs oko_k, with σ(z)=1/(1+e−z)\sigma(z)=1/(1+e^{-z}).
  3. Compute error at the output: δk=ok(1−ok)(tk−ok)\delta_k = o_k(1-o_k)(t_k-o_k).
  4. Backward pass: for each hidden unit jj, δj=oj(1−oj)∑kwjkδk\delta_j = o_j(1-o_j)\sum_k w_{jk}\delta_k.
  5. Update weights: wij←wij+η δj oiw_{ij} \leftarrow w_{ij} + \eta\,\delta_j\,o_i and biases bj←bj+η δjb_j \leftarrow b_j + \eta\,\delta_j.
  6. Repeat for all examples (epochs) until the error is small enough.

Example: Network with inputs x1=1,x2=0x_1=1, x_2=0, one hidden neuron hh with w1h=0.5,w2h=0.4w_{1h}=0.5, w_{2h}=0.4, bh=0b_h=0, and an output neuron with who=0.3w_{ho}=0.3, bo=0b_o=0, target t=1t=1, η=0.5\eta=0.5.

  • Forward: zh=0.5z_h=0.5, oh=σ(0.5)=0.622o_h=\sigma(0.5)=0.622; zo=0.3(0.622)=0.187z_o=0.3(0.622)=0.187, oo=σ(0.187)=0.547o_o=\sigma(0.187)=0.547.
  • Output error: δo=0.547(0.453)(1−0.547)=0.112\delta_o = 0.547(0.453)(1-0.547)=0.112.
  • Hidden error: δh=0.622(0.378)(0.3)(0.112)=0.0079\delta_h = 0.622(0.378)(0.3)(0.112)=0.0079.
  • Updates: who=0.3+0.5(0.112)(0.622)=0.335w_{ho}=0.3+0.5(0.112)(0.622)=0.335; w1h=0.5+0.5(0.0079)(1)=0.504w_{1h}=0.5+0.5(0.0079)(1)=0.504; w2hw_{2h} stays 0.4 (since x2=0x_2=0).

The next forward pass gives an output closer to 1, so the error decreases.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 10 marks

How does SVM works? Describe functional margin, geometric margin and optimum margin classifier. Show the relationship between functional and geometrical margin.

Answer

How SVM works

A Support Vector Machine is a supervised classifier that finds the hyperplane wTx+b=0w^Tx+b=0 that separates two classes with the maximum margin. Points closest to the hyperplane are the support vectors; only they determine the boundary. For non-separable data, a soft margin (parameter CC) allows some errors, and the kernel trick (polynomial, RBF) maps the data to a higher-dimensional space where a linear separation is possible. Prediction: class +1+1 if wTx+b>0w^Tx+b>0, else −1-1.

Functional margin

For a training example (x(i),y(i))(x^{(i)},y^{(i)}) with y(i)∈{−1,+1}y^{(i)}\in\{-1,+1\}:

γ^(i)=y(i)(wTx(i)+b)\hat{\gamma}^{(i)} = y^{(i)}\left(w^Tx^{(i)}+b\right)

A large positive value means a confident and correct prediction. For the training set it is γ^=min⁡iγ^(i)\hat\gamma=\min_i\hat\gamma^{(i)}. It can be made arbitrarily large by scaling (w,b)(w,b), so it is not a true distance.

Geometric margin

The actual Euclidean distance of a point from the hyperplane:

γ(i)=y(i)(wT∥w∥x(i)+b∥w∥)\gamma^{(i)} = y^{(i)}\left(\frac{w^T}{\|w\|}x^{(i)}+\frac{b}{\|w\|}\right)

It is invariant to scaling of (w,b)(w,b).

Relationship

γ(i)=γ^(i)∥w∥\gamma^{(i)}=\frac{\hat{\gamma}^{(i)}}{\|w\|}

If ∥w∥=1\|w\|=1 the two margins are equal.

Optimum margin classifier

It chooses w,bw,b to maximise the geometric margin γ\gamma. Fixing the functional margin γ^=1\hat\gamma=1 (by scaling), maximising γ=1/∥w∥\gamma=1/\|w\| is equivalent to the convex quadratic problem

min⁡w,b 12∥w∥2subject toy(i)(wTx(i)+b)≥1, ∀i\min_{w,b}\ \frac12\|w\|^2 \quad \text{subject to}\quad y^{(i)}(w^Tx^{(i)}+b)\ge 1,\ \forall i

Solved through its Lagrangian dual, w=∑iαiy(i)x(i)w=\sum_i\alpha_i y^{(i)}x^{(i)} where αi>0\alpha_i>0 only for support vectors. The resulting classifier has the widest possible gap between the classes and hence good generalisation.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What constitutes over-fitting, and how can it be prevented? Elaborate with a suitable example.

Answer

Over-fitting occurs when a model learns the training data too well, including its noise and random fluctuations, so it has very low training error but high error on unseen data. It happens when the model is too complex relative to the amount of data (high variance, low bias). It is identified by a large gap between training and validation/test accuracy.

Example: Fitting a degree-9 polynomial through 10 noisy points lying roughly on a line gives zero training error, but the curve wiggles wildly and predicts new points badly, whereas a straight line generalises well. Similarly, a decision tree grown until every leaf is pure may memorise the training set and give 100% training but 70% test accuracy.

Prevention

  • Collect more training data.
  • Use a simpler model (fewer features, lower polynomial degree, smaller network).
  • Regularisation (L1/L2 penalty on weights, dropout in neural networks).
  • Cross-validation and a separate validation set to tune hyperparameters.
  • Early stopping when validation error starts rising.
  • Pruning for decision trees.
  • Feature selection or dimensionality reduction.
  • Ensemble methods such as bagging and random forests.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

Define perceptron. Explain K-means clustering algorithm.

Answer

Perceptron

A perceptron is a single artificial neuron and the simplest linear binary classifier. It takes inputs x1,…,xnx_1,\dots,x_n with weights wiw_i and bias bb, and outputs

y={1∑iwixi+b≥00otherwisey=\begin{cases}1 & \sum_i w_ix_i+b\ge 0\\ 0 & \text{otherwise}\end{cases}

Weights are learned with wi←wi+η(t−y)xiw_i \leftarrow w_i+\eta(t-y)x_i, where tt is the target output and η\eta the learning rate. It converges only if the classes are linearly separable.

K-means clustering

K-means is an unsupervised partitioning algorithm that divides data into kk clusters.

  1. Select kk and choose kk initial centroids (randomly).
  2. Assign every point to the nearest centroid using Euclidean distance.
  3. Recompute each centroid as the mean of its assigned points.
  4. Repeat steps 2 and 3 until centroids stop changing (or a maximum number of iterations is reached).

It minimises the within-cluster sum of squares ∑j=1k∑x∈Cj∥x−μj∥2\sum_{j=1}^{k}\sum_{x\in C_j}\|x-\mu_j\|^2. It is simple and fast, but needs kk in advance, is sensitive to initial centroids and outliers, and finds only spherical clusters.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

Discuss the strengths and weaknesses of the Naive Bayes algorithm compared to other classification algorithms like Support Vector Machines.

Answer

Naive Bayes

Strengths

  • Very fast training and prediction; needs only counting of frequencies.
  • Works well with small datasets and very high-dimensional data such as text classification and spam filtering.
  • Naturally multi-class and gives probabilistic outputs.
  • Few hyperparameters and little tuning.

Weaknesses

  • The conditional independence assumption is rarely true; correlated features reduce accuracy.
  • Zero-probability problem unless smoothing is used.
  • Cannot learn interactions between features.
  • Probability estimates are poorly calibrated.

Comparison with SVM

AspectNaive BayesSVM
TypeGenerative, probabilisticDiscriminative, maximum-margin
Training speedVery fast, linearSlower (quadratic or worse) for large data
Feature dependenceAssumes independenceHandles dependent features
Non-linear dataLimitedHandled using kernels
AccuracyLower on complex data, good on small dataUsually higher on complex, high-dimensional data
ProbabilitiesDirect outputNot direct (needs calibration)
TuningAlmost noneNeeds choice of kernel, CC, γ\gamma
Noise/outliersFairly robustSensitive in the hard-margin case

Naive Bayes is preferred for quick baselines and small or text data; SVM for higher accuracy when features are interdependent.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

Why dimensionality reduction is useful? Considering a Long List of Machine Learning Algorithms, given a Data Set, How Do You Decide Which One to Use? Justify your answer.

Answer

Why dimensionality reduction is useful

  • Reduces the curse of dimensionality: with many features, data becomes sparse and models over-fit.
  • Lowers storage, memory and training time.
  • Removes redundant, correlated and noisy features, improving accuracy.
  • Makes visualisation possible by reducing data to 2D or 3D.
  • Makes models simpler and easier to interpret.

Methods: PCA, LDA, t-SNE, feature selection.

Choosing an algorithm for a given data set

No single algorithm is best (no free lunch), so the choice is guided by the data and the problem:

  1. Type of problem: labelled target with categories gives classification, numeric target gives regression, no labels gives clustering or dimensionality reduction, sequential decisions give reinforcement learning.
  2. Size of data: small data suits Naive Bayes, linear models, k-NN; large data suits neural networks, gradient boosting.
  3. Number and type of features: many features suit linear models, SVM or regularised models; mixed categorical features suit decision trees.
  4. Linearity: linear relationship gives linear/logistic regression; non-linear gives SVM with kernel, trees, neural networks.
  5. Interpretability needed: decision trees and linear models over black-box models.
  6. Speed and resources for training and prediction.
  7. Experimentation: try a few candidate models, compare them by cross-validation using suitable metrics (accuracy, F1, RMSE), tune hyperparameters and pick the best one that does not over-fit.

This justifies choosing by data characteristics plus empirical validation rather than by a fixed rule.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What do you mean by ROC curve? In a credit card fraud detection system, the algorithm flagged 50 transactions as fraudulent. Out of these flagged transactions, 45 were indeed fraudulent. Additionally, the algorithm didn't flag 30 fraudulent transactions. Calculate the precision, recall and F1-score for the fraud detection system.

Answer

ROC curve

The Receiver Operating Characteristic (ROC) curve plots the True Positive Rate (sensitivity, TP/(TP+FN)TP/(TP+FN)) on the y-axis against the False Positive Rate (FP/(FP+TN)FP/(FP+TN)) on the x-axis for all possible classification thresholds. A curve close to the top-left corner indicates a good classifier; the diagonal represents random guessing. The area under the curve (AUC) summarises performance: 1 is perfect, 0.5 is no better than chance.

Fraud detection calculation

  • Flagged as fraud = 50, of which truly fraud: TP=45TP=45, so FP=50−45=5FP=50-45=5.
  • Fraudulent transactions not flagged: FN=30FN=30.

Precision=TPTP+FP=4550=0.90\text{Precision}=\frac{TP}{TP+FP}=\frac{45}{50}=0.90

Recall=TPTP+FN=4575=0.60\text{Recall}=\frac{TP}{TP+FN}=\frac{45}{75}=0.60

F1=2×0.90×0.600.90+0.60=1.081.5=0.72F1=\frac{2\times 0.90\times 0.60}{0.90+0.60}=\frac{1.08}{1.5}=0.72

So precision is 90%, recall 60% and F1-score 0.72. The system is accurate when it flags, but misses 40% of the frauds.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What do you mean by hierarchical clustering? How can regression be used to find best fit line?

Answer

Hierarchical clustering builds a hierarchy (tree) of clusters, shown as a dendrogram, without needing the number of clusters in advance.

  • Agglomerative (bottom-up): start with each object as its own cluster; repeatedly merge the two closest clusters until one cluster remains.
  • Divisive (top-down): start with all objects in one cluster; repeatedly split until each object is separate.

Distance between clusters is measured by single linkage (minimum), complete linkage (maximum), average linkage or centroid distance. Cutting the dendrogram at a chosen height gives the desired number of clusters.

Using regression to find the best-fit line

Linear regression models y^=θ0+θ1x\hat y=\theta_0+\theta_1x and finds the parameters that minimise the sum of squared errors between actual and predicted values:

J=∑i=1m(yi−θ0−θ1xi)2J=\sum_{i=1}^{m}\left(y_i-\theta_0-\theta_1x_i\right)^2

Setting the partial derivatives to zero gives

θ1=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2,θ0=yˉ−θ1xˉ\theta_1=\frac{\sum(x_i-\bar x)(y_i-\bar y)}{\sum(x_i-\bar x)^2},\qquad \theta_0=\bar y-\theta_1\bar x

(or the same result is reached iteratively by gradient descent). The resulting line passes through (xˉ,yˉ)(\bar x,\bar y) and is the line of best fit, which can then predict yy for new xx.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

Write short notes on (any two):
a) Supervised Vs. Unsupervised Learning
b) Sensitivity and Specificity
c) Bayesian Belief Network

Answer

(a) Supervised vs. unsupervised learning

SupervisedUnsupervised
Uses labelled data (input and known output).Uses unlabelled data.
Learns a mapping from inputs to outputs.Discovers hidden structure or patterns.
Tasks: classification, regression.Tasks: clustering, dimensionality reduction, association.
Algorithms: linear regression, decision tree, SVM, k-NN.Algorithms: k-means, hierarchical clustering, PCA.
Accuracy can be measured directly.Evaluation is harder and more subjective.
Example: predicting spam emails.Example: grouping customers by behaviour.

(b) Sensitivity and specificity

Sensitivity (true positive rate) is the fraction of actual positives correctly detected, TP/(TP+FN)TP/(TP+FN). Specificity (true negative rate) is the fraction of actual negatives correctly identified, TN/(TN+FP)TN/(TN+FP). They are derived from the confusion matrix and are used especially in medical testing: a highly sensitive test rarely misses disease, a highly specific test rarely gives false alarms. Raising one usually lowers the other, as shown on the ROC curve.

(c) Bayesian belief network

A Bayesian belief network is a directed acyclic graph in which nodes represent random variables and edges represent conditional (causal) dependencies. Each node has a conditional probability table P(X∣Parents(X))P(X\mid \text{Parents}(X)). The joint probability is

P(x1,…,xn)=∏i=1nP(xi∣Parents(xi))P(x_1,\dots,x_n)=\prod_{i=1}^{n}P\left(x_i\mid \text{Parents}(x_i)\right)

It allows reasoning under uncertainty, such as computing the probability of disease given symptoms, and unlike Naive Bayes it permits dependencies between variables.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 10 marks

What is the need of confusion matrix? Explain the frame work for building machine learning system.

Answer

Need of the confusion matrix

Accuracy alone can be misleading, especially for imbalanced data (a model predicting "no fraud" always can be 99% accurate). The confusion matrix tabulates actual versus predicted classes:

Predicted PositivePredicted Negative
Actual PositiveTPFN
Actual NegativeFPTN

It is needed because

  • it shows the types of errors (false positives and false negatives), which have different costs;
  • it allows computing accuracy =TP+TNTP+TN+FP+FN=\frac{TP+TN}{TP+TN+FP+FN}, precision =TPTP+FP=\frac{TP}{TP+FP}, recall =TPTP+FN=\frac{TP}{TP+FN}, specificity and F1-score;
  • it shows which classes are confused with each other in multi-class problems;
  • it helps compare models and choose thresholds.

Framework for building a machine learning system

  1. Problem definition: state the goal, the task type (classification, regression, clustering) and the success metric.
  2. Data collection: gather relevant data from databases, sensors, web, surveys.
  3. Data preparation (pre-processing): clean missing values, noise and duplicates; encode categorical data; scale/normalise.
  4. Exploratory analysis and feature engineering: visualise, select, extract or reduce features.
  5. Splitting data: into training, validation and test sets.
  6. Model selection and training: choose candidate algorithms and fit them to the training set.
  7. Evaluation and tuning: assess on validation data (cross-validation, confusion matrix, ROC) and tune hyperparameters; handle over/under-fitting.
  8. Testing: measure final performance on the unseen test set.
  9. Deployment: integrate the model into an application or service.
  10. Monitoring and maintenance: track performance, detect data drift and retrain with new data.

The process is iterative; results at later steps often send the developer back to earlier steps.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 10 marks

Define entropy and information gain. Construct decision tree (ID3 Algorithm)for the following:DayOutlookTemperatureHumidityWindDecision
1SunnyHotHighWeakYes
2SunnyHotHighStrongNo
3OvercastHotHighWeakYes
4RainMildHighWeakNo
5RainColdNormalWeakYes

Answer

Entropy measures the impurity (uncertainty) of a set SS of examples:

H(S)=−∑ipilog⁡2piH(S)=-\sum_{i}p_i\log_2 p_i

It is 0 for a pure set and 1 for a two-class set split equally.

Information gain is the expected reduction in entropy after splitting on attribute AA:

IG(S,A)=H(S)−∑v∈A∣Sv∣∣S∣H(Sv)IG(S,A)=H(S)-\sum_{v\in A}\frac{|S_v|}{|S|}H(S_v)

ID3 selects, at each node, the attribute with the highest information gain.

Construction

Data: 3 Yes (days 1, 3, 5) and 2 No (days 2, 4).

H(S)=−35log⁡235−25log⁡225=0.971H(S)=-\tfrac35\log_2\tfrac35-\tfrac25\log_2\tfrac25=0.971

Outlook: Sunny {Yes, No} gives H=1H=1; Overcast {Yes} gives 00; Rain {No, Yes} gives 11.

IG=0.971−(25(1)+15(0)+25(1))=0.171IG=0.971-\left(\tfrac25(1)+\tfrac15(0)+\tfrac25(1)\right)=0.171

Temperature: Hot {Y, N, Y} gives H=0.918H=0.918; Mild {N} gives 00; Cold {Y} gives 00.

IG=0.971−35(0.918)=0.971−0.551=0.420IG=0.971-\tfrac35(0.918)=0.971-0.551=0.420

Humidity: High {Y, N, Y, N} gives H=1H=1; Normal {Y} gives 00.

IG=0.971−45(1)=0.171IG=0.971-\tfrac45(1)=0.171

Wind: Weak {Y, Y, N, Y} gives H=0.811H=0.811; Strong {N} gives 00.

IG=0.971−45(0.811)=0.322IG=0.971-\tfrac45(0.811)=0.322

Temperature has the highest gain (0.420), so it is the root.

  • Mild gives No (pure).
  • Cold gives Yes (pure).
  • Hot contains days 1, 2, 3 {Y, N, Y}. Splitting by Wind: Weak (days 1, 3) gives Yes and Strong (day 2) gives No, so gain is highest and the subtree is pure.

Decision tree

Temperature
├── Mild  -> No
├── Cold  -> Yes
└── Hot   -> Wind
              ├── Weak   -> Yes
              └── Strong -> No

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 10 marks

What are bias -variance trade off? Consider the table given below and use K-NN algorithm to evaluate result of Sija= {Machine Learning=60 GIS=80}DayOutlookTemperatureHumidityWindDecision
1SunnyHotHighWeakYes
2SunnyHotHighStrongNo
3OvercastHotHighWeakYes
4RainMildHighWeakNo
5RainColdNormalWeakYes

Answer

Bias-variance trade-off

The expected prediction error of a model can be decomposed as

Error=Bias2+Variance+Irreducible noise\text{Error}=\text{Bias}^2+\text{Variance}+\text{Irreducible noise}

  • Bias is the error from wrong or over-simple assumptions; high bias causes under-fitting.
  • Variance is the sensitivity of the model to small changes in the training data; high variance causes over-fitting.

Making a model more complex lowers bias but raises variance, and a simpler model does the opposite. The trade-off is to choose the complexity that minimises total error, usually found with validation.

K-NN algorithm

  1. Choose kk.
  2. Compute the distance (Euclidean) between the query and each training example.
  3. Take the kk nearest examples.
  4. Predict the majority class (or the average for regression).

Applying it to the table

The query Sija ={Machine Learning=60, GIS=80}=\{\text{Machine Learning}=60,\ \text{GIS}=80\} is described by two numeric marks, but the given table has the categorical attributes Outlook, Temperature, Humidity and Wind, and contains no Machine Learning or GIS values. Distances between Sija and the five days therefore cannot be computed from the table as it stands. With the table's own attributes, a new day is classified as follows: encode each attribute, count the number of mismatching attributes (Hamming distance) to every day, pick the kk closest days (for example k=3k=3) and take the majority of their Decision values. For a query with numeric attributes such as Sija, the distance to a training record (a,b)(a,b) would be d=(60−a)2+(80−b)2d=\sqrt{(60-a)^2+(80-b)^2}, and the Decision of the majority of the kk nearest records would be assigned to Sija.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 2+3 marks

Explain the bias–variance trade-off in machine learning. Provide examples of how increasing model complexity affects both bias and variance.

Answer

Bias-variance trade-off

The expected error of a model on unseen data is

Error=Bias2+Variance+Irreducible error\text{Error}=\text{Bias}^2+\text{Variance}+\text{Irreducible error}

  • Bias is the error caused by overly simple assumptions (under-fitting).
  • Variance is the error caused by sensitivity to the particular training sample (over-fitting).

The trade-off: lowering one tends to raise the other, so the best model balances the two to minimise total error.

Effect of increasing complexity

  • Low complexity: a linear model fitted to curved (quadratic) data has high bias and low variance. It under-fits and gives high error on both training and test data.
  • Moderate complexity: a degree-2 polynomial matches the true pattern; bias and variance are both low, so test error is lowest.
  • High complexity: a degree-10 polynomial or a very deep decision tree fits the training noise: bias is very low, variance is high, training error is near zero but test error rises.

So as complexity increases, bias decreases and variance increases. Test error is U-shaped, and the optimum is at the bottom of the U. Regularisation, more data and cross-validation help control it.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 3+2 marks

Describe the decision tree algorithm. What are the advantages and disadvantages of using decision trees?

Answer

Decision tree algorithm

A decision tree is a supervised model (classification and regression) that represents decisions as a tree: internal nodes test an attribute, branches are the outcomes of the test, and leaf nodes hold the class label or value.

Building (top-down, recursive, e.g. ID3, C4.5, CART):

  1. Start with all training examples at the root.
  2. Select the best attribute using a splitting measure: information gain (entropy) in ID3, gain ratio in C4.5, or Gini index in CART.
  3. Split the data by the attribute's values into child nodes.
  4. Repeat recursively on each child until the node is pure, no attributes remain, or a stopping condition is met.
  5. Prune the tree to avoid over-fitting.

To classify a new example, follow the tests from the root to a leaf.

Advantages

  • Easy to understand and interpret; can be visualised and converted to rules.
  • Handles numeric and categorical data with little pre-processing (no scaling).
  • Captures non-linear relationships and feature interactions.
  • Fast prediction.

Disadvantages

  • Prone to over-fitting without pruning.
  • Unstable: small changes in data can produce a very different tree.
  • Greedy splitting may not give the globally optimal tree.
  • Biased toward attributes with many values; poor for imbalanced classes.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Discuss the structure and learning process of a neural network in supervised learning.

Answer

Structure of a neural network

An artificial neural network consists of layers of interconnected neurons:

  • Input layer: one neuron per feature; passes the inputs on.
  • Hidden layer(s): neurons compute a=f(∑wixi+b)a=f\left(\sum w_ix_i+b\right) using weights ww, bias bb and a non-linear activation ff (sigmoid, tanh, ReLU).
  • Output layer: produces the prediction (sigmoid or softmax for classes, linear for regression).

Each connection has a weight; the weights and biases are the parameters learned.

Learning process in supervised learning

  1. Initialise weights randomly.
  2. Forward propagation: feed a training input through the layers to get the predicted output y^\hat y.
  3. Compute loss: compare with the true label yy using a loss function such as mean squared error or cross-entropy.
  4. Back propagation: propagate the error backward using the chain rule to compute the gradient of the loss with respect to every weight.
  5. Update weights by gradient descent: w←w−η ∂L∂ww\leftarrow w-\eta\,\dfrac{\partial L}{\partial w}, with learning rate η\eta.
  6. Repeat over all training examples (epochs, usually in mini-batches) until the loss converges or validation error stops improving.

Finally the network is evaluated on unseen test data; regularisation, dropout and early stopping reduce over-fitting.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 2.5+2.5 marks

The ages of 10 employees in a company are:
22, 25, 29, 30, 31, 33, 35, 36, 40, 45
a. Find minimum, Q1, median, Q3, and maximum values.
b. Draw a box plot for the data.

Answer

(a) Data (already sorted, n=10n=10): 22, 25, 29, 30, 31, 33, 35, 36, 40, 45

  • Minimum =22=22
  • Maximum =45=45
  • Median =31+332=32=\dfrac{31+33}{2}=32 (average of the 5th and 6th values)
  • Q1Q_1 = median of the lower half (22, 25, 29, 30, 31) =29=29
  • Q3Q_3 = median of the upper half (33, 35, 36, 40, 45) =36=36

Five-number summary: 22, 29, 32, 36, 45. IQR=36−29=7\text{IQR}=36-29=7.

Outlier fences: 29−1.5(7)=18.529-1.5(7)=18.5 and 36+1.5(7)=46.536+1.5(7)=46.5; all values lie inside, so there are no outliers.

(b) Box plot (on an age scale):

age: 20    25    30    35    40    45
      |-----[=====|====]-------------|
     22    29    32   36            45
     min   Q1   median Q3          max

The box extends from Q1=29Q_1=29 to Q3=36Q_3=36 with a line at the median 32. The whiskers extend to the minimum 22 on the left and the maximum 45 on the right. The longer right whisker shows slight positive skew.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

A spam filter uses the words "offer" and "win" as features.
From training data:
ClassP(offer)P(win)Prior Probability
Spam0.80.60.4
Not Spam0.10.050.6
Given an email containing both words, classify it as Spam or Not Spam using Naïve Bayes.

Answer

Naive Bayes: P(C∣offer, win)∝P(C) P(offer∣C) P(win∣C)P(C\mid \text{offer, win})\propto P(C)\,P(\text{offer}\mid C)\,P(\text{win}\mid C) (features assumed independent).

Spam:

0.4×0.8×0.6=0.1920.4\times0.8\times0.6=0.192

Not Spam:

0.6×0.1×0.05=0.0030.6\times0.1\times0.05=0.003

Normalising with P(evidence)=0.192+0.003=0.195P(\text{evidence})=0.192+0.003=0.195:

P(Spam∣offer, win)=0.1920.195≈0.985P(\text{Spam}\mid\text{offer, win})=\frac{0.192}{0.195}\approx0.985

P(Not Spam∣offer, win)=0.0030.195≈0.015P(\text{Not Spam}\mid\text{offer, win})=\frac{0.003}{0.195}\approx0.015

Since 0.192>0.0030.192>0.003, the email is classified as Spam (about 98.5% probability).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Explain the steps of the Principal Component Analysis (PCA) algorithm.

Answer

Principal Component Analysis (PCA) is an unsupervised dimensionality-reduction technique that transforms correlated features into a smaller set of uncorrelated variables (principal components) that retain most of the variance.

Steps

  1. Standardise the data: subtract the mean of each feature (and divide by the standard deviation if scales differ) so each feature has mean 0.
  2. Compute the covariance matrix of the features: C=1n−1XTXC=\frac{1}{n-1}X^TX
  3. Compute eigenvalues and eigenvectors of CC by solving Cv=λvCv=\lambda v (or use SVD). Eigenvectors give the directions of the components; eigenvalues give the variance along them.
  4. Sort eigenvectors by decreasing eigenvalue.
  5. Select the top kk components that explain enough variance (e.g. 95%), using the explained variance ratio λi/∑λj\lambda_i/\sum\lambda_j.
  6. Form the projection matrix WW from the chosen eigenvectors.
  7. Transform the data: Z=XWZ=XW, giving the new n×kn\times k dataset.

The first component captures the maximum variance, the second is orthogonal to it and captures the next largest, and so on.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Perform one iteration of K-means clustering for the following points with initial centroids C1 = (1,1) and C2 = (5,4): Points: (1,1), (2,1), (4,3), (5,4). Use Euclidean distance.

Answer

Initial centroids: C1=(1,1)C_1=(1,1), C2=(5,4)C_2=(5,4).

Assignment step (Euclidean distance)

Pointd to C1 (1,1)d to C2 (5,4)Cluster
(1,1)016+9=5.00\sqrt{16+9}=5.00C1
(2,1)1+0=1.00\sqrt{1+0}=1.009+9=4.24\sqrt{9+9}=4.24C1
(4,3)9+4=3.61\sqrt{9+4}=3.611+1=1.41\sqrt{1+1}=1.41C2
(5,4)16+9=5.00\sqrt{16+9}=5.000C2

Update step

C1=(1+22,1+12)=(1.5, 1)C_1=\left(\frac{1+2}{2},\frac{1+1}{2}\right)=(1.5,\,1)

C2=(4+52,3+42)=(4.5, 3.5)C_2=\left(\frac{4+5}{2},\frac{3+4}{2}\right)=(4.5,\,3.5)

After one iteration: Cluster 1 = {(1,1), (2,1)} with centroid (1.5, 1); Cluster 2 = {(4,3), (5,4)} with centroid (4.5, 3.5).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 6+4 marks

Describe the Support Vector Machine (SVM) concept of maximum margin classification with a diagram. A model trained on a dataset achieves the following results:
Training accuracy: 95%
Validation accuracy: 80%
Test accuracy: 78%
Discuss whether the model is underfitting, overfitting, or well-fitted. Justify your answer.

Answer

SVM maximum margin classification

SVM finds, among all hyperplanes wTx+b=0w^Tx+b=0 that separate the two classes, the one with the maximum margin, i.e. the largest distance to the nearest training points of either class. The nearest points are the support vectors; they lie on the margin hyperplanes wTx+b=±1w^Tx+b=\pm1, and the margin width is 2/∥w∥2/\|w\|. Maximising it is equivalent to

min⁡w,b 12∥w∥2s.t.yi(wTxi+b)≥1\min_{w,b}\ \tfrac12\|w\|^2\quad\text{s.t.}\quad y_i(w^Tx_i+b)\ge1

A larger margin gives better generalisation. Non-separable data uses a soft margin (parameter CC) or kernels.

   x2
    |   o        o   (class +1)
    |      o     \  w.x+b = +1
    |  ----------\----------- w.x+b = 0   (max-margin hyperplane)
    |   x      x  \  w.x+b = -1
    |        x        (class -1)
    +------------------------- x1
   (support vectors lie on the dashed margin lines;
    margin width = 2/||w||)

Fit analysis

Training accuracy 95%, validation 80% and test 78%.

  • The training accuracy is high, so the model is not under-fitting (under-fitting would show low accuracy on training data too).
  • There is a large gap (about 15-17 points) between training and validation/test accuracy, while validation and test are close to each other.

Hence the model is over-fitted: it has memorised the training data, including noise, and generalises poorly. The close validation and test scores show the drop is consistent, not an accident of one split. Remedies: regularisation, simpler model, more data, cross-validation, early stopping, feature reduction. A well-fitted model would show training and validation accuracies both high and close together.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 3+7 marks

Explain the concept of Confusion Matrix with example. Given the dataset below, fit a linear regression model using the least squares method and find the best-fit line equation. Also find the value of Y at X=4.5
XY
12
24
35
46
58

Answer

Confusion matrix

A confusion matrix is a table that summarises the performance of a classifier by comparing actual and predicted classes.

Predicted PositivePredicted Negative
Actual PositiveTPFN
Actual NegativeFPTN

Example: A spam filter classifies 100 emails: TP = 40, FN = 10, FP = 5, TN = 45. Then accuracy =85100=0.85=\frac{85}{100}=0.85, precision =4045=0.89=\frac{40}{45}=0.89, recall =4050=0.80=\frac{40}{50}=0.80.

Linear regression by least squares

XXYYX−XˉX-\bar XY−YˉY-\bar Y(X−Xˉ)(Y−Yˉ)(X-\bar X)(Y-\bar Y)(X−Xˉ)2(X-\bar X)^2
12-2-364
24-1-111
350000
461111
582364
Sum1410

Xˉ=155=3, Yˉ=255=5\bar X=\frac{15}{5}=3,\ \bar Y=\frac{25}{5}=5

b=∑(X−Xˉ)(Y−Yˉ)∑(X−Xˉ)2=1410=1.4b=\frac{\sum(X-\bar X)(Y-\bar Y)}{\sum(X-\bar X)^2}=\frac{14}{10}=1.4

a=Yˉ−bXˉ=5−1.4(3)=0.8a=\bar Y-b\bar X=5-1.4(3)=0.8

Best-fit line:

Y=0.8+1.4XY=0.8+1.4X

At X=4.5X=4.5:

Y=0.8+1.4(4.5)=0.8+6.3=7.1Y=0.8+1.4(4.5)=0.8+6.3=7.1

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 6+4 marks

Explain the K-nearest neighbor (KNN) algorithm. How does the value of k affect bias and variance?
Given two classes of points:
Class +1: (2, 2), (4, 4)
Class −1: (4, 0), (0, 0)
Determine the equation of the separating hyper-plane.

Answer

K-nearest neighbour (KNN)

KNN is a simple, instance-based (lazy) supervised algorithm. To classify a query point:

  1. Choose kk and a distance measure (usually Euclidean).
  2. Compute the distance from the query to all training points.
  3. Select the kk nearest points.
  4. Predict the majority class (or the average value for regression).

No model is built during training; all the work is done at prediction time.

Effect of kk on bias and variance

  • Small kk (e.g. 1): the boundary is very flexible and follows noise, so low bias, high variance (over-fitting).
  • Large kk: predictions are averaged over many neighbours and the boundary is smooth, so high bias, low variance (under-fitting). If k=nk=n, it always predicts the majority class.

kk is chosen by cross-validation, usually odd to avoid ties.

Separating hyperplane

Class +1+1: (2,2), (4,4); class −1-1: (4,0), (0,0). The maximum-margin hyperplane has support vectors (2,2), (4,0), (0,0). Writing wTx+b=+1w^Tx+b=+1 for (2,2) and −1-1 for the negatives:

  • (0,0): b=−1b=-1
  • (4,0): 4w1+b=−1⇒w1=04w_1+b=-1\Rightarrow w_1=0
  • (2,2): 2w2+b=1⇒w2=12w_2+b=1\Rightarrow w_2=1

So w=(0,1)w=(0,1), b=−1b=-1. Check (4,4): 4−1=3≥14-1=3\ge1, so it is correctly classified. Dual check: w=∑αiyixiw=\sum\alpha_iy_ix_i gives α=12\alpha=\tfrac12 for (2,2), 14\tfrac14 for (4,0), and 14\tfrac14 for (0,0), all positive and balanced (12=14+14\tfrac12=\tfrac14+\tfrac14).

x2−1=0i.e.x2=1x_2-1=0 \quad\text{i.e.}\quad x_2=1

The margin is 2/∥w∥=22/\|w\|=2.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from TU BCA 2022 Eighth Semester Database Programming (TU board exam, 2022), TU BCA 2023 Eighth Semester Database Programming (TU board exam, 2023), TU BCA 2024 Eighth Semester Database Programming (TU board exam, 2024), TU BCA 2025 Eighth Semester Database Programming (TU board exam, 2025), TU BCA 2022 Eighth Semester Geographical Information System (TU board exam, 2022), TU BCA 2023 Eighth Semester Geographical Information System (TU board exam, 2023), TU BCA 2024 Eighth Semester Geographical Information System (TU board exam, 2024), TU BCA 2025 Eighth Semester Geographical Information System (TU board exam, 2025), TU BCA 2022 Eighth Semester Information Security (TU board exam, 2022), TU BCA 2023 Eighth Semester Information Security (TU board exam, 2023), TU BCA 2024 Eighth Semester Information Security (TU board exam, 2024), TU BCA 2025 Eighth Semester Information Security (TU board exam, 2025), TU BCA 2022 Eighth Semester Machine Learning (TU board exam, 2022), TU BCA 2023 Eighth Semester Machine Learning (TU board exam, 2023), TU BCA 2025 Eighth Semester Machine Learning (TU board exam, 2025), TU BCA 2022 Eighth Semester Operational Research (TU board exam, 2022), TU BCA 2023 Eighth Semester Operational Research (TU board exam, 2023), TU BCA 2024 Eighth Semester Operational Research (TU board exam, 2024) and TU BCA 2025 Eighth Semester Operational Research (TU board exam, 2025). Answers are written for this site; check them against your class notes.