Top Banner Ad

AAI101 — Unit 2: ore AI Concepts ; Machine learning

Table of Contents (26 sections)

AAI101 · Introduction to AI and Prompt Engineering · Unit 2

ore AI Concepts ; Machine learning

Unit Scope & Exam Weightage: Unit 2 turns the "data → pattern → prediction" idea of Unit 1 into concrete algorithms: KNN, Naïve Bayes, K-Means, classification metrics, neural networks, deep learning with GPUs, CNN/computer vision and NLP. The two 2026-27 model papers contain 6 clusters worth 22 marks here. The examiners ask short definitions of K-Means, accuracy and precision, plus 7-mark explanations of deep learning and why it needs GPUs. Being able to work a tiny confusion matrix or a 3-neighbour classification is enough; heavy mathematics is deliberately out of scope.


Front Page: Importance-Wise Topic Roadmap (2026-27 Model Papers)

Priority Topic (Exact Syllabus) PYQs Asked Marks Weightage Tag
1 Deep learning — what makes it 'deep' 1 (2026-27 MP-S1) 7m × 1 High-Yield 7m
2 why it needs GPUs 1 (2026-27 MP-S2) 7m × 1 High-Yield 7m
3 Classification metrics-accuracy 2 (MP-S1, MP-S2) 2m × 2 Repeated Short
4 Clustering Technique-K-Means 1 (2026-27 MP-S1) 2m × 1 Short
5 precision 1 (2026-27 MP-S2) 2m × 1 Short
6 Classification Techniques- KNearest Neighbors (KNN), Naïve Bayes 0 direct — Predicted Algorithm
7 recall, F1 score, MAE Integrated with #3 — Worked Numerical
8 Neural networks — concept of neurons, layers, weights (simple diagram), CNN, Computer vision — how AI sees images (face recognition, medical imaging) 0 direct — Core Concept / Predicted
9 Natural Language Processing (NLP) — how AI understands text and speech Class Activity: Show Google Teachable Machine (teachablemachine.withgoogle.com) — train a simple image classifier in 5 minutes, no code, Branch connect: ECE — image sensors + AI, BT — protein structure prediction (AlphaFold), AG — plant disease detection from photos, TX — fabric defect detection 0 direct — Branch Link / Hands-on

2-Hour Last-Night Survival Checklist:

  1. Learn the two "learning families" with one algorithm each: classification (KNN, Naïve Bayes) predicts a label from labelled data; clustering (K-Means) groups unlabelled data by distance. Write one worked 3-point example for KNN and one two-iteration table for K-Means.
  2. Memorise the confusion-matrix block: TP, FP, FN, TN; accuracy = (TP+TN)/All, precision = TP/(TP+FP), recall = TP/(TP+FN), F1 = 2PR/(P+R), MAE = mean |actual − predicted|. Practise once on TP=40, FP=5, FN=10, TN=45 → accuracy 0.85, precision 0.889, recall 0.80, F1 0.842.
  3. Deep-learning 7m answer: "deep" = several stacked layers that learn features progressively (edges → shapes → objects); draw input → hidden layers → output with weights, and name one application (medical image classification).
  4. GPU 7m answer: training is billions of independent multiply-adds; a CPU has a few powerful cores, a GPU has thousands of simple cores doing matrix operations in parallel. Include one FLOP count: 64 × 512 × 256 × 2 ≈ 16.8 million operations for one dense layer batch.
  5. Keep one branch-specific image example ready: ECE image sensor counts components, AG phone photo of a leaf → diseased/healthy (Teachable Machine), TX camera → fabric defect, BT AlphaFold → protein structure, medical imaging → tumour boundary.

1. Classification Techniques- KNearest Neighbors (KNN)

Definition (2 Marks): K-Nearest Neighbors (KNN) is a supervised classifier that assigns a new point the label most common among its k closest training points. It stores all training examples and does no elaborate training; the distance calculation happens at prediction time.

1.1 Algorithm

  1. Choose kk (odd value such as 3 or 5 avoids ties in two-class problems).
  2. Compute distance from the query point to every stored point. For two features use Euclidean distance
d=(x1−x2)2+(y1−y2)2d=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}
  1. Sort distances and keep the kk smallest.
  2. Assign the majority class among those neighbours (or average the value in regression).

1.2 Worked Classification (No Calculator Needed)

