Data Mining:
Concepts and Techniques
Jianlin Cheng
Department of Computer Science
University of Missouri, Columbia
Adapted from
©2006 Jiawei Han and Micheline Kamber, All rights reserved
June 19, 2025 Data Mining: Concepts and Techniques 1
Chapter 2: Data Preprocessing
Why preprocess the data?
Descriptive data summarization
Data cleaning
Data integration and transformation
Data reduction
Discretization and concept hierarchy generation
Summary
June 19, 2025 Data Mining: Concepts and Techniques 2
Why Data Preprocessing?
• Data in the real world is dirty
• incomplete: lacking attribute values, lacking certain
attributes of interest, or containing only aggregate data
• e.g., occupation=“ ”
• noisy: containing errors or outliers
• e.g., Salary=“-10”
• inconsistent: containing discrepancies in codes or names
• e.g., Age=“42” Birthday=“03/07/1997”
• e.g., Was rating “1,2,3”, now rating “A, B, C”
• e.g., discrepancy between duplicate records
June 19, 2025 Data Mining: Concepts and Techniques 3
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
June 19, 2025 Data Mining: Concepts and Techniques 4
Why Is Data Preprocessing
Important?
No quality data, no quality mining results!
Quality decisions must be based on quality data
e.g., duplicate or missing data may cause incorrect or even
misleading statistics.
Data warehouse needs consistent integration of quality data
Data extraction, cleaning, and transformation comprises the
majority of the work of building a data warehouse
June 19, 2025 Data Mining: Concepts and Techniques 5
Multi-Dimensional Measure of Data
Quality
A well-accepted multidimensional view:
Accuracy
Completeness
Consistency
Timeliness
Believability
Value added
Interpretability
Accessibility
June 19, 2025 Data Mining: Concepts and Techniques 6
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
June 19, 2025 Data Mining: Concepts and Techniques 7
Forms of Data Preprocessing
June 19, 2025 Data Mining: Concepts and Techniques 8
Chapter 2: Data Preprocessing
Why preprocess the data?
Descriptive data summarization
Data cleaning
Data integration and transformation
Data reduction
Discretization and concept hierarchy generation
Summary
June 19, 2025 Data Mining: Concepts and Techniques 9
Mining Data Descriptive
Characteristics
Motivation
To better understand the data: central tendency, variation and
spread
Data dispersion characteristics
median, mean, max, min, quantiles, outliers, variance, etc.
Numerical dimensions correspond to sorted intervals
Data dispersion
Boxplot or quantile analysis on sorted intervals
June 19, 2025 Data Mining: Concepts and Techniques 10
Measuring the Central Tendency
1 n x
Mean (algebraic measure) (sample vs. population): x xi
n i 1 N
n
Weighted arithmetic mean: w x i i
x i 1
Trimmed mean: chopping extreme values n
w
i 1
i
Median: A holistic measure
Middle value if odd number of values, or average of the middle two
values otherwise
Mode
Value that occurs most frequently in the data
Unimodal, bimodal, trimodal
Empirical formula:
mean mode 3 (mean median)
June 19, 2025 Data Mining: Concepts and Techniques 11
Visualization of Data Dispersion: Boxplot
Analysis
June 19, 2025 Data Mining: Concepts and Techniques 12
Histogram Analysis
Graph displays of basic statistical class descriptions
Frequency histograms
A univariate graphical method
Consists of a set of rectangles that reflect the counts or
frequencies of the classes present in the given data
June 19, 2025 Data Mining: Concepts and Techniques 13
Quantile Plot
Displays all of the data (allowing the user to assess both the
overall behavior and unusual occurrences)
Plots quantile information
For a data xi data sorted in increasing order, fi in range [0, 1]
indicates that approximately 100 fi% of the data are below
or equal to the value xi
June 19, 2025 Data Mining: Concepts and Techniques 14
Quantile-Quantile (Q-Q) Plot
Graphs the quantiles of one univariate distribution against the
corresponding quantiles of another
Allows the user to view whether there is a shift in going from
one distribution to another
June 19, 2025 Data Mining: Concepts and Techniques 15
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
June 19, 2025 Data Mining: Concepts and Techniques 16
Loess Curve
Adds a smooth curve to a scatter plot in order to provide
better perception of the pattern of dependence
Loess curve is fitted by setting two parameters: a smoothing
parameter, and the degree of the polynomials that are fitted
by the regression
June 19, 2025 Data Mining: Concepts and Techniques 17
Positively and Negatively Correlated Data
June 19, 2025 Data Mining: Concepts and Techniques 18
June 19, 2025 Data Mining: Concepts and Techniques 19
Not Correlated Data
June 19, 2025 Data Mining: Concepts and Techniques 20
Graphic Displays of Basic Statistical
Descriptions
Histogram
Boxplot
Quantile plot:each value xi is paired with fi indicating that approximately 100 fi %
of data are xi
Quantile-quantile (q-q) plot: graphs the quantiles of one univariant distribution
against the corresponding quantiles of another
Scatter plot: each pair of values is a pair of coordinates and plotted as points in
the plane
Loess (local regression) curve: add a smooth curve to a scatter plot to provide
better perception of the pattern of dependence
June 19, 2025 Data Mining: Concepts and Techniques 21
Chapter 2: Data Preprocessing
Why preprocess the data?
Descriptive data summarization
Data cleaning
Data integration and transformation
Data reduction
Discretization and concept hierarchy generation
Summary
June 19, 2025 Data Mining: Concepts and Techniques 22
Data Cleaning
• Importance
• “Data cleaning is one of the three biggest problems in
data warehousing”—Ralph Kimball
• “Data cleaning is the number one problem in data
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
June 19, 2025 Data Mining: Concepts and Techniques 23
Missing Data
Data is not always available
E.g., many tuples have no recorded value for several attributes, such
as customer income in sales data
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
Missing data may need to be inferred.
June 19, 2025 Data Mining: Concepts and Techniques 24
Customer Data
Name Age Sex Income Class
Mike 40 Male 150k Big spender
Jenny 20 Female ? Regular
…
June 19, 2025 Data Mining: Concepts and Techniques 25
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 (e.g., predict my age based on the info at my web site?)
June 19, 2025 Data Mining: Concepts and Techniques 26
Noisy Data
Noise: random error or variance in a measured variable
Incorrect attribute values may due to
faulty data collection instruments
data entry problems
data transmission problems
technology limitation
inconsistency in naming convention
June 19, 2025 Data Mining: Concepts and Techniques 27
How to Handle 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)
June 19, 2025 Data Mining: Concepts and Techniques 28
Data Cleaning as a Process
Data discrepancy detection
Use metadata (e.g., domain, range, dependency, distribution) (How
many people are there in Nebraska?)
Check uniqueness rule, consecutive rule and null rule
Use commercial tools
Data scrubbing: use simple domain knowledge (e.g., postal code,
spell-check) to detect errors and make corrections
Data auditing: by analyzing data to discover rules and relationship to
detect violators (e.g., correlation and clustering to find outliers)
June 19, 2025 Data Mining: Concepts and Techniques 29
Chapter 2: Data Preprocessing
Why preprocess the data?
Data cleaning
Data integration and transformation
Data reduction
Discretization and concept hierarchy generation
Summary
June 19, 2025 Data Mining: Concepts and Techniques 30
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
Entity identification problem:
Identify real world entities from multiple data sources, e.g.,
Bill Clinton = William Clinton
Detecting and resolving data value conflicts
For the same real world entity, attribute values from different
sources are different
Possible reasons: different representations, different scales,
e.g., metric vs. British units (e.g., GPA in US and China)
June 19, 2025 Data Mining: Concepts and Techniques 31
Handling Redundancy in Data
Integration
• Redundant data occur often when integration of multiple
databases
• Object identification: The same attribute or object may
have different names in different databases
• Derivable data: One attribute may be a “derived” attribute
in another table, e.g., annual revenue
• Redundant attributes may be able to be detected by correlation
analysis
• Careful integration of the data from multiple sources may help
reduce/avoid redundancies and inconsistencies and improve
mining speed and quality
June 19, 2025 Data Mining: Concepts and Techniques 32
Correlation Analysis (Numerical
Data)
• Correlation coefficient (also called Pearson’s product moment
coefficient)
rA, B
(A A)( B B )
( AB) n AB
( n 1)AB ( n 1)AB
A B
where n is the number of tuples, and 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;DatarA,B
June 19, 2025
< 0: negatively correlated
Mining: Concepts and Techniques 33
Correlation Analysis (Categorical Data)
• Χ2 (chi-square) test (Example: Grade and Sex)
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
• 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 19, 2025 Data Mining: Concepts and Techniques 34
Data Transformation
Smoothing: remove noise from data
Aggregation: summarization
Generalization: concept hierarchy climbing
Normalization: scaled to fall within a small, specified range
min-max normalization
z-score normalization
normalization by decimal scaling
Attribute/feature construction
New attributes constructed from the given ones
June 19, 2025 Data Mining: Concepts and Techniques 35
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 [0.0, 1.0]. Then
73,600 12,000
(1.0 0) 0 0.716
$73,000 is mapped to 98,000 12,000
• Z-score normalization (μ: mean, σ: standard deviation):
v A
v'
A
73,600 54,000
1.225
• Ex. Let μ = 54,000, σ = 16,000. Then 16,000
• Normalization
v by decimal scaling
v' Where j is the smallest integer such that Max(|ν’|) < 1
10 j
June 19, 2025 Data Mining: Concepts and Techniques 36
Chapter 2: Data Preprocessing
Why preprocess the data?
Data cleaning
Data integration and transformation
Data reduction
Discretization and concept hierarchy generation
Summary
June 19, 2025 Data Mining: Concepts and Techniques 37
Data Reduction Strategies
• Why data reduction?
• A database/data warehouse may store terabytes of data
• Complex data analysis/mining may take a very long time to run on the
complete data set
• Data reduction
• Obtain a reduced representation of the data set that is much smaller in
volume but yet produce the same (or almost the same) analytical
results
• Data reduction strategies
• Data cube aggregation:
• Dimensionality reduction — e.g., remove unimportant attributes
• Data Compression
• Numerosity reduction — e.g., fit data into models
• Discretization and concept hierarchy generation
June 19, 2025 Data Mining: Concepts and Techniques 38
Data Cube Aggregation
The lowest level of a data cube (base
cuboid)
The aggregated data for an individual
entity of interest
Multiple levels of aggregation in data cubes
Further reduce the size of data to deal
with
June 19, 2025 Data Mining: Concepts and Techniques 39
Attribute Subset Selection
Feature selection (i.e., attribute subset selection):
Select a minimum set of features such that the probability
distribution of different classes given the values for those
features is as close as possible to the original distribution
given the values of all features
reduce # of patterns in the patterns, easier to understand
Heuristic methods (due to exponential # of choices):
Step-wise forward selection
Step-wise backward elimination
Combining forward selection and backward elimination
Decision-tree induction
June 19, 2025 Data Mining: Concepts and Techniques 40