Chapter 3
Chapter 3
November, 24
Chapter III
DATA PRE-PROSSESSING
2
Data Preprocessing
4
Why Is Data Dirty?
Incomplete data may come from
“Not applicable” data value when collected
Different considerations between the time when the data
was collected and when it is analyzed.
Human/hardware/software problems
Noisy data (incorrect values) may come from
Faulty data collection instruments
Human or computer error at data entry
Errors in data transmission
Inconsistent data may come from
Different data sources
Functional dependency violation (e.g., modify some linked
data)
Duplicate records also need data cleaning
5
Why Is Data Preprocessing
Important?
6
Multi-Dimensional Measure of Data
Quality
Completeness
Consistency
Timeliness
Believability
Value added
Interpretability
Accessibility
Broad categories:
Intrinsic, contextual, representational, and
accessibility
7
3) Major Tasks in Data
Preprocessing
Data cleaning
Fill in missing values, smooth noisy data, identify or
remove outliers, and resolve inconsistencies
Data integration
Integration of multiple databases, data cubes, or files
Data transformation
Normalization and aggregation
Data reduction
Obtains reduced representation in volume but produces
the same or similar analytical results
Data discretization
Part of data reduction but with particular importance,
especially for numerical data
Concept hierarchy generation
8
Forms of Data
Preprocessing
9
Data Preprocessing
integration
11
Missing Data
12
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 and infeasible?
Fill in it automatically with
a global constant : e.g., “unknown”, a new class?!
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
13
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
14
How to Handle Noisy Data?
Binning
first sort data and partition into (equal-
frequency) bins
then one can smooth by bin means, smooth by
functions
Clustering
detect and remove outliers
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
17
Regression
Smooth by fitting the data y
into Regression Functions
Finding a fitting function
for two dimensional case Y1
so that the value of the
second variable can be
estimated using the value
of the first variable
Y1’ y=x+1
X1 x
• It can be extended to N dimensional case in which regression finds
multidimensional space so that value of one of the dimension can be
predicted from the rest N-1 values
18
Cluster Analysis
Each cluster centroid is marked with a “+”, representing the average point
in space for that cluster. Outliers may be detected as values that fall
outside of the sets of clusters
19
Data Preprocessing
20
Data Integration
Data integration:
Combines data from multiple sources into a coherent store
21
Handling Redundancy in Data
Integration
rA, B
(A A)( B B )
( AB) n AB
( n 1)AB ( n 1)AB
where n is the number of tuples,
A and
B are the
respective means of A and B, σA and σB are the respective
standard deviation of A and B, and Σ(AB) is the sum of the
AB cross-product.
If rA,B > 0, A and B are positively correlated (A’s
values increase as B’s). The higher, the stronger
correlation.
rA,B = 0: independent; rA,B < 0: negatively 23
Correlation Analysis (Categorical
Data)
26
Data Transformation:
Normalization
Min-max normalization: to [new_minA, new_maxA]
v minA
v' (new _ maxA new _ minA) new _ minA
maxA minA
Ex. Let income range $12,000 to $98,000 normalized to
73,600 12,000
[0.0, 1.0]. Then $73,000 is mapped to (1.0 0) 0 0.716
98,000 12,000
Z-score normalization (μ: mean, σ: standard deviation):
v A
v'
A
73,600 54,000
Ex. Let μ = 54,000, σ = 16,000. Then 1.225
16,000
Normalization by decimal scaling
v
v' j Where j is the smallest integer such that Max(|ν’|) < 1
10
27
Data Preprocessing
Dimensionality reduction
Numerosity reduction
29
Data Cube Aggregation
Figure: Sales data for a given branch of AllElectronics for the year 2002 to 2004. On the left, the
sales are shown per quarter. On the right, the data are aggregated to provide the annual sales.
31
Attribute Subset Selection
Feature selection (i.e., attribute subset selection):
Select a minimum set of features such that the
understand
32
Heuristic Attribute Selection
Methods(1)
There are 2d possible sub-features of d features
Several heuristic feature selection methods:
Best single features under the feature
35
Dimensionality Reduction
Data encoding or transformations are applied so as to obtain
a reduced or “compressed” representation of the original
data.
If the original data can be reconstructed from the compressed
data without any loss of information, the data reduction is
called lossless.
If, instead, we can reconstruct only an approximation of the
original data, then the data reduction is called lossy.
There are several well-tuned algorithms for string
compression. Although they are typically lossless, they allow
only limited manipulation of the data.
Two popular and effective methods of lossy dimensionality
reduction:
Wavelet transforms
36
Data
Compression
s s y
lo
Original Data
Approximated
37
Data Reduction Method:
Clustering
38
Data Reduction Method: Sampling
Sampling: obtaining a small sample s to represent the whole
data set N
Allow a mining algorithm to run in complexity that is
potentially sub-linear to the size of the data
Choose a representative subset of the data
Simple random sampling may have very poor
Approximate the percentage of each class (or
subpopulation of interest) in the overall database
Used in conjunction with skewed data
Note: Sampling may not reduce database I/Os (page at a
time)
39
Sampling: with or without
Replacement
WOR
S RS dom r an
m p l e o ut
( s i wi t h
p l e
sa m m e nt )
p l a ce
re
SRSW
R
Raw Data
40
Sampling: Cluster or Stratified
Sampling
41
Data Preprocessing
45
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 1) S 2 Entropy ( S 2)
|S| |S|