Query point (2,2)(2,2). Training points: A(1,1)A(1,1) = Class Blue, B(2,3)B(2,3) = Class Red, C(4,2)C(4,2) = Class Red. Take k=3k=3.

Point Distance to (2,2)(2,2) Label
B(2,3)B(2,3) 02+12=1.00\sqrt{0^2+1^2}=1.00 Red
A(1,1)A(1,1) 12+12=1.41\sqrt{1^2+1^2}=1.41 Blue
C(4,2)C(4,2) 22+02=2.00\sqrt{2^2+0^2}=2.00 Red

Result: 2 Red vs 1 Blue → the query is classified Red. With k=1k=1 it would be Red as well; with correlated ties a larger odd kk stabilises the answer.

Effect of kk: small kk follows noise closely (overfit); very large kk underfits and ignores local structure. KNN is slow at prediction when the dataset is large because every saved point must be compared.

Examiner Tip: A 7-mark KNN answer should state: lazy learner, distance metric, choose odd kk, vote/average, worked 3-row table, and one limitation. Merely saying "classifies by neighbours" scores 2 marks.


2. Naïve Bayes

Definition: Naïve Bayes is a probabilistic classifier based on Bayes' theorem that assumes features are conditionally independent given the class. The assumption is rarely exactly true (hence "naïve") but works well for text and spam filtering.

P(class∣features)=P(features∣class) P(class)P(features)P(\text{class}\mid \text{features})=\frac{P(\text{features}\mid \text{class})\,P(\text{class})}{P(\text{features})}

With independence: P(features∣c)=∏jP(xj∣c)P(\text{features}\mid c)=\prod_j P(x_j\mid c). For choosing a class, the denominator P(features)P(\text{features}) is common and can be ignored.

Worked case: 40% of messages are spam. The word "offer" appears in 80% of spam and 10% of genuine mail. A new message contains "offer".

P(spam) P(offer∣spam)=0.4×0.8=0.32P(\text{spam})\,P(\text{offer}\mid\text{spam})=0.4\times0.8=0.32 P(ham) P(offer∣ham)=0.6×0.1=0.06P(\text{ham})\,P(\text{offer}\mid\text{ham})=0.6\times0.1=0.06

Normalise: P(spam∣offer)=0.32/(0.32+0.06)=0.842P(\text{spam}\mid\text{offer})=0.32/(0.32+0.06)=0.842.

Result: classify as spam (84.2% posterior). A zero probability is handled with Laplace smoothing, e.g. replace 0 by (0+1)/(n+2)(0+1)/(n+2).


3. Clustering Technique-K-Means

Definition (2 Marks): K-Means is an unsupervised clustering algorithm that partitions nn unlabelled points into kk groups by minimising the distance of each point to its cluster centre (centroid).

3.1 Iterative Steps

  1. Select kk and place kk initial centroids.
  2. Assign every point to the nearest centroid.
  3. Recompute each centroid as the mean of its assigned points.
  4. Repeat steps 2–3 until assignments stop changing or a fixed iteration limit is reached.

3.2 Worked Two-Iteration Example

Points on one axis: 1,2,8,9,101, 2, 8, 9, 10; k=2k=2; initial centroids 22 and 99.

Iteration Assignment New centroids Sum of squared error
1 {1,2} → C1; {8,9,10} → C2 C1 = 1.5, C2 = 9.0 0.52+0.52+12+02+12=2.50.5^2+0.5^2+1^2+0^2+1^2=2.5
2 {1,2} → C1; {8,9,10} → C2 C1 = 1.5, C2 = 9.0 (unchanged) 2.5

Result: convergence after iteration 1 because assignments no longer change. This is how a TE/textile class could group fabric-defect images into "minor" and "severe" without labels.

Examiner Tip: State that the final clusters depend on the initial centroids; good practice is to run several starts and choose the lowest error. This sentence converts a 2m definition into a high-scoring 7m answer.


4. Classification metrics-accuracy, precision, recall, F1 score, MAE

Confusion matrix: a 2×2 table of predicted versus actual outcomes. TP = true positive, FP = false positive (type I), FN = false negative (type II), TN = true negative.

