Data Preprocessing
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., Age=42 Birthday=03/07/1997 e.g., Was rating 1,2,3, now rating A, B, C e.g., discrepancy between duplicate records
Data cleaning
Fill in missing values, smooth noisy data, identify or remove outliers, and resolve inconsistencies Integration of multiple databases, data cubes, or files Normalization and aggregation Obtains reduced representation in volume but produces the same or similar analytical results Part of data reduction but with particular importance, especially for numerical data
Data integration
Data transformation
Data reduction
Data discretization
Data Cleaning
Importance Data cleaning is one of the three biggest problems in data warehousingRalph Kimball Data cleaning is the number one problem in data warehousingDCI survey
Fill in missing values Identify outliers and smooth out noisy data Correct inconsistent data Resolve redundancy caused by data integration
Missing Data
E.g., many tuples have no recorded value for several attributes, such as customer income in sales data equipment malfunction
Ignore the tuple: usually done when class label is missing (assuming the tasks in classificationnot 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
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 Other data problems which requires data cleaning duplicate records incomplete data inconsistent 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
Regression
y
Y1
Y1
y=x+1
X1
Cluster Analysis
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
correlation analysis
Careful integration of the data from multiple sources may help reduce/avoid redundancies and inconsistencies and improve mining speed and quality
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 (As values increase as Bs). The higher, the stronger correlation.
rA,B = 0: independent; rA,B < 0: negatively correlated
Data Mining: Concepts and Techniques 14
Data Transformation
min-max normalization z-score normalization normalization by decimal scaling New attributes constructed from the given ones
Data Mining: Concepts and Techniques 15
Attribute/feature construction
v'
Ex. Let income range $12,000 to $98,000 normalized to [0.0, 73 1.0]. Then $73,000 is mapped to 98,,600 12,,000 (1.0 0) 0 0.716 000 12 000
v'
v A
v v' j 10
July 14, 2012
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
Data Mining: Concepts and Techniques 17
The aggregated data for an individual entity of interest E.g., a customer in a phone calling data warehouse
Queries regarding aggregated information should be answered using data cube, when possible
Data Mining: Concepts and Techniques 18
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
Data Mining: Concepts and Techniques 19
Class 1
>
July 14, 2012
Class 2
Class 1
Class 2
Haar2
Daubechie4
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 0s, 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
Data Mining: Concepts and Techniques 21
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 Compute k orthonormal (unit) vectors, i.e., principal components Each input data (vector) is a linear combination of the k principal 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 reduced by eliminating the weak components, i.e., those with low variance. (i.e., using the strongest principal components, it is possible to reconstruct a good approximation of the original data Works for numeric data only Used when the number of dimensions is large
Data Mining: Concepts and Techniques 22
Numerosity Reduction
Reduce data volume by choosing alternative, smaller forms of data representation Parametric methods Assume the data fits some model, estimate model parameters, store only the parameters, and discard the data (except possible outliers) Example: Log-linear modelsobtain value at a point in m-D space as the product on appropriate marginal subspaces Non-parametric methods Do not assume models Major families: histograms, clustering, sampling
Data Mining: Concepts and Techniques 23
Discretization
Discretization:
Divide the range of a continuous attribute into intervals Some classification algorithms only accept categorical attributes. Reduce data size by discretization Prepare for further analysis
24
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
25
26
Specification of a partial/total ordering of attributes explicitly at the schema level by users or experts
Some hierarchies can be automatically generated based on the analysis of the number of distinct values per attribute in the data set The attribute with the most distinct values is placed at the lowest level of the hierarchy
27
country
15 distinct values
365 distinct values 3567 distinct values
province_or_ state
city street
28