Ceng 714 Data Mining Data Preprocessing Pnar enkul

  • Slides: 55
Download presentation
Ceng 714 Data Mining Data Preprocessing Pınar Şenkul Resource: J. Han and other books

Ceng 714 Data Mining Data Preprocessing Pınar Şenkul Resource: J. Han and other books 6/9/2021 Data Mining: Concepts and Techniques 1

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n Summary 6/9/2021 Data Mining: Concepts and Techniques 2

Why Data Preprocessing? n Data in the real world is dirty n incomplete: lacking

Why Data Preprocessing? n Data in the real world is dirty n incomplete: lacking attribute values, lacking certain attributes of interest, or containing only aggregate data n n noisy: containing errors or outliers n n e. g. , Salary=“-10” inconsistent: containing discrepancies in codes or names n n n 6/9/2021 e. g. , occupation=“” 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 Mining: Concepts and Techniques 3

Why Is Data Dirty? n Incomplete data comes from n n n 6/9/2021 n/a

Why Is Data Dirty? n Incomplete data comes from n n n 6/9/2021 n/a data value when collected different consideration between the time when the data was collected and when it is analyzed. human/hardware/software problems Noisy data comes from the process of data n collection n entry n transmission Inconsistent data comes from n Different data sources n Functional dependency violation Data Mining: Concepts and Techniques 4

Why Is Data Preprocessing Important? n No quality data, no quality mining results! n

Why Is Data Preprocessing Important? n No quality data, no quality mining results! n Quality decisions must be based on quality data n n n 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. — Bill Inmon 6/9/2021 Data Mining: Concepts and Techniques 5

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

Multi-Dimensional Measure of Data Quality n n 6/9/2021 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 6

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 6/9/2021 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 7

Forms of data preprocessing 6/9/2021 Data Mining: Concepts and Techniques 8

Forms of data preprocessing 6/9/2021 Data Mining: Concepts and Techniques 8

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n Summary 6/9/2021 Data Mining: Concepts and Techniques 9

Data Cleaning n n Importance n “Data cleaning is one of the three biggest

Data Cleaning n n Importance n “Data cleaning is one of the three biggest problems in data warehousing”—Ralph Kimball n “Data cleaning is the number one problem in data warehousing”—DCI survey Data cleaning tasks 6/9/2021 n Fill in missing values n Identify outliers and smooth out noisy data n Correct inconsistent data n Resolve redundancy caused by data integration Data Mining: Concepts and Techniques 10

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 6/9/2021 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 11

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 Fill in it automatically with n a global constant : e. g. , “unknown”, a new class? ! n the attribute mean for all samples belonging to the same class: smarter n the most probable value: inference-based such as Bayesian formula or decision tree 6/9/2021 Data Mining: Concepts and Techniques 12

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 6/9/2021 Data Mining: Concepts and Techniques 13

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 (e. g. , deal with possible outliers) Regression n smooth by fitting the data into regression functions 6/9/2021 Data Mining: Concepts and Techniques 14

Simple Discretization Methods: Binning n n Equal-width (distance) partitioning: n Divides the range into

Simple Discretization Methods: Binning n n Equal-width (distance) partitioning: n 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, but outliers may dominate presentation n Skewed data is not handled well. Equal-depth (frequency) partitioning: n Divides the range into N intervals, each containing approximately same number of samples n Good data scaling n Managing categorical attributes can be tricky. 6/9/2021 Data Mining: Concepts and Techniques 15

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 6/9/2021 Data Mining: Concepts and Techniques 16

Cluster Analysis 6/9/2021 Data Mining: Concepts and Techniques 17

Cluster Analysis 6/9/2021 Data Mining: Concepts and Techniques 17

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

Regression y Y 1 y=x+1 Y 1’ X 1 6/9/2021 Data Mining: Concepts and Techniques x 18

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n Summary 6/9/2021 Data Mining: Concepts and Techniques 19

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 6/9/2021 Data Mining: Concepts and Techniques 20

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

