Artificial Intelligence and Machine Learning: Concepts, Worked Examples and Exam Patterns

Build a clean map of AI, ML and deep learning, then apply it through k-NN and confusion-matrix calculations. Finish with common question styles and traps.

KnowledgeGate Team

Exam prep & CS education

Updated 4 Dec 20265 min read
Artificial Intelligence and Machine Learning: Concepts, Worked Examples and Exam Patterns

AI names a broad class of intelligent tasks; machine learning names methods that fit models from data. The key skill is tracing a labelled dataset through a model calculation and then evaluating the result. A k-nearest-neighbours prediction and a confusion matrix make that path concrete.

Artificial intelligence, machine learning and deep learning: the hierarchy

Artificial intelligence is the umbrella goal of making a system perform tasks associated with intelligent behaviour. Machine learning is an AI approach in which a model learns parameters from data. Deep learning is ML built around neural networks with multiple learned layers.

Not every AI system uses ML. A symbolic system can search or follow hand-written rules without learning from examples. Fundamentals of Artificial Intelligence develops agents and search, AI Technologies and Applications separates technologies, capabilities and applications, and Artificial Intelligence for ICT Exams adds data statistics and tool verification. The AI-versus-ML boundary turns on what humans supply and what, if anything, the system learns.

System

What is supplied by humans

What is learned

Best label

Tax calculator using fixed rules

Tax slabs and calculation rules

Nothing

Rule-based automation

Hand-written chess search system

Search procedure and evaluation rules

Nothing

Symbolic AI

Spam classifier trained on labelled messages

Training examples, labels and features

Classification parameters

Machine learning

Image classifier using a deep neural network

Training images, labels and network design

Layer weights and useful representations

Deep learning

The exam trap is treating automation, AI, ML and deep learning as interchangeable. A fixed tax rule is automated without learning, while a deep neural image classifier is both ML and AI.

Machine learning workflow: data, learning type and model

A dataset contains examples, usually as rows. Input features are written as X, and the target or label as y. A model maps X to a prediction. Training adjusts its parameters to reduce a loss, which measures prediction error.

The training set fits parameters. The validation set helps choose settings or models. The test set stays held back so it estimates performance on unseen data. Letting test information influence training gives an unrealistically favourable result.

The supervision and required output identify the learning type:

  • Supervised learning uses labelled outputs. Spam versus not spam is classification, while predicting a numeric house price is regression.

  • Unsupervised learning has no supplied target label. Grouping customers by similar behaviour is clustering.

  • Reinforcement learning learns through states, actions and rewards. An agent choosing moves in a grid world is a standard example.

Quick scenario drill: predicting pass or fail is classification; predicting a score from 0 to 100 is regression; discovering groups in unlabelled answer patterns is clustering. Identify the output and available supervision, not merely an algorithm name.

k-nearest neighbours: a worked classification example

Consider four labelled training points:

  • A1=(1,1), class A

  • A2=(2,2), class A

  • B1=(4,4), class B

  • B2=(5,4), class B

The query is Q=(3,3). With Euclidean distance and k=3, calculate every distance:

  1. d(Q,A1)=sqrt((3-1)^2+(3-1)^2)=sqrt(4+4)=sqrt(8)=2.828

  2. d(Q,A2)=sqrt((3-2)^2+(3-2)^2)=sqrt(1+1)=sqrt(2)=1.414

  3. d(Q,B1)=sqrt((3-4)^2+(3-4)^2)=sqrt(1+1)=sqrt(2)=1.414

  4. d(Q,B2)=sqrt((3-5)^2+(3-4)^2)=sqrt(4+1)=sqrt(5)=2.236

Sorting from nearest to farthest gives A2, B1, B2, A1. The three nearest neighbours vote A, B and B. Therefore, Q is classified as class B by a 2-to-1 majority.

Feature plane showing Q at (3,3) and four labelled neighbours; its three nearest points give two class B votes and one class A vote.

Three traps are common. k-NN uses the nearest points, not the farthest. Squared Euclidean distance gives the same ranking, but omitting square roots is safe only when every distance is treated consistently. An unnormalised large-scale feature can dominate distance. Equal distances to A2 and B1 cause no final tie because both enter the k=3 set, whose vote is 2-to-1.

Machine learning evaluation: a confusion-matrix worked example

In binary classification, positive and negative are class labels, not moral judgements. A true positive (TP) and true negative (TN) are correct predictions. A false positive (FP) is a negative case predicted positive, while a false negative (FN) is a positive case predicted negative.

For a test set of 20 cases, take TP=8, TN=7, FP=2 and FN=3. First check the total: 8+7+2+3=20.

  • Accuracy =(TP+TN)/20=(8+7)/20=15/20=0.75, or 75%.

  • Precision =TP/(TP+FP)=8/(8+2)=8/10=0.80, or 80%.

  • Recall =TP/(TP+FN)=8/(8+3)=8/11=0.727, or about 72.7%.

  • F1 =2TP/(2TP+FP+FN)=16/(16+2+3)=16/21=0.762, or about 76.2%.

Confusion matrix with TP 8, TN 7, FP 2 and FN 3, followed by accuracy, precision, recall and F1 calculations.

Precision asks how often a positive prediction is correct. Recall asks how many actual positives the model found. If missing a positive is costly, the three false negatives make recall important even with 75% accuracy. A single metric never tells the whole story.

Neural networks, deep learning and generative AI: where they fit

An artificial neuron combines weighted inputs with a bias, then applies an activation function. A layer is a collection of neurons. Training adjusts weights and biases to reduce loss. A deep network has multiple learned layers, so "deep" describes architecture, not a machine that thinks deeply.

Computer vision and natural language processing are application areas. Neural networks are a model family, transformers are an architecture, and large language models learn patterns over tokens. Generative AI produces new content rather than only assigning labels.

AI and ML exam patterns: how concepts are commonly tested

AI and ML concepts are commonly tested through four moves:

  1. Hierarchy or definition: identify that deep learning is within ML, which is within AI, while rule-based AI need not be ML.

  2. Scenario classification: pass or fail is classification, a 0 to 100 score is regression, and grouping unlabelled answer patterns is clustering.

  3. One-step numerical: calculate distances and obtain class B in the k-NN example, or compute recall as 8/11, about 72.7%.

  4. Diagnosis: recognise overfitting, data leakage or a metric that hides the error type that matters.

Use this six-item trap checklist while revising:

  • AI is not synonymous with ML.

  • Classification predicts categories, while regression predicts numeric values.

  • Training accuracy is not test accuracy.

  • High accuracy can hide weak recall for a minority class.

  • An unsupervised task has no supplied target label.

  • Data leakage occurs when test information influences training or feature preparation.

Practise the hierarchy, scenario type, numerical step and error diagnosis separately. Check the current official syllabus or notification for your examination before assigning study weight to AI and ML.

AI and ML short version and next step

Use this six-line revision ladder:

  1. Identify AI versus ML.

  2. Identify supervised, unsupervised or reinforcement learning.

  3. Name the features X and target y.

  4. Execute the model step, such as the k-NN vote that gave class B.

  5. Build the confusion matrix from TP, TN, FP and FN.

  6. Choose and interpret the metric, remembering the example's 75% accuracy and 72.7% recall.

For a broader route through related subjects, explore Coding & Skill Development Courses. If you want a guided sequence across AI, ML and generative AI, the AI & ML for Placements course is the structured next step.