Accuracy=TP+TNTP+TN+FP+FNPrecision=TPTP+FPRecall=TPTP+FN\text{Accuracy}=\frac{TP+TN}{TP+TN+FP+FN}\qquad \text{Precision}=\frac{TP}{TP+FP}\qquad \text{Recall}=\frac{TP}{TP+FN} F1=2 (Precision)(Recall)Precision+RecallMAE=1n∑i=1n∣yi−y^i∣F1=\frac{2\,(\text{Precision})(\text{Recall})}{\text{Precision}+\text{Recall}}\qquad \text{MAE}=\frac{1}{n}\sum_{i=1}^{n}\left|y_i-\hat{y}_i\right|

4.1 Worked Confusion Matrix

A defect detector on 100 castings reports TP=40, FP=5, FN=10, TN=45.

Metric Substitution Value Meaning
Accuracy (40+45)/100(40+45)/100 0.85 85% of all decisions correct
Precision 40/(40+5)40/(40+5) 0.889 88.9% of alarms are real defects
Recall 40/(40+10)40/(40+10) 0.80 80% of real defects were caught
F1 2(0.889)(0.80)/(0.889+0.80)2(0.889)(0.80)/(0.889+0.80) 0.842 Harmonic balance of the two

4.2 Worked MAE (Regression)

Predicted crack widths y^=2,4,6\hat{y} = 2, 4, 6 mm; measured y=3,5,5y = 3, 5, 5 mm. Absolute errors =1,1,1=1,1,1; MAE=3/3=1 mm\text{MAE}=3/3=\mathbf{1\,mm}.

Examiner Tip: Accuracy misleads when classes are unbalanced: if only 1 in 100 castings is defective, always answering "good" gives 99% accuracy but zero defect detection. In safety questions prefer recall or F1.


5. Neural networks — concept of neurons, layers, weights (simple diagram)

Artificial neuron: a computing unit that multiplies each input xix_i by a weight wiw_i, adds a bias bb, and passes the sum through an activation function ϕ\phi:

y=ϕ ⁣(∑iwixi+b)y=\phi\!\left(\sum_i w_i x_i + b\right)

The weights store what the network has learned; the activation decides whether the neuron fires.

%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '16px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart LR
    X1["Input x1<br/>pixel / feature"] --> S["Σ wixi + b<br/>Neuron"]
    X2["Input x2"] --> S
    X3["Input x3"] --> S
    S --> A["Activation φ<br/>ReLU / sigmoid"]
    A --> O["Output y<br/>next layer or class"]
Part Role Exam phrase
Input layer Receives features "No computation, only data"
Hidden layer(s) Learns intermediate features "Edges → parts → whole object"
Output layer Produces class score or number "Softmax for classes, linear for regression"
Weights wiw_i Strength/sign of each connection "Updated during training"
Bias bb Shifts activation threshold "Lets neuron fire even at small inputs"

Worked neuron: inputs (1,0,2)(1, 0, 2), weights (0.5,−1,0.7)(0.5, -1, 0.7), bias −0.2-0.2, sigmoid activation. Sum =0.5+0+1.4−0.2=1.7=0.5+0+1.4-0.2=1.7; σ(1.7)=1/(1+e−1.7)≈0.845\sigma(1.7)=1/(1+e^{-1.7})\approx0.845. Output ≈ 0.845.


6. Deep learning — what makes it 'deep', why it needs GPUs

Deep learning (2 Marks): machine learning based on neural networks with many stacked layers ("deep" = multiple hidden layers). Each layer transforms the previous representation into a more abstract one, so the network learns features automatically instead of relying on a human to design them.

6.1 What "Deep" Changes

Stage of a face-recognition net Representation learned
Layer 1 Edges and colour boundaries
Layer 2 Eyes, nose, mouth corners
Layer 3 Face parts combined
Output Identity / "face present" score

6.2 Why It Needs GPUs

  1. Massive matrix multiplication: one dense layer with 512 inputs, 256 neurons and a batch of 64 examples performs 64×512×256×2≈16.8 million64\times512\times256\times2\approx\mathbf{16.8\,million} multiply-add operations; a network with dozens of layers and thousands of batches does this repeatedly.
  2. Independence: outputs for different examples and different neurons are independent, so the work maps naturally onto thousands of GPU cores.
  3. Memory bandwidth: weights and activations are read in large blocks; GPUs have much higher memory throughput than CPUs.
  4. Practical effect: training that takes weeks on a CPU can finish in hours or days on a GPU, making experimentation possible.