Handling Redundancy 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 6/9/2021 Data Mining: Concepts and Techniques 21

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 6/9/2021 New attributes constructed from the given ones Data Mining: Concepts and Techniques 22

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(| 6/9/2021 Data Mining: Concepts and Techniques |)<1 23

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n Summary 6/9/2021 Data Mining: Concepts and Techniques 24

Data Reduction Strategies n n n A data warehouse may store terabytes of data

Data Reduction Strategies n n n A data warehouse may store terabytes of data n Complex data analysis/mining may take a very long time to run on the complete data set Data reduction n 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 n Data cube aggregation n Dimensionality reduction—remove unimportant attributes n Data Compression n Numerosity reduction—fit data into models n Discretization and concept hierarchy generation 6/9/2021 Data Mining: Concepts and Techniques 25

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 6/9/2021 Data Mining: Concepts and Techniques 26

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 6/9/2021 Data Mining: Concepts and Techniques 27

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 > 6/9/2021 Class 2 Class 1 Class 2 Reduced attribute set: {A 1, A 4, A 6} Data Mining: Concepts and Techniques 28

Data Compression n 6/9/2021 String compression n There are extensive theories and well-tuned algorithms

Data Compression n 6/9/2021 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 Data Mining: Concepts and Techniques 30

Data Compression Compressed Data Original Data lossless Original Data Approximated 6/9/2021 y s s

Data Compression Compressed Data Original Data lossless Original Data Approximated 6/9/2021 y s s lo Data Mining: Concepts and Techniques 31

Wavelet Transformation Haar 2 n n Discrete wavelet transform (DWT): linear signal processing, multiresolutional

Wavelet Transformation Haar 2 n n Discrete wavelet transform (DWT): linear signal processing, multiresolutional analysis Daubechie 4 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: n Length, L, must be an integer power of 2 (padding with 0 s, when necessary) n Each transform has 2 functions: smoothing, difference n Applies to pairs of data, resulting in two set of data of length L/2 n Applies two functions recursively, until reaches the desired length 6/9/2021 Data Mining: Concepts and Techniques 32

DWT for Image Compression n Image Low Pass 6/9/2021 High Pass Data Mining: Concepts

DWT for Image Compression n Image Low Pass 6/9/2021 High Pass Data Mining: Concepts and Techniques 33

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 6/9/2021 Data Mining: Concepts and Techniques 34

Principal Component Analysis X 2 Y 1 Y 2 X 1 6/9/2021 Data Mining:

Principal Component Analysis X 2 Y 1 Y 2 X 1 6/9/2021 Data Mining: Concepts and Techniques 35

Numerosity Reduction n Parametric methods n n n 6/9/2021 Assume the data fits some

Numerosity Reduction n Parametric methods n n n 6/9/2021 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 36

Regression and Log-Linear Models n Linear regression: Data are modeled to fit a straight

Regression and Log-Linear Models n Linear regression: Data are modeled to fit a straight line n n Often uses the least-square method to fit the line Multiple regression: allows a response variable Y to be modeled as a linear function of multidimensional feature vector n Log-linear model: approximates discrete multidimensional probability distributions 6/9/2021 Data Mining: Concepts and Techniques 37

Regress Analysis and Log-Linear Models n Linear regression: Y = + X n Two

Regress Analysis and Log-Linear Models n Linear regression: Y = + X n Two parameters , and specify the line and are to be estimated by using the data at hand. n using the least squares criterion to the known values of Y 1, Y 2, …, X 1, X 2, …. n n Multiple regression: Y = b 0 + b 1 X 1 + b 2 X 2. n Many nonlinear functions can be transformed into the above. Log-linear models: n The multi-way table of joint probabilities is approximated by a product of lower-order tables. n Probability: p(a, b, c, d) = ab ac ad bcd

Histograms n n 6/9/2021 A popular data reduction technique Divide data into buckets and

Histograms n n 6/9/2021 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. Data Mining: Concepts and Techniques 39

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 6/9/2021 Data Mining: Concepts and Techniques 40

Sampling n n 6/9/2021 Allow a mining algorithm to run in complexity that is

