Data Preprocessing n Data cleaning n Data integration

  • Slides: 48
Download presentation
Data Preprocessing n Data cleaning n Data integration and transformation n Data reduction n

Data Preprocessing n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n Summary 9/10/2020 Data Mining: Concepts and Techniques 1

Multi-Dimensional Measure of Data Quality n n 9/10/2020 A well-accepted multidimensional view: n Accuracy

Multi-Dimensional Measure of Data Quality n n 9/10/2020 A well-accepted multidimensional view: n Accuracy n Completeness n Consistency n Timeliness n Believability n Value added n Interpretability n Accessibility Broad categories: n intrinsic, contextual, representational, and accessibility. Data Mining: Concepts and Techniques 2

Major Tasks in Data Preprocessing n Data cleaning n n Data integration n n

Major Tasks in Data Preprocessing n Data cleaning n n Data integration n n Obtains reduced representation in volume but produces the same or similar analytical results Data discretization n 9/10/2020 Normalization and aggregation Data reduction n n Integration of multiple databases, data cubes, or files Data transformation n n Fill in missing values, smooth noisy data, identify or remove outliers, and resolve inconsistencies Part of data reduction but with particular importance, especially for numerical data Data Mining: Concepts and Techniques 3

Forms of data preprocessing 9/10/2020 Data Mining: Concepts and Techniques 4

Forms of data preprocessing 9/10/2020 Data Mining: Concepts and Techniques 4

Data Cleaning n 9/10/2020 Data cleaning tasks n Fill in missing values n Identify

Data Cleaning n 9/10/2020 Data cleaning tasks n Fill in missing values n Identify outliers and smooth out noisy data n Correct inconsistent data Data Mining: Concepts and Techniques 5

Missing Data n Data is not always available n n Missing data may be

Missing Data n Data is not always available n n Missing data may be due to n equipment malfunction n inconsistent with other recorded data and thus deleted n data not entered due to misunderstanding n n n 9/10/2020 E. g. , many tuples have no recorded value for several attributes, such as customer income in sales data 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. Data Mining: Concepts and Techniques 6

How to Handle Missing Data? n Ignore the tuple: usually done when class label

How to Handle Missing Data? n 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. n Fill in the missing value manually: tedious + infeasible? n Use a global constant to fill in the missing value: e. g. , “unknown”, a new class? ! n Use the attribute mean to fill in the missing value n Use the attribute mean for all samples belonging to the same class to fill in the missing value: smarter n Use the most probable value to fill in the missing value: inferencebased such as Bayesian formula or decision tree 9/10/2020 Data Mining: Concepts and Techniques 7

Noisy Data n n n Noise: random error or variance in a measured variable

Noisy Data n n n Noise: random error or variance in a measured variable Incorrect attribute values may due to n faulty data collection instruments n data entry problems n data transmission problems n technology limitation n inconsistency in naming convention Other data problems which requires data cleaning n duplicate records n incomplete data n inconsistent data 9/10/2020 Data Mining: Concepts and Techniques 8

How to Handle Noisy Data? n n Binning method: n first sort data and

How to Handle Noisy Data? n n Binning method: n first sort data and partition into (equi-depth) bins n then one can smooth by bin means, smooth by bin median, smooth by bin boundaries, etc. Clustering n detect and remove outliers Combined computer and human inspection n detect suspicious values and check by human Regression n smooth by fitting the data into regression functions 9/10/2020 Data Mining: Concepts and Techniques 9

Simple Discretization Methods: Binning n n Equal-width (distance) partitioning: n It divides the range

Simple Discretization Methods: Binning n n Equal-width (distance) partitioning: n It divides the range into N intervals of equal size: uniform grid n if A and B are the lowest and highest values of the attribute, the width of intervals will be: W = (B-A)/N. n The most straightforward n But outliers may dominate presentation n Skewed data is not handled well. Equal-depth (frequency) partitioning: n It divides the range into N intervals, each containing approximately same number of samples n Good data scaling n Managing categorical attributes can be tricky. 9/10/2020 Data Mining: Concepts and Techniques 10

Binning Methods for Data Smoothing * Sorted data for price (in dollars): 4, 8,

