Back to the 2025 paper

Module 3: Classification and Prediction

20257m

Define Classification and Prediction in data mining. Describe the concept of Bayesian Classification with a simple example.

Worked SolutionAI Assisted

Classification & Prediction + Naïve Bayesian Classification

Classification and Prediction — Definitions

  • Classification is a supervised learning process that builds a model from labelled training data and then uses it to assign new/unseen objects to discrete, predefined class labels (e.g., predict whether a loan is low-risk or high-risk). Its output is categorical.
  • Prediction is the general task of estimating unknown values. When the value being predicted is numeric/continuous (e.g., predicting the price of a house), it is called prediction or regression; when the unknown value is a categorical class label, it is classification. Prediction is governed by a mean squared error style loss, whereas classification deals with accuracy/error rate.

Bayesian Classification

Bayesian classification is a statistical classification technique based on Bayes' Theorem. It assigns a tuple XX to the class CiC_i for which the posterior probability P(Ci∣X)P(C_i \mid X) is maximum:

P(Ci∣X)=P(X∣Ci) P(Ci)P(X)P(C_i \mid X) = \frac{P(X \mid C_i)\, P(C_i)}{P(X)}

Because P(X)P(X) is the same for all classes, the maximum a posteriori (MAP) decision rule is:

choose Ci such that P(X∣Ci) P(Ci) is maximum\text{choose } C_i \text{ such that } P(X \mid C_i)\, P(C_i) \text{ is maximum}

  • P(Ci)P(C_i) — prior probability of class CiC_i (estimated from training-data frequencies).
  • P(X∣Ci)P(X \mid C_i) — likelihood of observing XX given the class.

Naïve Bayes — a Simple Example

The naïve assumption is that all attributes are conditionally independent given the class, so:

P(X∣Ci)=∏k=1nP(xk∣Ci)P(X \mid C_i) = \prod_{k=1}^{n} P(x_k \mid C_i)

Example: Classify a fruit by its attributes.

Fruit Colour Shape Taste
Apple Red Round Sweet
Apple Green Round Sweet
Mango Yellow Oval Sweet
Mango Yellow Oval Sour

Let a new fruit have attributes X=(Colour=Yellow, Shape=Oval)X = (\text{Colour} = \text{Yellow},\ \text{Shape} = \text{Oval}). We compute:
P(Mango)=2/4=0.5P(\text{Mango}) = 2/4 = 0.5, P(Apple)=0.5P(\text{Apple}) = 0.5.

  • P(Yellow∣Mango)=2/2=1P(Yellow \mid Mango) = 2/2 = 1, P(Oval∣Mango)=2/2=1P(Oval \mid Mango) = 2/2 = 1
  • P(Yellow∣Apple)=0/2=0P(Yellow \mid Apple) = 0/2 = 0, so P(X∣Apple)=0P(X \mid Apple) = 0.

Score mango = 0.5×(1×1)=0.50.5 \times (1 \times 1) = 0.5; apple score =0= 0. Since 0.5>00.5 > 0, the new fruit is classified as Mango.

Advantages: simple, fast, easily handles high-dimensional data, works well in spam filtering and text classification. Limitation: the independence assumption is often violated in real data.

Similar questions

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.