SEM 6 › Data Mining › Week 04
Data Mining · Week 04

Data Reduction & Discretization

Make the dataset smaller without changing what it tells you — cubes, attribute selection, compression, histograms, binning and concept hierarchies.

ITE34321 video · 10 min📄 week 4.pdf

▶Lecture videos

Click any timestamp — here or inside the notes — to jump the video to that moment. Your position is remembered.

1Why reduce data at all?

Real datasets are huge — millions of rows and hundreds of columns. Mining algorithms on such data are slow and need a lot of memory. Data reduction produces a much smaller version of the dataset that still gives the same (or almost the same) analytical results.

The one-sentence definition

Data reduction = obtaining a reduced representation of the dataset that is much smaller in volume but keeps the integrity of the original data, so mining it is more efficient and the results barely change.

Two benefits are named in the notes:

  1. Less time and memory needed by data-mining algorithms.
  2. Data becomes easier to visualise.

Where this fits — the four preprocessing tasks

This lesson is the third member of the data-preprocessing family introduced in Week 3:

Task What it does Example
Data cleaning Removes noise, fixes inconsistencies Filling missing ages, smoothing noisy prices
Data integration Merges data from multiple sources into one coherent store Combining branch databases into a data warehouse
Data transformation Converts data into a suitable form Normalisation (helps distance-based algorithms)
Data reduction ← this week Shrinks the data size Aggregating, dropping redundant features, clustering

The five data-reduction strategies

Memorise these five — they are the outline of the whole lesson:

Data cube aggregationAttribute subset selectionDimensionality reductionNumerosity reductionDiscretization & concept hierarchies
Strategy Idea in plain words
Data cube aggregation Apply aggregation (sum, count…) while building a data cube — store summaries, not every transaction.
Attribute subset selection Detect and remove irrelevant, weakly relevant or redundant attributes (columns).
Dimensionality reduction Use encoding mechanisms to compress the data (e.g. wavelets, PCA).
Numerosity reduction Replace the data by a smaller representation — a model (parametric) or histograms / clusters / samples (non-parametric).
Discretization & concept hierarchy generation Replace raw values by ranges or higher-level concepts (e.g. age 23 → "youth").
Exam focus

"List and briefly explain the strategies for data reduction" is a classic question. Write all five with one line each — exactly the table above.

2Data cube aggregation

A data cube stores multidimensional aggregated information. (Cubes are covered in detail in Week 5 – Data Warehousing; here you only need the idea.)

Picture sales data with three dimensions — item type, branch and year. Instead of storing every single sale, each cell of the cube holds an aggregate value (e.g. total sales of computers at Branch B in 2008).

Branch A Branch B Branch C
Home entertainment 568 750 150
Computer 680 952 31
Phone 1,000 512 290
Security 38 580 7

One "slice" of a sales cube: annual sales per item type for each branch (values illustrative).

  • Each attribute can have a concept hierarchy — e.g. branches can be grouped into regions based on their address — so you can analyse at multiple levels of abstraction.
  • Cubes give fast access to pre-computed, summarised data, which benefits both OLAP (on-line analytical processing) and data mining.
Why it reduces data

If the analysis only needs annual totals per branch, keeping quarterly or per-transaction rows is waste. Aggregating to the level you need shrinks the data massively with no loss for that task.

3Attribute subset selection

Datasets may contain hundreds of attributes, many irrelevant or redundant.

The notes' example

Task: predict whether a customer will buy a new CD when told about a sale. - Relevant: age, music taste - Irrelevant: telephone number

Why not keep everything? Leaving out relevant attributes or keeping irrelevant ones confuses the mining algorithm → poor-quality patterns. A domain expert could pick attributes by hand, but that is slow and hard when the data's behaviour is not well known.

Goal

Find the minimum set of attributes such that the probability distribution of the data classes is as close as possible to the distribution obtained using all attributes.

Extra benefit: fewer attributes in the discovered patterns → patterns are easier to understand.

Heuristic (greedy) methods