Binning Methods for Data Smoothing * Sorted data for price (in dollars): 4, 8, 9, 15, 21, 24, 25, 26, 28, 29, 34 * Partition into (equi-depth) bins: - Bin 1: 4, 8, 9, 15 - Bin 2: 21, 24, 25 - Bin 3: 26, 28, 29, 34 * Smoothing by bin means: - Bin 1: 9, 9, 9, 9 - Bin 2: 23, 23, 23 - Bin 3: 29, 29, 29 * Smoothing by bin boundaries: - Bin 1: 4, 4, 4, 15 - Bin 2: 21, 25, 25 - Bin 3: 26, 26, 34 9/10/2020 Data Mining: Concepts and Techniques 11

Cluster Analysis 9/10/2020 Data Mining: Concepts and Techniques 12

Cluster Analysis 9/10/2020 Data Mining: Concepts and Techniques 12

Regression y Y 1 y=x+1 Y 1’ X 1 9/10/2020 Data Mining: Concepts and

Regression y Y 1 y=x+1 Y 1’ X 1 9/10/2020 Data Mining: Concepts and Techniques x 13

Regression n Linear regression: Y = + X n Two parameters , and specify

Regression n Linear regression: Y = + X n Two parameters , and specify the line and are to be estimated by using the data at hand. Multiple regression: Y = b 0 + b 1 X 1 + b 2 X 2. n Y= + X+e n n n 9/10/2020 To find and requires only two pairs of <x, y>. This, however, may generate some errors. e is an estimate of the error for other pairs. Given x 1, x 2, x 3, …, xk, and y 1, y 2, y 3, …, yk we need to find such and that minimizes a cumulative error: Sum(ei) = Sum(yi- - xi)^2 Data Mining: Concepts and Techniques 14

Regression n Log-linear models: n The multi-way table of joint probabilities is approximated by

Regression n Log-linear models: n The multi-way table of joint probabilities is approximated by a product of lower-order tables. ab ac ad bcd p = (e^( + x 1))/(1+ e^( + x 1)) n Probability: p(a, b, c, d) = n Example:

Data Integration n Data integration: n combines data from multiple sources into a coherent

Data Integration n Data integration: n combines data from multiple sources into a coherent store Schema integration n integrate metadata from different sources n Entity identification problem: identify real world entities from multiple data sources, e. g. , A. cust-id B. cust-# Detecting and resolving data value conflicts n for the same real world entity, attribute values from different sources are different n possible reasons: different representations, different scales, e. g. , metric vs. British units 9/10/2020 Data Mining: Concepts and Techniques 16

Handling Redundant Data in Data Integration n Redundant data occur often when integration of

Handling Redundant Data in Data Integration n Redundant data occur often when integration of multiple databases n n The same attribute may have different names in different databases One attribute may be a “derived” attribute in another table, e. g. , annual revenue Redundant data may be able to be detected by correlational analysis Careful integration of the data from multiple sources may help reduce/avoid redundancies and inconsistencies and improve mining speed and quality 9/10/2020 Data Mining: Concepts and Techniques 17

Data Transformation n Smoothing: remove noise from data n Aggregation: summarization, data cube construction

Data Transformation n Smoothing: remove noise from data n Aggregation: summarization, data cube construction n Generalization: concept hierarchy climbing n n Normalization: scaled to fall within a small, specified range n min-max normalization n z-score normalization n normalization by decimal scaling Attribute/feature construction n 9/10/2020 New attributes constructed from the given ones Data Mining: Concepts and Techniques 18

Smoothing n n 9/10/2020 If y= x^2, then we can replace x^2 with t

Smoothing n n 9/10/2020 If y= x^2, then we can replace x^2 with t and to analyse a linear dependence Danger! Do not go too far into data transformation, since some data characteristics can be lost. Who decides: EXPERT Common data transformation for smoothing: p/(1 -p); sqrt, powers, Data Mining: Concepts and Techniques 19

Summarization n Statistical Summarization: n Mean, if known. If not replace with sample mean

