DWDMData Warehousing & Mining
Unit IV · 9 Lectures

Teaching Machines to Label

Classification predicts a category from labelled data. Build decision trees by the purest split, classify with k nearest neighbours, reason with Bayes, and measure it all honestly — then test yourself with 10 questions.

Course IT314 B
Unit IV
Type Supervised
Outcome CO3

What you'll master

INTERACTIVE
0
Algorithms
0
Live demos
0
Concept videos
0
Quiz questions
01

The Classification Problem

Learn a mapping, then predict

Given training records with a known class label, a classifier learns a model that maps attributes → class. New, unlabelled records are then assigned a class. It's supervised learning because the labels guide training.

General approach: split into train/test → build the model on training data → predict on the test set → evaluate accuracy → deploy.

Evaluating a classifier

  • Confusion matrix — TP, FP, TN, FN counts.
  • Accuracy = (TP+TN)/all; error rate = 1 − accuracy.
  • Precision / Recall / F1 — for imbalanced data.
  • Holdout, random subsampling, k-fold cross-validation for honest estimates.
Characterization

Summarise the general traits of a target class.

Decision boundary

The surface a model draws to separate classes.

Overfitting

A model that memorises training noise and fails to generalise.

Ensemble

Combine many models (bagging, boosting, random forest) for accuracy.

02

Decision Trees & the Best Split

A decision tree splits the data with attribute tests, choosing at each node the split that makes the children purest. Purity is measured by Gini or entropy; information gain is the drop in entropy after a split. Slide the class mix and watch impurity respond — purest (0) at the ends, most impure (max) at a 50/50 mix.

Impurity calculatorGini & entropy of a node
Class mix — % of class A in the node50%
Gini impurity
0.500
Entropy (bits)
1.000
Read it: a node that is all one class has Gini = 0 and entropy = 0 (a pure leaf). A 50/50 node is maximally impure (Gini 0.5, entropy 1 bit). The tree picks the attribute test that lowers impurity the most — that drop is the information gain.
Attribute test conditions

Binary, multiway, or threshold splits on nominal, ordinal or continuous attributes.

Best-split measures

Gini index, entropy/information gain, gain ratio — pick the attribute that purifies most.

Induction (Hunt's algorithm)

Recursively split nodes until pure or a stop condition; then prune to avoid overfitting.

03

k-Nearest Neighbours

KNN is a lazy learner — it stores the training data and classifies a new point by a majority vote of its k closest neighbours. Click anywhere to drop a query point; lines connect it to its k neighbours and it takes the majority colour. Slide k and watch the verdict change.

KNN classifierclick the plot to place a query point
k — number of neighbours5
Class A votes
Class B votes
Try it: click near the boundary between the two clusters and toggle k — a small k follows local noise, a large k smooths the decision. Choosing k is the key trade-off in KNN.
04

Bayes, Belief Networks & Ensembles

Naïve Bayes

Applies Bayes' theorem assuming features are conditionally independent given the class. Fast, surprisingly accurate, needs little data.

Bayes' theorem

P(class∣x) ∝ P(x∣class)·P(class). Pick the class with the highest posterior probability.

Bayesian belief networks

A graph of variables with conditional dependencies — relaxes the naïve independence assumption to model real relationships.

Lazy vs eager

KNN is lazy (no model until query time); trees and Bayes are eager (build a model up front).

Accuracy & error measures

Accuracy, error rate, precision, recall, F-measure; cross-validation gives a reliable estimate.

Ensemble methods

Bagging (e.g. random forest), boosting (e.g. AdaBoost) and stacking combine weak models into a strong one.

05

Watch the Concepts

Clear explainers from StatQuest with Josh Starmer for the three classifiers in this unit.

StatQuestDecision & Classification TreesHow splits and impurity build a tree.
StatQuestNaïve Bayes, Clearly ExplainedBayes' theorem for classification.
StatQuestK-Nearest NeighboursClassify by the nearest k points.

Videos are embedded from YouTube and belong to their creators. If a frame is blank, your network may block YouTube.

06

Unit IV Quiz — 10 Questions

Test yourself: Classification0 / 10