Professional Documents
Culture Documents
02DataPreprocessing Dikonversi
02DataPreprocessing Dikonversi
— Chapter 2 —
Jiawei Han
Department of Computer Science
University of Illinois at Urbana-Champaign
www.cs.uiuc.edu/~hanj
©2006 Jiawei Han and Micheline Kamber, All rights reserved
June 7, 2014 Data Mining: Concepts and Techniques 1
1
Why Data Preprocessing?
Data in the real world is dirty
incomplete: lacking attribute values, lacking
2
Why Is Data Preprocessing Important?
3
Forms of Data Preprocessing
4
Mining Data Descriptive Characteristics
Motivation
To better understand the data: central tendency, variation
and spread
Data dispersion characteristics
median, max, min, quantiles, outliers, variance, etc.
Numerical dimensions correspond to sorted intervals
Data dispersion: analyzed with multiple granularities of
precision
Boxplot or quantile analysis on sorted intervals
Dispersion analysis on computed measures
Folding measures into numerical dimensions
Boxplot or quantile analysis on the transformed cube
w xx i i
w i
Median: A holistic measure i 1
5
Measuring the Dispersion of Data
Quartiles, outliers and boxplots
Quartiles: Q1 (25th percentile), Q3 (75th percentile)
Inter-quartile range: IQR = Q3 – Q1
Five number summary: min, Q1, M, Q3, max
Boxplot: ends of the box are the quartiles, median is marked, whiskers, and
plot outlier individually
Outlier: usually, a value higher/lower than 1.5 x IQR
Variance and standard deviation (sample: s, population: σ)
Variance: (algebraic, scalable computation)
1 n 1 n 1 n 1 n 1 n
s2 (x x)2 [x 2i ( x ) 2] o 2 i
N i 1( x )
2 2
N i x
i
n ii1 n 1ii1 n i1
1 2
Standard deviation s (or σ) is the square root of variance s2 (or σ2)
1
Boxplot Analysis
6
Histogram Analysis
Scatter plot
Provides a first look at bivariate data to see clusters of
points, outliers, etc
Each pair of values is treated as a pair of coordinates and
plotted as points in the plane
7
Positively and Negatively Correlated Data
8
Graphic Displays of Basic Statistical Descriptions
9
Data Cleaning
Importance
“Data cleaning is one of the three biggest problems
warehousing”—DCI survey
Data cleaning tasks
Fill in missing values
Identify outliers and smooth out noisy data
Correct inconsistent data
Resolve redundancy caused by data integration
Missing Data
10
How to Handle Missing Data?
Ignore the tuple: usually done when class label is missing (assuming
the tasks in classification—not effective when the percentage of
missing values per attribute varies considerably.
Fill in the missing value manually: tedious + infeasible?
Fill in it automatically with
a global constant : e.g., “unknown”, a new class?!
the attribute mean
the attribute mean for all samples belonging to the same class:
smarter
the most probable value: inference-based such as Bayesian
formula or decision tree
June 7, 2014 Data Mining: Concepts and Techniques 21
Noisy Data
Noise: random error or variance in a measured variable
Incorrect attribute values may due to
faulty data collection instruments
technology limitation
incomplete data
inconsistent data
11
How to Handle Noisy Data?
Binning
first sort data and partition into (equal-frequency) bins
Clustering
detect and remove outliers
12
Binning Methods for Data Smoothing
Sorted data for price (in dollars): 4, 8, 9, 15, 21, 21, 24, 25, 26,
28, 29, 34
* Partition into equal-frequency (equi-depth) bins:
- Bin 1: 4, 8, 9, 15
- Bin 2: 21, 21, 24, 25
- Bin 3: 26, 28, 29, 34
* Smoothing by bin means:
- Bin 1: 9, 9, 9, 9
- Bin 2: 23, 23, 23, 23
- Bin 3: 29, 29, 29, 29
* Smoothing by bin boundaries:
- Bin 1: 4, 4, 4, 15
- Bin 2: 21, 21, 25, 25
- Bin 3: 26, 26, 26, 34
June 7, 2014 Data Mining: Concepts and Techniques 25
Regression
Y1
Y1’ y=x+1
X1 x
13
Cluster Analysis
14
Data Integration
Data integration:
Combines data from multiple sources into a coherent
store
Schema integration: e.g., A.cust-id B.cust-
#
Integrate metadata from different sources
15
Correlation Analysis (Numerical Data)
rA ,
((nA
A)( B B )
1) ( n
( AB )
1)
B A B
n AB A B
Χ2 (chi-square) test
(Observed Expected)2
2
Expected
The larger the Χ value, the more likely the variables are
2
related
The cells that contribute the most to the Χ2 value are
those whose actual count is very different from the
expected count
Correlation does not imply causality
# of hospitals and # of car-theft in a city are correlated
Both are causally linked to the third variable: population
June 7, 2014 Data Mining: Concepts and Techniques 32
16
Chi-Square Calculation: An Example
It840)
2
shows
that like_science_fiction and play_chess are
correlated
90 in the group 210 360
840
June 7, 2014 Data Mining: Concepts and Techniques 33
Data Transformation
17
Data Transformation: Normalization
Min-max normalization: to [new_minA, new_maxA]
v minA
v' (new _ maxA new _ min A ) new _ A
min max A
v A
v'
o A
73,600 54,000
Ex. Let μ = 54,000, σ = 16,000. Then 16,000
1.225
18
Data Reduction Strategies
smaller in volume but yet produce the same (or almost the
same) analytical results
Data reduction strategies
Data cube aggregation:
attributes
Data Compression
19
Cube: A Lattice of Cuboids
all
0-D(apex) cuboid
time,location,su
pplier 3-D cuboids
time,item,location
time,item,supplier item,location,supplier
4-D(base) cuboid
time, item, location, supplier
understand
Heuristic methods (due to exponential # of
choices):
Step-wise forward selection
elimination
June 7, 2014 Data Mining: Concepts and Techniques 40
Decision-tree induction
20
Attribute Subset Selection
A4 ?
A1? A6?
21
Heuristic Feature Selection Methods
There are 2d possible sub-features of d features
Several heuristic feature selection methods:
Best single features under the feature independence
Data Compression
String compression
There are extensive theories and well-tuned algorithms
Typically lossless
expansion
Audio/video compression
Typically lossy compression, with progressive
refinement
Sometimes small fragments of signal can be
22
Data Compression
If the original data can be reconstructed
from the compressed data without any
loss of information, the data reduction is
called lossless
Original Data
If we can reconstruct only an
Approximated approximation of the original data, then
the data reduction is called lossy
June 7, 2014 Data Mining: Concepts and Techniques 45
Dimensionality Reduction:
Wavelet Transformation
Haar2 Daubechie4
Discrete wavelet transform (DWT): linear signal
processing, multi-resolutional analysis
Compressed approximation: store only a small fraction of
the strongest of the wavelet coefficients
Similar to discrete Fourier transform (DFT), but better
lossy compression, localized in space
Method:
Length, L, must be an integer power of 2 (padding with 0’s, when
necessary)
Each transform has 2 functions: smoothing, difference
Applies to pairs of data, resulting in two set of data of length L/2
Applies two functions recursively, until reaches the desired length
June 7, 2014 Data Mining: Concepts and Techniques 46
23
Dimensionality Reduction: Principal
Component Analysis (PCA)
Given N data vectors from n-dimensions, find k ≤ n orthogonal vectors
(principal components) that can be best used to represent data
Steps
Normalize input data: Each attribute falls within the same range
component vectors
The principal components are sorted in order of decreasing
“significance” or strength
Since the components are sorted, the size of the data can be
X1
24
Numerosity Reduction
Reduce data volume by choosing alternative, smaller
forms of data representation
Parametric methods
Major families:
histograms, clustering,
June 7, 2014 Data Mining: Concepts and Techniques 49
sampling
25
Regress Analysis and Log-Linear Models
Linear regression: Y = w X + b
Two regression coefficients, w and b, specify the line
above
Log-linear models:
The multi-way table of joint probabilities is
20
V-optimal: with the least
15histogram variance
between each
(weighted sumpair for pairs
of the have
original
10000
20000
30000
40000
50000
60000
70000
80000
90000
100000
5
MaxDiff: set bucket boundary
0
26
Data Reduction Method (3): Clustering
Partition data set into clusters based on similarity, and store cluster
representation (e.g., centroid and diameter) only
Can be very effective if data is clustered but not if data is
“smeared”
Can have hierarchical clustering and be stored in multi-dimensional
index tree structures
There are many choices of clustering definitions and clustering
algorithms
Cluster analysis will be studied in depth in Chapter 7
27
Sampling: with or without Replacement
Raw Data
June 7, 2014 Data Mining: Concepts and Techniques 55
28
Chapter 2: Data Preprocessing
Discretization
29
Discretization and Concept Hierarchy
Discretization
Reduce the number of values for a given continuous attribute by
dividing the range of the attribute into intervals
Interval labels can then be used to replace actual data values
Supervised vs. unsupervised
Split (top-down) vs. merge (bottom-up)
Discretization can be performed recursively on an attribute
Concept hierarchy formation
Recursively reduce the data by collecting and replacing low level
concepts (such as numeric values for age) by higher level concepts
(such as young, middle-aged, or senior)
30
Entropy-Based Discretization
Given a set of samples S, if S is partitioned into two intervals S1 and S2
using boundary T, the information gain after partitioning is
| | | |
I (S , T ) S 1 Entropy ( ) S 2 Entropy ( )
|S| S1 |S| S2
Entropy is calculated based on class distribution of the samples in the
set. Given m classes, the entropy of S1 is
m
Entropy ( S 1 )
i p i log 2 ( p i )
1
31
Segmentation by Natural Partitioning
(-$1,000 - $2,000)
Step 3:
(-$1,000 - 0) (0
Step 4: -$ 1,000)
($1,000 - $2,000)
(-$400 -$5,000)
(-$400 - 0) (0 - $1,000)
($1,200 - ($1,000 - $2, 000)
($2,000 - $5, 000)
(0 -
(-$400 - ($1,000 -
$200)
-$300) $1,200) ($2,000 -
($200 - $3,000)
0) $400)
(-$300 - $1,400)
-$200) ($3,000 -
($400 - ($1,400 - $4,000)
(-$200 - $600) $1,600) ($4,000 -
-$100) ($600 - ($1,600 - $5,000)
$800) ($800 - $1,800) ($1,800 -
(-$100 - $1,000) $2,000)
32
Concept Hierarchy Generation for Categorical Data
33
Chapter 2: Data Preprocessing
Summary
Data preparation or preprocessing is a big issue for both
data warehousing and data mining
Discriptive data summarization is need for quality data
preprocessing
Data preparation includes
Data cleaning and data integration
Data reduction and feature selection
Discretization
A lot a methods have been developed but data
preprocessing still an active area of research
June 7, 2014 Data Mining: Concepts and Techniques 68
34
References
D. P. Ballou and G. K. Tayi. Enhancing data quality in data warehouse environments. Communications of
ACM, 42:73-78, 1999
T. Dasu and T. Johnson. Exploratory Data Mining and Data Cleaning. John Wiley & Sons, 2003
T. Dasu, T. Johnson, S. Muthukrishnan, V. Shkapenyuk. Mining Database Structure; Or, How to Build a
Data Quality Browser. SIGMOD’02.
H.V. Jagadish et al., Special Issue on Data Reduction Techniques. Bulletin of the Technical
Committee on Data Engineering, 20(4), December 1997
D. Pyle. Data Preparation for Data Mining. Morgan Kaufmann, 1999
E. Rahm and H. H. Do. Data Cleaning: Problems and Current Approaches. IEEE Bulletin of the
Technical Committee on Data Engineering. Vol.23, No.4
V. Raman and J. Hellerstein. Potters Wheel: An Interactive Framework for Data Cleaning and
Transformation, VLDB’2001
T. Redman. Data Quality: Management and Technology. Bantam Books, 1992
Y. Wand and R. Wang. Anchoring data quality dimensions ontological foundations. Communications of
ACM, 39:86-95, 1996
R. Wang, V. Storey, and C. Firth. A framework for analysis of data quality research. IEEE Trans.
Knowledge and Data Engineering, 7:623-640, 1995
35