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:
- 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.
- 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.
- 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).
- 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.
- 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
- Choose (odd value such as 3 or 5 avoids ties in two-class problems).
- Compute distance from the query point to every stored point. For two features use Euclidean distance
- Sort distances and keep the smallest.
- Assign the majority class among those neighbours (or average the value in regression).
1.2 Worked Classification (No Calculator Needed)
Query point . Training points: = Class Blue, = Class Red, = Class Red. Take .
| Point | Distance to | Label |
|---|---|---|
| Red | ||
| Blue | ||
| Red |
Result: 2 Red vs 1 Blue → the query is classified Red. With it would be Red as well; with correlated ties a larger odd stabilises the answer.
Effect of : small follows noise closely (overfit); very large 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 , 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.
With independence: . For choosing a class, the denominator 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".
Normalise: .
Result: classify as spam (84.2% posterior). A zero probability is handled with Laplace smoothing, e.g. replace 0 by .
3. Clustering Technique-K-Means
Definition (2 Marks): K-Means is an unsupervised clustering algorithm that partitions unlabelled points into groups by minimising the distance of each point to its cluster centre (centroid).
3.1 Iterative Steps
- Select and place initial centroids.
- Assign every point to the nearest centroid.
- Recompute each centroid as the mean of its assigned points.
- 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: ; ; initial centroids and .
| Iteration | Assignment | New centroids | Sum of squared error |
|---|---|---|---|
| 1 | {1,2} → C1; {8,9,10} → C2 | C1 = 1.5, C2 = 9.0 | |
| 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.
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 | 0.85 | 85% of all decisions correct | |
| Precision | 0.889 | 88.9% of alarms are real defects | |
| Recall | 0.80 | 80% of real defects were caught | |
| F1 | 0.842 | Harmonic balance of the two |
4.2 Worked MAE (Regression)
Predicted crack widths mm; measured mm. Absolute errors ; .
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 by a weight , adds a bias , and passes the sum through an activation function :
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 | Strength/sign of each connection | "Updated during training" |
| Bias | Shifts activation threshold | "Lets neuron fire even at small inputs" |
Worked neuron: inputs , weights , bias , sigmoid activation. Sum ; . 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
- Massive matrix multiplication: one dense layer with 512 inputs, 256 neurons and a batch of 64 examples performs multiply-add operations; a network with dozens of layers and thousands of batches does this repeatedly.
- Independence: outputs for different examples and different neurons are independent, so the work maps naturally onto thousands of GPU cores.
- Memory bandwidth: weights and activations are read in large blocks; GPUs have much higher memory throughput than CPUs.
- 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 image with 16 filters of size in the first layer produces 16 feature maps of about 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 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: .
- 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:
- 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.
- Mechanism (3m): Each neuron computes ; layer outputs feed the next layer; during training the error is propagated backward and weights are updated; deeper layers learn edges → parts → objects.
- 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.
- 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:
- Accuracy compares predictions with actual labels over the whole test set: correct predictions ÷ total predictions.
- 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:
- Precision : of all cases the model flagged as positive, how many were actually positive.
- 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:
- Step 1 — Identify the core operation: every layer computes , i.e. large matrix multiplication.
- 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.
- Step 3 — Note independence: results for different examples and neurons do not depend on each other, so they can be computed simultaneously.
- 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).
- Step 5 — Include gradient computation: back-propagation repeats the same matrix operations, roughly doubling to tripling the work.
- Comparison result: CPU = flexible but slow for deep networks; GPU = specialised but essential for practical training time.
- Examiner result: GPUs make deep learning feasible by executing the parallel matrix arithmetic of training far faster than a CPU.
Practice Questions (Self-Test)
- (2 Marks) Define KNN and state what happens when is too small.
- (2 Marks) What does "naïve" in Naïve Bayes assume? Give one text-classification use.
- (5 Marks) Run K-Means for one more iteration on points
1, 2, 8, 9, 10with centroids1.5, 9.0and report whether it converges. - (5 Marks) For TP=18, FP=2, FN=6, TN=74 compute accuracy, precision, recall and F1.
- (7 Marks) Draw a neuron with three inputs and compute its output for weights , bias , inputs using sigmoid.
- (7 Marks — Predicted) Explain how a CNN can detect fabric defects from camera images, naming convolution, pooling and output stages.