Data Preprocessing - Updated
Data Preprocessing - Updated
Preprocessing
1
Purpose of Pre-processing
2
Various Steps 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 reduction
Dimensionality reduction
Numerosity reduction
Data compression
Data transformation and data discretization
Normalization
Concept hierarchy generation
3
Data Cleaning
Data in the Real World Is Dirty: Lots of potentially
incorrect data, e.g., instrument faulty, human or
computer error, transmission error
incomplete: lacking attribute values, lacking certain
attributes of interest, or containing only aggregate
data
e.g., City=“ ” (missing data)
noisy: containing noise, errors, or outliers
e.g., Wages=“−10” (an error)
inconsistent: containing discrepancies in codes or
names, e.g.,
Age=“42”, Birthday=“03/07/2020”
Different way of grading like “1, 2, 3”, now rating
“A, B, C”
duplicate records
4
Incomplete (Missing) Data
Data is not always available
E.g., share of broker, customer income
Missing data may be due to
equipment malfunction
inconsistent with other recorded data and thus
deleted
data not entered due to misunderstanding
certain data may not be considered important
at the time of entry
not register history or changes of the data
Missing data may need to be inferred
5
Handling of Missing Data
Ignore the tuple: usually done when class label is
missing (when doing classification)—not effective
when the % 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
6
Noisy Data
Noise: random error or variance in a measured
variable
Incorrect attribute values may be due to
faulty data collection instruments
data entry problems
data transmission problems
technology limitation
inconsistency in naming convention
Other data problems
duplicate records
incomplete data
inconsistent data
7
Handling of Noisy Data
Binning
first sort data and partition into (equal-frequency)
bins
then one can smooth by bin means, smooth by bin
median, smooth by bin boundaries, etc.
Regression
smooth by fitting the data into regression functions
Clustering
detect and remove outliers
Combined computer and human inspection
detect suspicious values and check by human (e.g.,
deal with possible outliers)
8
Handling of Noisy Data: Binning
+ 18) / 2 = 9 1 32
Bin [19-39]: Midpoint = 2 24
3 120
(19 + 39) / 2 = 29 4 42
Bin [40-59]: Midpoint = 5 18
(40 + 59) / 2 = 49.5 6 56
7 6
Bin [60+]: Midpoint = (60 8 70
+ ∞) / 2 = ∞ (Infinity) 9 90
10 28
10
Handling of Noisy Data: Binning
14
Handling of Noisy Data:
Clustering
Dista Dista
Let's calculate the distances:
nce to nce to
For Cluster 1: Distance =
Studen Exam Cluste Cluste
|Exam Score - Cluster 1 center| = |Exam t Score r1 r2
Score - 92.3|
1 85 7.3 23.2
For Cluster 2: Distance = 2 88 4.3 20.2
|Exam Score - Cluster 2 center| = |Exam 3 90 2.3 18.2
Score - 108.2| 4 92 0.3 16.2
Let's calculate the distances for each 5 95 3.3 13.2
student: 6 97 5.3 11.2
data points with distances to both 7 99 7.3 9.2
clusters greater than, for example, 20 as 8 100 8.3 8.2
outliers. 9 101 9.3 7.2
The outliers are students with Exam 10 103 11.3 5.2
Scores: 85, 88, 150. 11 105 13.3 3.2
12 107 15.3 1.2
13 110 17.7 1.8
14 112 19.7 3.8
15 150 57.7 41.8
17
Handling Redundancy in Data
Integration
18
Correlation Analysis (Nominal Data)
Χ2 (chi-square) test
2
(Observed Expected )
2
Expected
The larger the Χ2 value, the more likely the
variables are related
The cells that contribute the most to the Χ2 value
are those whose actual count is very different from
the expected count
19
Chi-Square Calculation: An
Example
Scatter plots
showing the
similarity from
–1 to 1.
22
Covariance (Numeric Data)
Covariance is similar to correlation
Correlation coefficient:
where n is the number of tuples, and are the respective mean
or expected values of A and B, A σ andBσ are the respective
A B
attributes
Wavelet transforms
Principal Components Analysis (PCA)
Feature subset selection, feature creation
Numerosity reduction (some simply call it: Data
Reduction)
Regression and Log-Linear Models
Histograms, clustering, sampling
Data cube aggregation
Data compression 25
Sampling
particular item
Sampling without replacement
Once an object is selected, it is removed from
the population
Sampling with replacement
A selected object is not removed from the
population
Stratified sampling:
Partition the data set, and draw samples from
W O R
SRS le random
i m p ho ut
( s e wi t
l
samp ment)
p l a ce
re
SRSW
R
Raw Data
28
Data Transformation
A function that maps the entire set of values of a given
attribute to a new set of replacement values s.t. each old
value can be identified with one of the new values
Methods
Smoothing: Remove noise from data
Attribute/feature construction
New attributes constructed from the given ones
Aggregation: Summarization, data cube construction
range
min-max normalization
z-score normalization
normalization by decimal scaling
Discretization: Concept hierarchy climbing
29
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
73,600 12,000 normalized to
(1.0 0) 0 0.716
[0.0, 1.0]. Then $73,000 is mapped to
98, 000 12, 000
73,600 54,000
1.225
Ex. Let μ = 54,000, σ = 16,000. Then16,000
Normalization by decimal scaling
v
v' j Where j is the smallest integer such that Max(|ν’|) < 1
10
30
Thanks
31