Trying every subset of n attributes means 2n possibilities — impossible for large n. So we use greedy heuristics: at each step make the choice that looks best right now (a locally optimal choice) hoping it leads to a globally optimal solution. In practice they come close to the optimum.

The four basic methods (Figure 3-2 in the notes):

Method How it works Example with
Stepwise forward selection Start with an empty set. Repeatedly add the best remaining attribute. {} → {A1} → {A1, A4} → {A1, A4, A6}
Stepwise backward elimination Start with all attributes. Repeatedly remove the worst one. {A1…A6} → {A1, A3, A4, A5, A6} → {A1, A4, A5, A6} → {A1, A4, A6}
Combined forward + backward Each step adds the best and removes the worst. —
Decision tree induction Build a decision tree; attributes that appear in the tree form the reduced set; those that never appear are irrelevant. Tree tests A4, A1, A6 → {A1, A4, A6}
How to remember

Forward = grow from nothing. Backward = shrink from everything. Decision tree = "whatever the tree bothered to use".

4Dimensionality reduction

Here data encoding or transformations are applied to get a compressed representation of the original data.

Lossless

The original data can be reconstructed exactly from the compressed data — no information lost.

Example: string compression algorithms (like ZIP).

Lossy

Only an approximation of the original can be reconstructed.

Two popular, effective methods: - Wavelet transforms - Principal Components Analysis (PCA)

  • Wavelet transform – converts the data vector into a vector of wavelet coefficients; keeping only the strongest coefficients gives a compressed approximation.
  • PCA – finds a small number of new axes (principal components) that capture most of the variation in the data, then represents each record using only those few components.
Exam focus

Be able to define lossless vs lossy and name wavelet transforms and PCA as the two popular lossy methods — that's what the notes emphasise.

5Numerosity reduction

Replace the data with an alternative, smaller representation. Two families:

Parametric methods

A model estimates the data, so you store only the model parameters (plus maybe outliers) instead of the data.

  • Regression
  • Log-linear models (estimate discrete multidimensional probability distributions)

Non-parametric methods

No model is assumed; store a reduced version of the data itself.

  • Histograms
  • Clustering
  • Sampling

Regression

In linear regression the data are modelled to fit a straight line:

y = w x + b
  • y = response variable, x = predictor variable
  • w (slope) and b (intercept) are the regression coefficients.

So instead of storing 10,000 (x, y) pairs you store just two numbers, w and b. That's the reduction.

Histograms

Histograms use binning to approximate the data distribution — a very popular form of data reduction. A histogram for attribute A splits A's values into disjoint subsets called buckets.

  • Singleton bucket – a bucket holding just one attribute-value/frequency pair.
  • Usually buckets represent continuous ranges of the attribute.

Partitioning rules — know all four:

Rule How buckets are formed
Equal-width Every bucket has the same range width.
Equal-frequency (equi-depth) Every bucket holds roughly the same number of (contiguous) values.
V-Optimal Of all possible histograms with the given number of buckets, the one with the least variance (histogram variance = weighted sum of the original values each bucket represents, weight = number of values in the bucket).
MaxDiff Look at the difference between each pair of adjacent sorted values. Put a bucket boundary at the β − 1 largest differences, where β = number of buckets wanted.

We work through all of these with numbers in section 7.

Clustering and sampling (for completeness)

  • Clustering – group similar records into clusters; store only the cluster representations (e.g. centre + diameter) instead of every record.
  • Sampling – represent a large dataset by a much smaller random sample (e.g. simple random sample without/with replacement, cluster sample, stratified sample).

6Discretization & concept hierarchies

Discretization reduces the number of values of a continuous attribute by dividing its range into intervals. Interval labels then replace the actual values.

Worked example

Ages 13, 15, 16, 19, 22, 25, 33, 35, 46, 52 → replace with labels "10–19", "20–29", "30–39", "40+". Ten distinct values become four labels — the data is simpler and the mining results become a concise, knowledge-level representation.

Ways to classify discretization methods

Basis Type Meaning
Uses class information? Supervised Yes — uses the class labels to choose intervals
Unsupervised No class information used (e.g. plain binning)
Direction Top-down (splitting) Find one or a few split points (cut points) to split the whole range, then repeat recursively on each interval
Bottom-up (merging) Start with all values as potential split points, remove some by merging neighbouring values into intervals, repeat recursively

