Concepts and Tasks

Data mining tasks fall into two groups. Descriptive tasks describe the general properties of the data (clustering, association, summarisation). Predictive tasks use current data to make predictions (classification, regression). Data mining is used in retail, banking, healthcare, telecom, education and science.

Why Preprocess Data

Real data is dirty: incomplete (missing values), noisy (errors and outliers) and inconsistent (different codes for the same thing). Poor data gives poor results, so preprocessing often takes most of the effort in a mining project.

Data Cleaning

  • Missing values: ignore the record, fill by hand, fill with a global constant, or fill with the mean or median of the attribute (or of the class).
  • Noisy data: smooth by binning (replace values by the mean or boundaries of their bin), by regression, or by clustering, which exposes outliers.

Data Integration

Combining data from several sources raises the entity identification problem (the same customer under two names), redundancy (found by correlation analysis) and conflicts in units or scales. Careful integration reduces duplicates.

Data Transformation

  • Normalisation: min-max, z-score or decimal scaling so that attributes are comparable.
  • Aggregation, generalisation (city to country) and attribute construction.
  • Discretisation: converting numbers into ranges.

Data Reduction

Reduces data size while keeping the same analytical result: dimensionality reduction (PCA, attribute selection), numerosity reduction (sampling, histograms, clustering) and data compression.

Definition: Normalisation. Scaling the values of an attribute to a small common range, such as 0 to 1, so that no attribute dominates the analysis because of its units.

Table 2.1: Data preprocessing steps

Step Aim Methods
Cleaning Remove errors Fill missing values, binning, outlier removal
Integration Merge sources Entity matching, correlation check
Transformation Suitable forms Normalisation, aggregation, discretisation
Reduction Smaller data Sampling, PCA, compression

Example 2.1: Smoothing by bin means and min-max scaling

Problem: The sorted prices 4, 8, 15, 21, 21, 24, 25, 28, 34 are placed in 3 equal-depth bins. Smooth the data by bin means, then scale the value 15 to the range 0 to 1 using min-max normalisation.

Solution:

  1. Bin 1 = 4, 8, 15 with mean (4 + 8 + 15) / 3 = 9.
  2. Bin 2 = 21, 21, 24 with mean 66 / 3 = 22; bin 3 = 25, 28, 34 with mean 87 / 3 = 29.
  3. Smoothed data: 9, 9, 9, 22, 22, 22, 29, 29, 29.
  4. Min-max: (v - min) / (max - min) = (15 - 4) / (34 - 4) = 11 / 30 = 0.367.

Result: The smoothed values are 9, 22 and 29 for the three bins, and 15 is normalised to 0.367.

data = [4, 8, 15, 21, 21, 24, 25, 28, 34]
size = 3
smooth = []
for i in range(0, len(data), size):
    b = data[i:i + size]
    m = sum(b) // len(b)
    smooth += [m] * len(b)
print("Smoothed:", smooth)
lo, hi = min(data), max(data)
print("Min-max of 15:", round((15 - lo) / (hi - lo), 3))
ages = [22, 25, None, 31, 40, None, 52]
known = [a for a in ages if a is not None]
mean = sum(known) / len(known)
print("Filled:", [a if a is not None else mean for a in ages])

Output

Smoothed: [9, 9, 9, 22, 22, 22, 29, 29, 29]
Min-max of 15: 0.367
Filled: [22, 25, 34.0, 31, 40, 34.0, 52]

Common mistakes

  • Filling missing values with the mean without checking whether the mean is meaningful.
  • Normalising before removing outliers, which squeezes the other values.
  • Merging data sources without matching entities first.
  • Reducing data so much that useful patterns are lost.

Key takeaways

  • Tasks are descriptive (clustering, association) or predictive (classification, regression).
  • Preprocessing: cleaning, integration, transformation, reduction.
  • Min-max scales to 0 to 1; z-score uses mean and standard deviation.
  • Binning smooths noisy data.

Practice questions

  1. Name two ways of handling missing values.
  2. What is normalisation used for?
  3. What are the strategies of data reduction?

Answers to the practice questions

  1. Fill with the mean or median, or ignore the record.
  2. Bringing attributes to a common scale.
  3. Dimensionality reduction, numerosity reduction and compression.

Sources

  • Official BCA syllabus Data Warehousing and Mining, course code 25BCA406DS03, Unit II