Chapter 3
Data Preprocessing
Data quality, the four preprocessing techniques, missing and noisy data, binning and histograms, discretization and concept hierarchies, integration and correlation, normalization, and data reduction strategies.
From: Topic 3a - Overview of Data Preprocessing, Topic 3 part 2 - Data Cleaning & Discretization, Topic 3 part 3 - Data Integration, Topic 3 part 4 - Data Transformation, Topic 3 part 5 - Data Reduction, Topic 3 part 6 - Data Reduction II
Why preprocess? (3a)
- Real-world data is incomplete (missing values or attributes, or only aggregates), noisy (errors, outliers, e.g. Salary = “−10”) and inconsistent (discrepancies, e.g. Age = 42 but Birthday = 03/07/1997; ratings changed from 1,2,3 to A,B,C).
- Data quality is multidimensional: accuracy, completeness, consistency, timeliness, believability, interpretability.
| Technique | Definition |
|---|---|
| Data cleaning | Fix or remove incorrect, corrupted, badly formatted, duplicate or incomplete data: fill missing values, smooth noise, identify outliers, correct inconsistencies |
| Data integration | Combine data from multiple sources into a coherent store |
| Data transformation | Convert data into the format needed for mining, e.g. normalize to 0.0–1.0 |
| Data reduction | A reduced representation of the data with minimal loss |
Missing data (3.2)
- Causes: equipment malfunction; deleted because inconsistent; not entered due to misunderstanding; not considered important at entry; history or changes not registered.
- Ignore the tuple: usually when the class label is missing; not effective when the % missing per attribute varies a lot.
- Fill in manually: tedious, maybe infeasible.
- Fill in automatically with: a global constant (“unknown”, effectively a new class); the attribute mean; the attribute mean for samples of the same class (smarter); or the most probable value (inference-based, e.g. Bayesian formula or decision tree).
Noisy data (3.2)
Noise is random error or variance in a measured variable. Smooth it out with binning, regression or cluster analysis (the same methods are used in data reduction).
| Partitioning | How | Pros / cons |
|---|---|---|
| Equal-width (distance) | N intervals of equal size: W = (B − A)/N | Most straightforward, but outliers may dominate and skewed data isn't handled well |
| Equal-depth (frequency) | N intervals, each with about the same number of samples | Good data scaling; categorical attributes can be tricky |
Smoothing by binning (3.2, slide 10)
- Sorted prices: 4, 8, 9, 15, 21, 21, 24, 25, 26, 28, 29, 34 → equal-frequency bins: [4, 8, 9, 15], [21, 21, 24, 25], [26, 28, 29, 34].
- By bin means: 9, 9, 9, 9 | 23, 23, 23, 23 | 29, 29, 29, 29.
- By bin boundaries (each value → closest of min/max): 4, 4, 4, 15 | 21, 21, 25, 25 | 26, 26, 26, 34.
- Smoothing by bin median is also possible.
- Histograms (3.2, slides 11–12): for 24 values 1–9, an equal-width 3-bucket histogram uses [1,3], [4,6], [7,9]; an equal-frequency one uses [1,2], [3,5], [6,9] so each bucket holds about the same count.
- Clustering: similar values form clusters; points outside clusters are outliers.
- Regression: fit the data to a function. Linear regression finds the best line Y = α + βX (least squares); multiple regression Y = b0 + b1X1 + b2X2; log-linear models approximate discrete multidimensional probability distributions.
- Inconsistent data can be corrected manually with external references (paper trace); it comes from data entry errors or integration (same attribute, different names).
Discretization and concept hierarchies (3.2)
- Discretization reduces the number of values of a continuous attribute by dividing its range into intervals; interval labels replace the values.
- Supervised discretization uses class information; unsupervised doesn't.
- Concept hierarchy: replace low-level concepts (numeric age) with higher-level ones (young, middle-aged, senior). Useful for mining at multiple levels of abstraction.
- Numeric data: binning, histogram analysis, cluster analysis, entropy-based discretization, natural partitioning.
- Nominal data: order attributes at schema level (street < city < state < country); group values explicitly ({Urbana, Champaign, Chicago} < Illinois); or generate automatically by the number of distinct values: the attribute with the most distinct values goes at the lowest level (street 674,339 → city 3,567 → province/state 365 → country 15).
Data integration (3.3)
- Combines multiple databases, data cubes or flat files into a coherent store such as a data warehouse.
- Issues: schema integration (the entity identification problem, e.g. A.cust-id ≡ B.cust-#), redundancy, and data value conflicts (different representations or scales, e.g. metric vs British units).
- Redundancy arises from object identification (same attribute, different names) and derivable data (e.g. annual revenue). Detect it with correlation and covariance analysis.
- Nominal data: χ² (chi-square) test. Numeric data: correlation coefficient and covariance.
- r > 0: positively correlated (higher = stronger); r = 0: independent; r < 0: negatively correlated. Scatter plots run from −1 to 1.
Data transformation (3.4)
| Method | Meaning |
|---|---|
| Smoothing | Remove noise |
| Aggregation | Summarise, build data cubes |
| Generalization | Concept hierarchy climbing |
| Normalization | Scale into a small, specified range |
| Attribute/feature construction | Build new attributes from given ones (e.g. feature extraction from image data) |
min-max: v′ = (v − min)/(max − min) × (new_max − new_min) + new_min
$73,600 with range $12,000–$98,000 → 0.716
z-score: v′ = (v − μ)/σ
μ = 54,000, σ = 16,000: $73,600 → 1.225
decimal scaling: v′ = v / 10^j, where j is the smallest integer with max(|v′|) < 1
Range −986 to 917 → divide by 1,000; 900 → 0.9
Data reduction (3.5–3.6)
Goal: a representation much smaller in volume that keeps the integrity of the original, so mining is more efficient yet gives the same results. Strategies: data cube aggregation, attribute subset selection, dimensionality reduction / data compression, numerosity reduction, discretization and concept hierarchy generation.
- Data cube aggregation: e.g. quarterly sales aggregated to annual sales; use the smallest representation enough for the task.
- Attribute subset selection (FSS): find a minimum set of attributes whose class distribution is close to the original. Methods: stepwise forward selection, stepwise backward elimination (start with all, remove the worst each step), a combination of both, decision tree induction, and reducts from rough set theory.
- Redundant attributes duplicate information in others (purchase price vs sales tax paid). Irrelevant attributes carry no useful information (student ID for predicting GPA).
- Data compression: lossless if the original can be reconstructed exactly, lossy if only an approximation. Methods: wavelet transforms (linear signal processing, keeps relative distance at different resolutions; used for image compression) and PCA (projects data onto a smaller space capturing the most variation; unlike FSS it creates new combined attributes).
- Numerosity reduction: smaller forms of representation. Parametric: fit a model, store only its parameters (regression, log-linear). Non-parametric: histograms, clustering (store cluster representations), sampling.
| Sampling | How |
|---|---|
| Simple random sampling (SRS) | Equal probability of picking any item; may perform poorly with skewed data |
| Without replacement (SRSWOR) | Each picked item is removed from the population |
| With replacement (SRSWR) | Picked items stay, so the same object can be picked more than once |
| Stratified sampling | Split into partitions (strata), sample from each; keeps class percentages; used with skewed data |
| Cluster sampling | Group the data into clusters and sample whole clusters |