Feature CPU GPU
Cores Few (4–32), complex Thousands, simple
Best at Sequential control, branching Parallel matrix/vector arithmetic
Neural-network role Data preparation, orchestration Forward/backward passes
Limitation for DL Too slow for large batches Higher cost and power draw

Examiner Tip: "Deep" must be defined by layer count and learned representations, not by "large data" alone. For the GPU answer, always connect hardware to the arithmetic: parallel multiply-adds → shorter training time.

After-Topic PYQ (2026-27 Model Paper (Set 1), 7 Marks): "Explain Deep learning — what makes it 'deep' with its definition, mechanism, and one worked application from ore AI Concepts ; Machine learning."
Worked answer: See Sections 5–6. Definition: neural network with many hidden layers. Mechanism: weighted sums + activation in each layer; errors flow backward to update weights; deeper layers build more abstract features. Worked application: plant disease detection from a leaf photo — layer 1 finds green/brown edges, layer 2 spots lesion shapes, later layers combine them, output gives "infected with probability 0.91". GPUs make the training feasible.


7. CNN and Computer vision — how AI sees images

CNN (Convolutional Neural Network): a deep network that slides small learnable filters over an image. A filter detects local patterns (edges, texture) and shares its weights across the image, which drastically reduces parameters compared with a fully connected network.

%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '16px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart LR
    I["Input image<br/>pixels"] --> C["Convolution<br/>3×3 filters → feature maps"]
    C --> R["ReLU<br/>keep positive signals"]
    R --> P["Pooling<br/>reduce size, keep strong features"]
    P --> F["Flatten + Dense<br/>class scores"]
    F --> O["Output<br/>face / defect / tumour"]
Application Input Learned signal Output
Face recognition Camera frame Face embedding Identity match
Medical imaging MRI/CT slice Tissue boundary texture Tumour outline / benign-malignant score
AG plant disease Leaf photograph Spot colour and shape "Blight detected"
ECE image sensors + AI Sensor array image Component geometry Missing/defective part
TX fabric defect Loom camera frame Thread irregularity Defect class

Filter count check: a 32×3232\times32 image with 16 filters of size 3×33\times3 in the first layer produces 16 feature maps of about 30×3030\times30 values (assuming no padding) — a compact representation for the next layer.


8. Natural Language Processing (NLP) — how AI understands text and speech

NLP: the branch of AI that lets machines read, interpret and generate human language. Text is split into tokens, tokens become numeric vectors (embeddings), and a model predicts the next token, a label or an intent.

Stage Operation Example
Tokenise Split text into words/sub-words "pump is faulty" → [pump, is, faulty]
Normalise Lowercase, remove noise "Pump" → "pump"
Embed Map tokens to numbers "faulty" → vector of 768 numbers
Model Learn context / classify Transformer or simpler classifier
Decode Produce label or text Intent = "maintenance request"

Speech path: microphone waveform → frames → acoustic features → speech-to-text → intent classifier → reply or action. This is exactly what a voice assistant does.

8.1 Class Activity: Show Google Teachable Machine (teachablemachine.withgoogle.com) — train a simple image classifier in 5 minutes

No code steps: (1) open the site and choose "Image project"; (2) create two classes, e.g. "healthy leaf" and "diseased leaf"; (3) hold up 20 examples of each to the webcam; (4) train the model; (5) test with a fresh leaf image and note the confidence score; (6) discuss what happens if the lighting changes — the learned pattern is tied to the training conditions.

Examiner Tip: In branch-connect answers, always write the chain "sensor/image → learned feature → decision". For BT mention AlphaFold (protein structure prediction from sequence); for AG mention plant disease detection from photos; for TX mention fabric defect detection.


Solved Exam-Ready Questions (Verbatim Model-Paper Wording)

Solved Q1 (2026-27 Model Paper (Set 1), 2 Marks)

Q: "Define Clustering Technique-K-Means and state its role in ore AI Concepts ; Machine learning."

Solution:

  • Definition: K-Means is an unsupervised clustering method that divides unlabelled data into kk groups by repeatedly assigning each point to the nearest centroid and recomputing centroids as cluster means.
  • Role: It provides the clustering branch of machine learning: when labels are absent, it discovers hidden structure (e.g., normal vs abnormal vibration patterns) instead of predicting a supplied label.