Concept hierarchies

Doing discretization recursively on an attribute gives a hierarchical (multiresolution) partitioning — a concept hierarchy. It lets you mine at multiple levels of abstraction.

A concept hierarchy replaces low-level concepts (numeric age values) with higher-level concepts (youth, middle-aged, senior).

Figure 3-3 — a concept hierarchy for price:

                        ($0 … $1000]
      ┌──────────┬───────────┼───────────┬────────────┐
 ($0…$200]  ($200…$400]  ($400…$600]  ($600…$800]  ($800…$1000]
  ┌───┴───┐   ┌───┴───┐     …            …            …
($0…$100] ($100…$200] ($200…$300] ($300…$400] …

Why bother, if detail is lost?

  • Generalised data is more meaningful and easier to interpret.
  • Gives a consistent representation of results across multiple mining tasks.
  • Mining a reduced dataset needs fewer I/O operations → more efficient.
Important

Because of these benefits, discretization and concept hierarchies are applied before mining as a preprocessing step, not during mining. More than one hierarchy can be defined for the same attribute to suit different users.

Link

Discretization is itself a form of numerosity reduction, and it is very useful for automatically generating concept hierarchies.

7Binning: equal-width vs equal-depth

The lecture video opens with why: data mining looks for hidden frequent patterns. If an attribute has a very large range of values, the same exact value rarely repeats, so patterns are hard to find. Breaking the range into bins (partitions) makes values "collide" so frequent patterns appear 00:00.

Equal-width partitioning (uniform grid) 00:37

Divide the range into N intervals of equal size. If A is the lowest value and B is the highest:

Width W = (B − A) / N

Bins: [A, A+W), [A+W, A+2W), … up to B. Simple and straightforward.

Weakness — outliers 01:18

If B is an outlier (one huge value), B − A becomes huge, so W becomes huge, and almost all normal data falls into one or two bins. Skewed data is not handled well.

Equal-depth (equal-frequency) partitioning 01:44

Divide into N intervals each containing approximately the same number of samples. Good data scaling; but managing categorical attributes can be tricky.

Equal-width example — temperatures into 7 bins 02:17

Temperatures (sorted): 64, 65, 68, 69, 70, 71, 72, 72, 75, 75, 80, 81, 83, 85

Step 1 – width: W = (85 − 64) / 7 = 21 / 7 = 3

Step 2 – bins and counts:

Bin Values Count
64 – <67 64, 65 2
67 – <70 68, 69 2
70 – <73 70, 71, 72, 72 4
73 – <76 75, 75 2
76 – <79 — 0
79 – <82 80, 81 2
82 – 85 83, 85 2

Notice the 76–79 bin is empty — with equal width that is perfectly possible, as the lecturer points out 03:04.

Equal-depth example — prices into 3 bins 03:26

Prices: 4, 8, 9, 15, 21, 21, 24, 25, 26, 28, 29, 34

Step 1 – sort (already sorted). Step 2 – count: 12 values. Step 3 – depth: 12 / 3 = 4 values per bin.

Bin Values
Bin 1 4, 8, 9, 15
Bin 2 21, 21, 24, 25
Bin 3 26, 28, 29, 34

8Smoothing noisy data with bins

Data can contain noise (random errors). After binning, we can smooth each bin 04:16. Using the price bins above:

1. Smoothing by bin means 04:30

Replace every value in a bin by the bin's mean.

Bin Values Mean Smoothed
1 4, 8, 9, 15 36/4 = 9 9, 9, 9, 9
2 21, 21, 24, 25 91/4 = 22.75 ≈ 23 23, 23, 23, 23
3 26, 28, 29, 34 117/4 = 29.25 ≈ 29 29, 29, 29, 29

2. Smoothing by bin medians 05:07

Same idea but replace by the median.

