Unit II ยท Data Preprocessing

Back to Syllabus

2.1 Why Preprocessing Matters

Real-world data is incomplete, noisy, and inconsistent. Data preprocessing transforms raw data into a quality format suitable for mining. It is the most time-consuming step, consuming 60-80% of a data mining project's effort.

Data Quality Dimensions:
  • Accuracy: Values are correct and reflect reality.
  • Completeness: All required data is present.
  • Consistency: No contradictory data across sources.
  • Timeliness: Data is up-to-date and relevant.
Zoom: 100%
flowchart LR RAW[(๐Ÿ“ฅ Raw Data)] --> CLEAN[๐Ÿงน Data Cleaning
Handle missing values
Remove noise & outliers] CLEAN --> INT[๐Ÿ”— Data Integration
Merge multiple sources
Resolve conflicts] INT --> TRANS[โš™๏ธ Data Transformation
Normalization
Aggregation
Encoding] TRANS --> RED[๐Ÿ“‰ Data Reduction
Dimensionality reduction
Feature selection] RED --> MINED[(โœ… Mined Data)] style RAW fill:#ede9fe,stroke:#7c3aed,stroke-width:3px,color:#1e1b4b style MINED fill:#dcfce7,stroke:#22c55e,stroke-width:3px,color:#1e1b4b style CLEAN fill:#dbeafe,stroke:#3b82f6,stroke-width:3px,color:#1e1b4b style INT fill:#fef3c7,stroke:#f59e0b,stroke-width:3px,color:#1e1b4b style TRANS fill:#fce7f3,stroke:#ec4899,stroke-width:3px,color:#1e1b4b style RED fill:#f3e8ff,stroke:#8b5cf6,stroke-width:3px,color:#1e1b4b

2.2 Data Cleaning

Data cleaning handles missing values, noise, and inconsistencies in the dataset.

Handling Missing Values

๐Ÿ—‘๏ธ Delete Tuples Remove rows with missing values (works if missing data is small, <5%).
โœ๏ธ Fill Manually Use domain knowledge to fill values (time-consuming).
๐Ÿ“Š Mean/Median/Mode Replace with statistical average (fast but may reduce variance).
๐Ÿ“ˆ Regression Predict missing values using regression models.
๐Ÿ” KNN Imputation Use k-nearest neighbors to estimate missing values.
๐ŸŽฒ Multiple Imputation Create multiple plausible values and average results.
Missing Data Types:
  • MCAR (Missing Completely at Random): Missingness has no pattern โ€” deletion is safe.
  • MAR (Missing at Random): Missingness depends on observed data โ€” imputation works.
  • MNAR (Missing Not at Random): Missingness depends on the missing value itself โ€” most problematic.

Noise Handling

2.3 Data Integration

Data integration combines data from multiple heterogeneous sources into a unified view.

Challenges in Data Integration

๐Ÿ“‹ Schema Integration Matching attributes across databases (e.g., "First Name" vs "Given Name").
๐Ÿ” Entity Resolution Identifying the same real-world entity across sources (e.g., "J. Smith" = "John Smith").
๐Ÿ”„ Redundancy Detection Correlated attributes can be detected using correlation analysis.
โš ๏ธ Data Value Conflicts Same entity may have different values in different sources (currency, units).
Correlation Analysis for Numerical Data:
  • Covariance: Measures how two variables change together. Positive = same direction, Negative = opposite.
  • Pearson Correlation Coefficient: Normalized covariance between -1 and +1. Values near ยฑ1 indicate strong linear relationship.
Chi-Square Test for Categorical Data:

Tests whether two categorical attributes are independent. A high chi-square value indicates the attributes are dependent (redundant).

2.4 Data Transformation

Data transformation converts data into forms suitable for mining.