Solved Q2 (2026-27 Model Paper (Set 1), 2 Marks)

Q: "Define Classification metrics-accuracy and state its role in ore AI Concepts ; Machine learning."

Solution:

  • Definition: Accuracy is the fraction of correct predictions among all predictions: (TP+TN)/(TP+TN+FP+FN)(TP+TN)/(TP+TN+FP+FN).
  • Role: It is the first, simplest summary of classifier quality; it tells how often the model is right, but must be supplemented by precision and recall when classes are unbalanced.

Solved Q3 (2026-27 Model Paper (Set 1), 7 Marks)

Q: "Explain Deep learning — what makes it 'deep' with its definition, mechanism, and one worked application from ore AI Concepts ; Machine learning."

Solution:

  1. Definition (1m): Deep learning uses neural networks with several hidden layers; "deep" refers to this stack of layers and the progressively abstract features they learn.
  2. Mechanism (3m): Each neuron computes y=ϕ(∑wixi+b)y=\phi(\sum w_i x_i+b); layer outputs feed the next layer; during training the error is propagated backward and weights are updated; deeper layers learn edges → parts → objects.
  3. Worked application (2m): plant disease detection from photos: input leaf image, first convolution layer detects coloured edges, next layers detect lesion shapes, dense output gives "diseased, confidence 0.91"; the farmer receives a spray decision.
  4. Result (1m): No human-designed lesion rule was written — the features were learned, which is the hallmark of deep learning.

Solved Q4 (2026-27 Model Paper (Set 2), 2 Marks)

Q: "List the two scored features of Classification metrics-accuracy expected in ore AI Concepts ; Machine learning."

Solution:

  1. Accuracy compares predictions with actual labels over the whole test set: correct predictions ÷ total predictions.
  2. It ranges from 0 to 1 (0–100%) and is unreliable for highly imbalanced data, where precision/recall or F1 should be reported.

Solved Q5 (2026-27 Model Paper (Set 2), 2 Marks)

Q: "List the two scored features of precision expected in ore AI Concepts ; Machine learning."

Solution:

  1. Precision =TPTP+FP=\dfrac{TP}{TP+FP}: of all cases the model flagged as positive, how many were actually positive.
  2. Low precision means many false alarms; in a defect detector it answers "when the machine cries defect, can I trust it?"

Solved Q6 (2026-27 Model Paper (Set 2), 7 Marks)

Q: "Derive or outline why it needs GPUs step by step, include a suitable comparison, and state the examiner result for ore AI Concepts ; Machine learning."

Solution:

  1. Step 1 — Identify the core operation: every layer computes Wx+bW x + b, i.e. large matrix multiplication.
  2. Step 2 — Count the work: 64 examples × 512 inputs × 256 neurons × 2 (multiply + add) ≈ 16.8 million operations for one layer; dozens of layers × thousands of batches give billions per epoch.
  3. Step 3 — Note independence: results for different examples and neurons do not depend on each other, so they can be computed simultaneously.
  4. Step 4 — Compare hardware: a CPU has few complex cores suited to sequential logic; a GPU has thousands of simpler cores and high memory bandwidth suited to parallel arithmetic (Section 6.2 table).
  5. Step 5 — Include gradient computation: back-propagation repeats the same matrix operations, roughly doubling to tripling the work.
  6. Comparison result: CPU = flexible but slow for deep networks; GPU = specialised but essential for practical training time.
  7. Examiner result: GPUs make deep learning feasible by executing the parallel matrix arithmetic of training far faster than a CPU.

Practice Questions (Self-Test)

  1. (2 Marks) Define KNN and state what happens when kk is too small.
  2. (2 Marks) What does "naïve" in Naïve Bayes assume? Give one text-classification use.
  3. (5 Marks) Run K-Means for one more iteration on points 1, 2, 8, 9, 10 with centroids 1.5, 9.0 and report whether it converges.
  4. (5 Marks) For TP=18, FP=2, FN=6, TN=74 compute accuracy, precision, recall and F1.
  5. (7 Marks) Draw a neuron with three inputs and compute its output for weights (0.5,−1,0.7)(0.5,-1,0.7), bias −0.2-0.2, inputs (1,0,2)(1,0,2) using sigmoid.
  6. (7 Marks — Predicted) Explain how a CNN can detect fabric defects from camera images, naming convolution, pooling and output stages.