Summarization n Statistical Summarization: n Mean, if known. If not replace with sample mean n Sample Mean = sum(x(i))/n n Variance = (sum(x(I)-mean)^2)/n n Standard deviation = sqrt(variance) n n 9/10/2020 Range – difference between largest and smallest data points Skewness = (sum(x(I)-mean)^3)/ (sum(x(I)mean)^(3/2) Data Mining: Concepts and Techniques 20

Data Transformation: Normalization n min-max normalization n z-score normalization n normalization by decimal scaling

Data Transformation: Normalization n min-max normalization n z-score normalization n normalization by decimal scaling Where j is the smallest integer such that Max(| 9/10/2020 Data Mining: Concepts and Techniques |)<1 21

Data Reduction Strategies n n n Warehouse may store terabytes of data: Complex data

Data Reduction Strategies n n n 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 n Obtains a reduced representation of the data set that is much smaller in volume but yet produces the same (or almost the same) analytical results Data reduction strategies n Data cube aggregation n Dimensionality reduction n Numerosity reduction n Discretization and concept hierarchy generation 9/10/2020 Data Mining: Concepts and Techniques 22

Data Cube Aggregation n n The lowest level of a data cube n the

Data Cube Aggregation n n The lowest level of a data cube n the aggregated data for an individual entity of interest n e. g. , a customer in a phone calling data warehouse. Multiple levels of aggregation in data cubes n n Reference appropriate levels n n Further reduce the size of data to deal with Use the smallest representation which is enough to solve the task Queries regarding aggregated information should be answered using data cube, when possible 9/10/2020 Data Mining: Concepts and Techniques 23

Dimensionality Reduction n n Feature selection (i. e. , attribute subset selection): n Select

Dimensionality Reduction n n Feature selection (i. e. , attribute subset selection): n 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 n reduce # of patterns in the patterns, easier to understand Heuristic methods (due to exponential # of choices): n step-wise forward selection n step-wise backward elimination n combining forward selection and backward elimination n decision-tree induction 9/10/2020 Data Mining: Concepts and Techniques 24

Example of Decision Tree Induction Initial attribute set: {A 1, A 2, A 3,

Example of Decision Tree Induction Initial attribute set: {A 1, A 2, A 3, A 4, A 5, A 6} A 4 ? A 6? A 1? Class 1 > 9/10/2020 Class 2 Class 1 Class 2 Reduced attribute set: {A 1, A 4, A 6} Data Mining: Concepts and Techniques 25

Data Compression n String compression n There are extensive theories and well-tuned algorithms n

Data Compression n String compression n There are extensive theories and well-tuned algorithms n Typically lossless n But only limited manipulation is possible without expansion Audio/video compression n Typically lossy compression, with progressive refinement n Sometimes small fragments of signal can be reconstructed without reconstructing the whole Time sequence is not audio n Typically short and vary slowly with time 9/10/2020 Data Mining: Concepts and Techniques 27

Data Compression Compressed Data Original Data lossless Original Data Approximated 9/10/2020 y s s

Data Compression Compressed Data Original Data lossless Original Data Approximated 9/10/2020 y s s lo Data Mining: Concepts and Techniques 28

Numerosity Reduction n Parametric methods n n n 9/10/2020 Assume the data fits some

Numerosity Reduction n Parametric methods n n n 9/10/2020 Assume the data fits some model, estimate model parameters, store only the parameters, and discard the data (except possible outliers) Log-linear models: obtain value at a point in m-D space as the product on appropriate marginal subspaces Non-parametric methods n Do not assume models n Major families: histograms, clustering, sampling Data Mining: Concepts and Techniques 29

Principal Component Analysis n n 9/10/2020 PCA is projection pursuit methods. That is, instead

Principal Component Analysis n n 9/10/2020 PCA is projection pursuit methods. That is, instead of projecting data on either X or Y or Z, etc. we want computer to find better projections that can discover unexpected data patterns. That is we try to find interesting projections Generally, it mean to find a projection onto two dimensional plane that minimizes squared differences between the data points and their projections onto this plane Data Mining: Concepts and Techniques 30

Principal Component Analysis n Given N data vectors from k-dimensions, find c <= k

Principal Component Analysis n Given N data vectors from k-dimensions, find c <= k orthogonal vectors that can be best used to represent data n n The original data set is reduced to one consisting of N data vectors on c principal components (reduced dimensions) Each data vector is a linear combination of the c principal component vectors n Works for numeric data only n Used when the number of dimensions is large 9/10/2020 Data Mining: Concepts and Techniques 31

Principal Component Analysis n n n Suppose that X is Nx. P data matrix.

Principal Component Analysis n n n Suppose that X is Nx. P data matrix. Rows represent tuples in the database selected for analysis. We look at x now as x^T. The value of each data attribute is mean-centered We select the a column of weghts a that result in the largest variance n a^T X a is a variance along a. n We impose a normalization constraint a^T a = 1 n 9/10/2020 (V-Gamma I)a= 0 Gamma is to be found in this equation Data Mining: Concepts and Techniques 32

Principal Component Analysis X 2 Y 1 Y 2 X 1 9/10/2020 Data Mining:

Principal Component Analysis X 2 Y 1 Y 2 X 1 9/10/2020 Data Mining: Concepts and Techniques 33

Histograms n n A popular data reduction technique Divide data into buckets and store

Histograms n n A popular data reduction technique Divide data into buckets and store average (sum) for each bucket Can be constructed optimally in one dimension using dynamic programming Related to quantization problems. 9/10/2020 Data Mining: Concepts and Techniques 34

Clustering n Partition data set into clusters, and one can store cluster representation only

Clustering n Partition data set into clusters, and one can store cluster representation only n Can be very effective if data is clustered but not if data is “smeared” n Can have hierarchical clustering and be stored in multidimensional index tree structures n There are many choices of clustering definitions and clustering algorithms, further detailed in Chapter 8 9/10/2020 Data Mining: Concepts and Techniques 35

Sampling n n Allow a mining algorithm to run in complexity that is potentially

Sampling n 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 n Simple random sampling may have very poor performance in the presence of skew Develop adaptive sampling methods n Stratified sampling: n Approximate the percentage of each class (or subpopulation of interest) in the overall database n Used in conjunction with skewed data Sampling may not reduce database I/Os (page at a time). 9/10/2020 Data Mining: Concepts and Techniques 36

Sampling R O W SRS le random t p u o m i h

Sampling R O W SRS le random t p u o m i h t s ( wi e l p sam ment) e c a l p re SRSW R Raw Data 9/10/2020 Data Mining: Concepts and Techniques 37

Sampling Raw Data 9/10/2020 Cluster/Stratified Sample Data Mining: Concepts and Techniques 38

Sampling Raw Data 9/10/2020 Cluster/Stratified Sample Data Mining: Concepts and Techniques 38

Hierarchical Reduction n n Use multi-resolution structure with different degrees of reduction Hierarchical clustering

Hierarchical Reduction n n Use multi-resolution structure with different degrees of reduction Hierarchical clustering is often performed but tends to define partitions of data sets rather than “clusters” Parametric methods are usually not amenable to hierarchical representation Hierarchical aggregation n An index tree hierarchically divides a data set into partitions by value range of some attributes n Each partition can be considered as a bucket n Thus an index tree with aggregates stored at each node is a hierarchical histogram 9/10/2020 Data Mining: Concepts and Techniques 39

Discretization n n 9/10/2020 Three types of attributes: n Nominal — values from an

Discretization n n 9/10/2020 Three types of attributes: n Nominal — values from an unordered set n Ordinal — values from an ordered set n Continuous — real numbers Discretization: * divide the range of a continuous attribute into intervals n Some classification algorithms only accept categorical attributes. n Reduce data size by discretization n Prepare for further analysis Data Mining: Concepts and Techniques 40

Discretization and Concept hierachy n Discretization n n Concept hierarchies n 9/10/2020 reduce the

Discretization and Concept hierachy n Discretization n n Concept hierarchies n 9/10/2020 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. reduce the data by collecting and replacing low level concepts (such as numeric values for the attribute age) by higher level concepts (such as young, middle -aged, or senior). Data Mining: Concepts and Techniques 41

Discretization and concept hierarchy generation for numeric data n Binning (see sections before) n

Discretization and concept hierarchy generation for numeric data n Binning (see sections before) n Histogram analysis (see sections before) n Clustering analysis (see sections before) n Entropy-based discretization n Segmentation by natural partitioning 9/10/2020 Data Mining: Concepts and Techniques 42

Entropy-Based Discretization n n Given a set of samples S, if S is partitioned

Entropy-Based Discretization n n Given a set of samples S, if S is partitioned into two intervals S 1 and S 2 using boundary T, the entropy after partitioning is The boundary that minimizes the entropy function over all possible boundaries is selected as a binary discretization. The process is recursively applied to partitions obtained until some stopping criterion is met, e. g. , Experiments show that it may reduce data size and improve classification accuracy 9/10/2020 Data Mining: Concepts and Techniques 43

Segmentation by natural partitioning 3 -4 -5 rule can be used to segment numeric

Segmentation by natural partitioning 3 -4 -5 rule can be used to segment numeric data into relatively uniform, “natural” intervals. * If an interval covers 3, 6, 7 or 9 distinct values at the most significant digit, partition the range into 3 equiwidth intervals * If it covers 2, 4, or 8 distinct values at the most significant digit, partition the range into 4 intervals * If it covers 1, 5, or 10 distinct values at the most significant digit, partition the range into 5 intervals 9/10/2020 Data Mining: Concepts and Techniques 44

Example of 3 -4 -5 rule count Step 1: Step 2: -$351 -$159 Min

Example of 3 -4 -5 rule count Step 1: Step 2: -$351 -$159 Min Low (i. e, 5%-tile) msd=1, 000 profit High(i. e, 95%-0 tile) Low=-$1, 000 (-$1, 000 - 0) (-$400 - 0) (-$200 -$100) (-$100 0) 9/10/2020 Max High=$2, 000 ($1, 000 - $2, 000) (0 -$ 1, 000) (-$4000 -$5, 000) Step 4: (-$300 -$200) $4, 700 (-$1, 000 - $2, 000) Step 3: (-$400 -$300) $1, 838 ($1, 000 - $2, 000) (0 - $1, 000) (0 $200) ($1, 000 $1, 200) ($200 $400) ($1, 200 $1, 400) ($1, 400 $1, 600) ($400 $600) ($600 $800) ($800 $1, 000) ($1, 600 ($1, 800) $2, 000) Data Mining: Concepts and Techniques ($2, 000 - $5, 000) ($2, 000 $3, 000) ($3, 000 $4, 000) ($4, 000 $5, 000) 45

Concept hierarchy generation for categorical data n n Specification of a partial ordering of

Concept hierarchy generation for categorical data n n Specification of a partial ordering of attributes explicitly at the schema level by users or experts Specification of a portion of a hierarchy by explicit data grouping n Specification of a set of attributes, but not of their partial ordering n 9/10/2020 Specification of only a partial set of attributes Data Mining: Concepts and Techniques 46

Specification of a set of attributes Concept hierarchy can be automatically generated based on

Specification of a set of attributes Concept hierarchy can be automatically generated based on the number of distinct values per attribute in the given attribute set. The attribute with the most distinct values is placed at the lowest level of the hierarchy. country province_or_ state 65 distinct values city 3567 distinct values street 9/10/2020 15 distinct values 674, 339 distinct values Data Mining: Concepts and Techniques 47

Summary n Data preparation is a big issue for both warehousing and mining n

Summary n Data preparation is a big issue for both warehousing and mining n n Data preparation includes n Data cleaning and data integration n Data reduction and feature selection n Discretization A lot a methods have been developed but still an active area of research 9/10/2020 Data Mining: Concepts and Techniques 48

References n D. P. Ballou and G. K. Tayi. Enhancing data quality in data

References n D. P. Ballou and G. K. Tayi. Enhancing data quality in data warehouse environments. Communications of ACM, 42: 73 -78, 1999. n Jagadish et al. , Special Issue on Data Reduction Techniques. Bulletin of the Technical Committee on Data Engineering, 20(4), December 1997. n D. Pyle. Data Preparation for Data Mining. Morgan Kaufmann, 1999. n T. Redman. Data Quality: Management and Technology. Bantam Books, New York, 1992. n Y. Wand R. Wang. Anchoring data quality dimensions ontological foundations. Communications of ACM, 39: 86 -95, 1996. n 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. 9/10/2020 Data Mining: Concepts and Techniques 49