Sampling n n 6/9/2021 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). Data Mining: Concepts and Techniques 41

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 6/9/2021 Data Mining: Concepts and Techniques 42

Sampling Raw Data 6/9/2021 Cluster/Stratified Sample Data Mining: Concepts and Techniques 43

Sampling Raw Data 6/9/2021 Cluster/Stratified Sample Data Mining: Concepts and Techniques 43

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 6/9/2021 Data Mining: Concepts and Techniques 44

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n Summary 6/9/2021 Data Mining: Concepts and Techniques 45

Discretization n n 6/9/2021 Three types of attributes: n Nominal — values from an

Discretization n n 6/9/2021 Three types of attributes: n Nominal — values from an unordered set n Ordinal — values from an ordered set n Continuous — real numbers Discretization: n 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 46

Discretization and Concept hierachy n Discretization n n reduce the number of values for

Discretization and Concept hierachy n Discretization n n 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 Concept hierarchies n 6/9/2021 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, middleaged, or senior) Data Mining: Concepts and Techniques 47

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 6/9/2021 Data Mining: Concepts and Techniques 48

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 6/9/2021 Data Mining: Concepts and Techniques 49

Segmentation by Natural Partitioning n A simply 3 -4 -5 rule can be used

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

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) 6/9/2021 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) 51

Concept Hierarchy Generation for Categorical Data n n n Specification of a partial ordering

Concept Hierarchy Generation for Categorical Data n n n Specification of a partial ordering of attributes explicitly at the schema level by users or experts n street<city<state<country Specification of a portion of a hierarchy by explicit data grouping n {Urbana, Champaign, Chicago}<Illinois Specification of a set of attributes. n System automatically generates partial ordering by analysis of the number of distinct values E. g. , street < city <state < country Specification of only a partial set of attributes n E. g. , only street < city, not others n n 6/9/2021 Data Mining: Concepts and Techniques 52

Automatic Concept Hierarchy Generation n Some concept hierarchies can be automatically generated based on

Automatic Concept Hierarchy Generation n Some concept hierarchies can be automatically generated based on the analysis of the number of distinct values per attribute in the given data set n The attribute with the most distinct values is placed at the lowest level of the hierarchy n Note: Exception—weekday, month, quarter, year country province_or_ state 65 distinct values city 3567 distinct values street 6/9/2021 15 distinct values 674, 339 distinct values Data Mining: Concepts and Techniques 53

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data

Chapter 3: Data Preprocessing n Why preprocess the data? n Data cleaning n Data integration and transformation n Data reduction n Discretization and concept hierarchy generation n 6/9/2021 Summary Data Mining: Concepts and Techniques 54

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 6/9/2021 Data Mining: Concepts and Techniques 55

References n E. Rahm and H. H. Do. Data Cleaning: Problems and Current Approaches.

References n E. Rahm and H. H. Do. Data Cleaning: Problems and Current Approaches. IEEE Bulletin of the Technical Committee on Data Engineering. Vol. 23, No. 4 n n n n n D. P. Ballou and G. K. Tayi. Enhancing data quality in data warehouse environments. Communications of ACM, 42: 73 -78, 1999. H. V. Jagadish et al. , Special Issue on Data Reduction Techniques. Bulletin of the Technical Committee on Data Engineering, 20(4), December 1997. A. Maydanchik, Challenges of Efficient Data Cleansing (DM Review - Data Quality resource portal) D. Pyle. Data Preparation for Data Mining. Morgan Kaufmann, 1999. D. Quass. A Framework for research in Data Cleaning. (Draft 1999) V. Raman and J. Hellerstein. Potters Wheel: An Interactive Framework for Data Cleaning and Transformation, VLDB’ 2001. T. Redman. Data Quality: Management and Technology. Bantam Books, New York, 1992. Y. Wand R. Wang. Anchoring data quality dimensions ontological foundations. Communications of ACM, 39: 86 -95, 1996. 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. http: //www. cs. ucla. edu/classes/spring 01/cs 240 b/notes/data-integration 1. pdf 6/9/2021 Data Mining: Concepts and Techniques 56