Zoom: 100%
flowchart TD A[โš™๏ธ Data Transformation] --> B[๐Ÿ“Š Normalization] A --> C[๐Ÿ“ฆ Aggregation] A --> D[๐Ÿ”บ Generalization] A --> D2[๐Ÿท๏ธ Encoding] B --> B1[Min-Max
v' = (v-min)/(max-min)] B --> B2[Z-Score
v' = (v-mean)/std] B --> B3[Decimal Scaling
v' = v / 10^d] C --> C1[Sum] C --> C2[Average] C --> C3[Count] D --> D1[Hierarchy
Day โ†’ Month โ†’ Year] D2 --> E1[One-Hot
Red=100, Blue=010] D2 --> E2[Label
Low=0, Med=1, High=2] style A fill:#ede9fe,stroke:#7c3aed,stroke-width:3px,color:#1e1b4b style B fill:#dbeafe,stroke:#3b82f6,stroke-width:3px,color:#1e1b4b style C fill:#fef3c7,stroke:#f59e0b,stroke-width:3px,color:#1e1b4b style D fill:#d1fae5,stroke:#22c55e,stroke-width:3px,color:#1e1b4b style D2 fill:#fce7f3,stroke:#ec4899,stroke-width:3px,color:#1e1b4b style B1 fill:#e0e7ff,stroke:#6366f1,stroke-width:2px,color:#1e1b4b style B2 fill:#e0e7ff,stroke:#6366f1,stroke-width:2px,color:#1e1b4b style B3 fill:#e0e7ff,stroke:#6366f1,stroke-width:2px,color:#1e1b4b style C1 fill:#fef9c3,stroke:#eab308,stroke-width:2px,color:#1e1b4b style C2 fill:#fef9c3,stroke:#eab308,stroke-width:2px,color:#1e1b4b style C3 fill:#fef9c3,stroke:#eab308,stroke-width:2px,color:#1e1b4b style D1 fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#1e1b4b style E1 fill:#fce7f3,stroke:#db2777,stroke-width:2px,color:#1e1b4b style E2 fill:#fce7f3,stroke:#db2777,stroke-width:2px,color:#1e1b4b

Normalization Techniques

Encoding Categorical Data

2.5 Data Reduction

Data reduction reduces data volume while maintaining mining integrity.

Zoom: 100%
flowchart TD A[๐Ÿ“‰ Data Reduction] --> B[๐Ÿ“ Dimensionality
Reduce attributes] A --> C[๐Ÿ”ข Numerosity
Reduce data points] A --> D[๐Ÿ“ฆ Data Compression
Encode compactly] B --> B1[PCA
Principal Component Analysis] B --> B2[Feature Selection
Select relevant features] B --> B3[Feature Extraction
Create new features] C --> C1[Sampling
Random, stratified, systematic] C --> C2[Data Cube Aggregation] D --> D1[Lossless
Original recoverable] D --> D2[Lossy
Approximate reconstruction] style A fill:#ede9fe,stroke:#7c3aed,stroke-width:3px,color:#1e1b4b style B fill:#dbeafe,stroke:#3b82f6,stroke-width:3px,color:#1e1b4b style C fill:#fef3c7,stroke:#f59e0b,stroke-width:3px,color:#1e1b4b style D fill:#fce7f3,stroke:#ec4899,stroke-width:3px,color:#1e1b4b style B1 fill:#f3e8ff,stroke:#8b5cf6,stroke-width:2px,color:#1e1b4b style B2 fill:#f3e8ff,stroke:#8b5cf6,stroke-width:2px,color:#1e1b4b style B3 fill:#f3e8ff,stroke:#8b5cf6,stroke-width:2px,color:#1e1b4b style C1 fill:#fef9c3,stroke:#eab308,stroke-width:2px,color:#1e1b4b style C2 fill:#fef9c3,stroke:#eab308,stroke-width:2px,color:#1e1b4b style D1 fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#1e1b4b style D2 fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#1e1b4b

Dimensionality Reduction

๐Ÿ“ PCA Projects data onto directions of maximum variance. Reduces dimensions while preserving most information.
โœ‚๏ธ Feature Selection Selects a subset of original features. Methods: filter (correlation), wrapper (model-based), embedded (LASSO).
๐Ÿ”ง Feature Extraction Creates new features from existing ones (e.g., polynomial features, interactions).

Numerosity Reduction

Textbooks & Resources

Data Mining: Concepts & Techniques by Han, Kamber, Pei Search
Introduction to Data Mining by Tan, Steinbach, Kumar Search
Complete Syllabus View