Bin Median Smoothed
1 (8+9)/2 = 8.5 8.5, 8.5, 8.5, 8.5
2 (21+24)/2 = 22.5 22.5, 22.5, 22.5, 22.5
3 (28+29)/2 = 28.5 28.5, 28.5, 28.5, 28.5

3. Smoothing by bin boundaries 05:18

The minimum and maximum of each bin are its boundaries. Every value is replaced by the closest boundary; the boundaries themselves stay.

Bin Boundaries Reasoning Smoothed
1 4 and 15 8 → closer to 4 (4 away vs 7); 9 → closer to 4 (5 vs 6) 4, 4, 4, 15
2 21 and 25 21 stays; 24 → closer to 25 21, 21, 25, 25
3 26 and 34 28 → 26 (2 vs 6); 29 → 26 (3 vs 5) 26, 26, 26, 34
🧪 Try it — Binning & smoothing lab

Change anything — the bins, the calculation steps and the smoothed values update instantly. Try adding an outlier like 300 with equal-width to see why outliers are a problem.

Exam focus

This exact style of question (sort → partition into equal-depth bins → smooth by means / boundaries) is very common. Always show the sorted data, the depth calculation, each bin, and the replaced values. If a value is exactly in the middle, state which boundary you chose.

9Histogram partitioning — a full worked example

The video then applies the histogram rules 06:29. Equal-width and equal-frequency work exactly like the binning above; V-Optimal chooses the partition with the least histogram variance; MaxDiff cuts at the β − 1 largest adjacent differences 07:21.

Ages into 3 buckets (β = 3) 07:54

Ages (sorted, 20 values): 13, 15, 16, 16, 19, 20, 21, 22, 22, 25, 30, 33, 35, 35, 36, 40, 45, 46, 52, 70

(a) Equal-width: W = (70 − 13) / 3 = 57 / 3 = 19

Bucket Values Count
13 – <32 13, 15, 16, 16, 19, 20, 21, 22, 22, 25, 30 11
32 – <51 33, 35, 35, 36, 40, 45, 46 7
51 – 70 52, 70 2

(b) Equal-depth: 20 / 3 ≈ 7 values per bucket

Bucket Values
1 13, 15, 16, 16, 19, 20, 21
2 22, 22, 25, 30, 33, 35, 35
3 36, 40, 45, 46, 52, 70

(c) MaxDiff: need β − 1 = 2 largest adjacent differences.

Differences between neighbours: 15−13=2, 16−15=1, 0, 3, 1, 1, 1, 0, 3, 5 (25→30), 3, 2, 0, 1, 4, 5, 1, 6 (46→52), 18 (52→70)

Two largest: 18 (between 52 and 70) and 6 (between 46 and 52) → cut there.

Bucket Values
1 13 … 46 (18 values)
2 52
3 70

MaxDiff isolates the unusual values (52 and 70) — the cuts go where the data has natural gaps.

How the lecturer finds MaxDiff values 09:05

"For each pair of data elements we take the difference… out of this we select the 2 maximum differences." In the lecturer's own dataset the two largest gaps were 55 → 62 (7) and 29 → 35 (6), giving buckets ending at 29, then 35–55, then 62–65 10:00.

10Also asked in self-assessments: entropy-based discretization and the 3-4-5 rule

These two methods aren't in this week's PDF, but the 2024 cohort's Self-Assessment 4 asked about them (they're from the Han & Kamber textbook). Learn the idea and one example of each.

Entropy-based discretization (supervised)

Idea

Use the class labels to choose the split point T that makes the two intervals as pure as possible, i.e. the one with the lowest expected information (equivalently, the highest information gain):

I(S, T) = (|S₁| / |S|)·Ent(S₁) + (|S₂| / |S|)·Ent(S₂), where Ent(S) = −Σ pᵢ log₂ pᵢ

Then split each interval again recursively until the gain is too small (below a threshold).

Ages with class "buys"

Data: 21 N · 25 N · 30 Y · 35 Y · 40 Y · 45 N. The whole set has Ent(S) = 1.000 (3 Y and 3 N).

Candidate T (midpoint) Left / right I(S, T) Gain
23 {N} / 0.809 0.191
27.5 {N, N} / {Y, Y, Y, N} 0.541 0.459 ← best
32.5 {N, N, Y} / 0.918 0.082
37.5 {N, N, Y, Y} / 1.000 0
42.5 {N, N, Y, Y, Y} / 0.809 0.191

So the first split is age ≤ 27.5 vs age > 27.5.

The 3-4-5 rule (natural partitioning)

Rule

Look at the most significant digit (msd) of the range, and count how many distinct msd values the range covers:

Distinct msd values covered Split into
3, 6, 7 or 9 3 equal-width intervals (7 → 2-3-2)
2, 4 or 8 4 intervals
1, 5 or 10 5 intervals

Apply it recursively to each interval. This gives "natural", rounded boundaries that people find easy to read.

Profit from −Rs. 351,976 to Rs. 4,700,896 (textbook example)
  1. Use the 5th to 95th percentile range (−159,876 to 1,838,761) to avoid outliers. The msd is 1,000,000, so round outwards to Low = −1,000,000 and High = 2,000,000.
  2. That covers 3 distinct msd values (−1, 0, 1 million), so make 3 intervals: (−1M, 0], (0, 1M], (1M, 2M].
  3. Adjust to the real min and max: the first interval shrinks to (−400,000, 0], and a new interval (2M, 5M] is added to cover the maximum.
  4. Repeat inside each interval. For example, at the 100,000s digit, (0, 1M] covers 10 distinct values, so split it into 5 intervals of 200,000: (0, 200k], (200k, 400k], …, (800k, 1M].

11Self-assignment (2024): binning in practice

Ages: 13, 15, 16, 16, 19, 20, 20, 21, 22, 22, 25, 25, 25, 25, 30, 33, 33, 35, 35, 35, 35, 36, 40, 45, 46, 52, 70

a) Three equal-depth bins (27 values, so 9 per bin), smoothed by bin means:

Bin Values Mean Smoothed (means) Smoothed (boundaries)
1 13 15 16 16 19 20 20 21 22 162 / 9 = 18 18 × 9 13 13 13 13 22 22 22 22 22
2 22 25 25 25 25 30 33 33 35 253 / 9 = 28.11 28.11 × 9 22 22 22 22 22 35 35 35 35
3 35 35 35 36 40 45 46 52 70 394 / 9 = 43.78 43.78 × 9 35 35 35 35 35 35 35 35 70

b) Finding outliers:

  • IQR rule: Q1 = 20, Q3 = 35, so the upper fence = 35 + 1.5 × 15 = 57.5, and 70 is an outlier.
  • z-score: (70 − 29.96) / 12.70 = 3.15 > 3.
  • Clustering: 70 sits far from every cluster.
  • Boxplots: 70 shows as a point beyond the whisker.

c) Other smoothing methods: bin medians (19, 25, 40), bin boundaries, regression, clustering, moving averages.

12Quick revision sheet

Concept Remember it as
Data reduction Smaller data, (almost) same results; saves time & memory
5 strategies Cube aggregation · Attribute subset selection · Dimensionality reduction · Numerosity reduction · Discretization
Attribute subset goal Minimum attributes, class distribution ≈ original
Greedy methods Forward selection · Backward elimination · Combined · Decision tree induction
Lossless vs lossy Exact reconstruction vs approximation (wavelet, PCA)
Parametric numerosity Store model parameters: regression y = wx + b, log-linear
Non-parametric numerosity Histograms, clustering, sampling
Histogram rules Equal-width · Equal-frequency · V-Optimal (least variance) · MaxDiff (β − 1 largest gaps)
Equal-width formula W = (B − A) / N — hurt by outliers
Equal-depth Same count per bin — sort first, depth = n / N
Smoothing By means · by medians · by boundaries (closest of min/max)
Supervised vs unsupervised Uses class labels or not
Top-down vs bottom-up Splitting at cut points vs merging neighbours
Concept hierarchy Recursive discretization: age → youth / middle-aged / senior; done before mining

?Self-check quiz

11 questions on this week. Answer them all, then press Check my answers. Your best and latest scores are saved and shown on the subject page.