SlideShare a Scribd company logo
Prof. Pier Luca Lanzi
Data Preparation
Data Mining andText Mining (UIC 583 @ Politecnico di Milano)
Prof. Pier Luca Lanzi
Why Data Preprocessing?
•  Data in the real world are “dirty”
•  They are usually incomplete
§ Missing attribute values
§ Missing attributes of interest, or containing only aggregate data
•  They are usually noisy, containing errors or outliers
§ e.g., Salary=“-10”
•  They are usually inconsistent and contain discrepancies
§ 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
2
Prof. Pier Luca Lanzi
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
3
Prof. Pier Luca Lanzi
Why Is Data Preprocessing Important?
•  No quality in data, no quality in the mining results!
(trash in, trash out)
•  Quality decisions needs quality in data
•  E.g., duplicate or missing data may cause incorrect or even
misleading statistics.
•  Data warehouses need consistent integration of quality data
•  Data extraction, cleaning, and transformation comprises the
majority of the work of building a data warehouse
4
Prof. Pier Luca Lanzi
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 reduction
§ Dimensionality reduction
§ Numerosity reduction
§ Data compression
•  Data transformation and data discretization
§ Normalization
§ Concept hierarchy generation
5
Prof. Pier Luca Lanzi
Outliers
•  Outliers are data objects with characteristics that are considerably
different than most of the other data objects in the data set
6
Prof. Pier Luca Lanzi
Missing Values
•  Reasons for missing values
§ Information is not collected 
(e.g., people decline to give their age and weight)
§ Attributes may not be applicable to all cases 
(e.g., annual income is not applicable to children)
•  Handling missing values
§ Eliminate Data Objects
§ Estimate Missing Values
§ Ignore the Missing Value During Analysis
§ Replace with all possible values (weighted by their
probabilities)
7
Prof. Pier Luca Lanzi
Duplicate Data
•  Data set may include data objects that are duplicates, or almost
duplicates of one another
•  Major issue when merging data from heterogeous sources
•  Examples: same person with multiple email addresses
•  Data cleaning: process of dealing with duplicate data issues
8
Prof. Pier Luca Lanzi
Data Preprocessing
•  Aggregation
•  Sampling
•  Dimensionality Reduction
•  Feature subset selection
•  Feature creation
•  Discretization and Binarization
9
Prof. Pier Luca Lanzi
Aggregation
•  Combining two or more attributes (or objects) 
into a single attribute (or object)
•  Data reduction
§ Reduce the number of attributes or objects
•  Change of scale
§ Cities aggregated into regions
§ States, countries, etc
•  More “stable” data
§ Aggregated data tends to have less variability
10
Prof. Pier Luca Lanzi
Sampling
•  Sampling is the main technique employed for data selection
•  It is often used for both the preliminary investigation of the data
and the final data analysis.
•  Statisticians sample because obtaining the entire set of data of
interest is too expensive or time consuming
•  Sampling is used in data mining because processing the entire set
of data of interest is too expensive or time consuming
•  Using a sample will work almost as well as using the entire data
sets, if the sample is representative
•  A sample is representative if it has approximately the same
property (of interest) as the original set of data
11
Prof. Pier Luca Lanzi
Types of Sampling
•  Simple Random Sampling
§ There is an equal probability of selecting any particular item
•  Sampling without replacement
§ As each item is selected, it is removed from the population
•  Sampling with replacement
§ Objects are not removed from the population as they are
selected for the sample.
§ In sampling with replacement, the same object can 
be picked up more than once
•  Stratified sampling
§ Split the data into several partitions
§ Then draw random samples from each partition
12
Prof. Pier Luca Lanzi
2000 Points8000 points 500 Points
Prof. Pier Luca Lanzi
Sample Size
•  What sample size is necessary to get at least 
one object from each of 10 groups.
14
Prof. Pier Luca Lanzi
Dimensionality Reduction
•  Purpose
§ Avoid curse of dimensionality
§ Reduce amount of time and memory required by data mining
algorithms
§ Allow data to be more easily visualized
§ May help to eliminate irrelevant features or reduce noise
•  Techniques
§ Principle Component Analysis
§ Singular Value Decomposition
§ Others: supervised and non-linear techniques
15
Prof. Pier Luca Lanzi
Dimensionality Reduction: 
Principal Component Analysis (PCA)
•  Given N data vectors from n-dimensions, find k ≤ n orthogonal
vectors (principal components) that can be best used to
represent data
•  Works for numeric data only
•  Used when the number of dimensions is large
16
Prof. Pier Luca Lanzi
Dimensionality Reduction: 
Principal Component Analysis (PCA)
•  Normalize input data
•  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
17
Prof. Pier Luca Lanzi
Dimensionality Reduction: 
Principal Component Analysis (PCA)
•  Goal is to find a projection that captures the largest amount of
variation in data
18
Original axes
**
*
*
*
*
* *
*
*
*
*
*
*
*
*
*
* *
*
*
*
*
*
Data points
First principal componentSecond principal component
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
Prof. Pier Luca Lanzi
Singular Value Decomposition
•  Theorem (Press 1992). It is always possible to decompose matrix
A into A = UΛVT where U, Λ, V are unique
•  U, V are column orthonormal, i.e., columns are unit vectors,
orthogonal to each other, so that UTU = I; VTV = I
•  Li,i are the singular values, they are positive, and sorted in
decreasing order
21
Prof. Pier Luca Lanzi
Singular Value Decomposition
•  Data are viewed as a matrix A with n examples described by m
numerical attributes

A[n x m] = U[n x r] Λ [ r x r] (V[m x r])T
•  A stores the original data
•  U represents the n examples using r new concepts/attributes
•  Λ represents the strength of each ‘concept’ (r is the rank of A)
•  V contain m terms, r concepts
•  Λi,i are called the singular values of A, if A is singular, some of the
wi will be 0; in general rank(A) = number of nonzero wi
•  SVD is mostly unique (up to permutation of singular values, or if
some Li are equal)
22
Prof. Pier Luca Lanzi
Singular Value Decomposition
for Dimensionality Reduction
•  Suppose you want to find best rank-k approximation to A
•  Set all but the largest k singular values to zero
•  Can form compact representation by eliminating columns of U
and V corresponding to zeroed Li
23
1 1 1 0 0
2 2 2 0 0
1 1 1 0 0
5 5 5 0 0
0 0 0 2 2
0 0 0 3 3
0 0 0 1 1
0.18 0
0.36 0
0.18 0
0.90 0
0 0.53
0 0.80
0 0.27
=
9.64 0
0 5.29
x
0.58 0.58 0.58 0 0
0 0 0 0.71 0.71
x
Prof. Pier Luca Lanzi
Singular Value Decomposition
for Dimensionality Reduction
1 1 1 0 0
2 2 2 0 0
1 1 1 0 0
5 5 5 0 0
0 0 0 2 2
0 0 0 3 3
0 0 0 1 1
0.18
0.36
0.18
0.90
0
0
0
~
9.64
x
0.58 0.58 0.58 0 0
x
24
Prof. Pier Luca Lanzi
Singular Value Decomposition
for Dimensionality Reduction
1 1 1 0 0
2 2 2 0 0
1 1 1 0 0
5 5 5 0 0
0 0 0 2 2
0 0 0 3 3
0 0 0 1 1
~
1 1 1 0 0
2 2 2 0 0
1 1 1 0 0
5 5 5 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
25
Prof. Pier Luca Lanzi
Feature Subset Selection
•  Another way to reduce dimensionality of data
•  Redundant features
§ duplicate much or all of the information contained in one or
more other attributes
§ Example: purchase price of a product and the amount of sales
tax paid
•  Irrelevant features
§ contain no information that is useful for the data mining task
at hand
§ Example: students' ID is often irrelevant to the task of
predicting students' GPA
26
Prof. Pier Luca Lanzi
Feature Subset Selection
•  Brute-force approach
§ Try all possible feature subsets as input to data mining algorithm
•  Embedded approaches
§ Feature selection occurs naturally as part of 
the data mining algorithm
•  Filter approaches
§ Features are selected using a procedure that is 
independent from a specific data mining algorithm
§ E.g., attributes are selected based on correlation measures
•  Wrapper approaches
§ Use a data mining algorithm as a black box 
to find best subset of attributes
§ E.g., apply a genetic algorithm and an algorithm for decision tree to
find the best set of features for a decision tree
27
Prof. Pier Luca Lanzi
Example of using the information gain to rank the importance of attributes.
Prof. Pier Luca Lanzi
Decision trees applied to all the attributes.
Prof. Pier Luca Lanzi
Decision trees applied to all the breast dataset without the four least ranked attributes.
Prof. Pier Luca Lanzi
Wrapper approach using exhaustive search and decision trees.
Prof. Pier Luca Lanzi
Feature Creation
•  Create new attributes that can capture the important information
in a data set much more efficiently than the original attributes
•  E.g., given the birthday, create the attribute age
•  Three general methodologies:
§ Feature Extraction: domain-specific
§ Mapping Data to New Space
§ Feature Construction: combining features
32
Prof. Pier Luca Lanzi
Discretization
•  Three types of attributes
§ Nominal: values from an unordered set, e.g., color
§ Ordinal: values from an ordered set, 
e.g., military or academic rank
§ Continuous: real numbers, 
e.g., integer or real numbers
•  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
33
Prof. Pier Luca Lanzi
Discretization Approaches
•  Supervised
§ Attributes are discretized using the class information
§ Generates intervals that tries to minimize the loss of
information about the class
•  Unsupervised
§ Attributes are discretized solely based on their values
34
Prof. Pier Luca Lanzi
Supervised Discretization
•  Entropy based approach
35
3 categories for both x and y 5 categories for both x and y
Prof. Pier Luca Lanzi
Discretization Without Using Class Labels 36
Data Equal interval width
Equal frequency K-means
Prof. Pier Luca Lanzi
Segmentation by Natural Partitioning
•  A simply 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 equi-width intervals (3
equal-width intervals for 3, 6, and 9; and 3 intervals in the
grouping of 2-3-2 for 7)
•  If it covers 2, 4, or 8 distinct values at the most significant digit,
partition the range into 4 intervals
•  If it covers 5 or 10 distinct values at the most significant digit,
partition the range into 5 intervals
37
Prof. Pier Luca Lanzi
Summary
•  Data exploration and preparation, or preprocessing, is a big issue
for both data warehousing and data mining
•  Descriptive data summarization is need for quality data
preprocessing
•  Data preparation includes
§ Data cleaning and data integration
§ Data reduction and feature selection
§ Discretization
•  A lot a methods have been developed but data preprocessing still
an active area of research
38

More Related Content

PDF
DMTM 2015 - 03 Data Representation
PDF
DMTM 2015 - 19 Graph Mining
PDF
DMTM Lecture 16 Association rules
PDF
DMTM 2015 - 17 Text Mining Part 1
PDF
DMTM 2015 - 10 Introduction to Classification
PDF
DMTM 2015 - 13 Naive bayes, Nearest Neighbours and Other Methods
PDF
DMTM 2015 - 04 Data Exploration
PDF
DMTM 2015 - 18 Text Mining Part 2
DMTM 2015 - 03 Data Representation
DMTM 2015 - 19 Graph Mining
DMTM Lecture 16 Association rules
DMTM 2015 - 17 Text Mining Part 1
DMTM 2015 - 10 Introduction to Classification
DMTM 2015 - 13 Naive bayes, Nearest Neighbours and Other Methods
DMTM 2015 - 04 Data Exploration
DMTM 2015 - 18 Text Mining Part 2

What's hot (20)

PDF
DMTM 2015 - 06 Introduction to Clustering
PDF
DMTM Lecture 20 Data preparation
PDF
DMTM Lecture 17 Text mining
PDF
DMTM Lecture 05 Data representation
PDF
DMTM Lecture 09 Other classificationmethods
PDF
DMTM 2015 - 09 Density Based Clustering
PDF
DMTM Lecture 02 Data mining
PDF
DMTM Lecture 04 Classification
PDF
DMTM Lecture 11 Clustering
PDF
DMTM Lecture 19 Data exploration
PDF
DMTM Lecture 10 Classification ensembles
PDF
DMTM 2015 - 11 Decision Trees
PDF
DMTM Lecture 15 Clustering evaluation
PDF
DMTM Lecture 07 Decision trees
PDF
DMTM Lecture 03 Regression
PDF
DMTM 2015 - 15 Classification Ensembles
PDF
DMTM 2015 - 14 Evaluation of Classification Models
PDF
DMTM 2015 - 08 Representative-Based Clustering
PDF
DMTM Lecture 06 Classification evaluation
PDF
An Overview of Naïve Bayes Classifier
DMTM 2015 - 06 Introduction to Clustering
DMTM Lecture 20 Data preparation
DMTM Lecture 17 Text mining
DMTM Lecture 05 Data representation
DMTM Lecture 09 Other classificationmethods
DMTM 2015 - 09 Density Based Clustering
DMTM Lecture 02 Data mining
DMTM Lecture 04 Classification
DMTM Lecture 11 Clustering
DMTM Lecture 19 Data exploration
DMTM Lecture 10 Classification ensembles
DMTM 2015 - 11 Decision Trees
DMTM Lecture 15 Clustering evaluation
DMTM Lecture 07 Decision trees
DMTM Lecture 03 Regression
DMTM 2015 - 15 Classification Ensembles
DMTM 2015 - 14 Evaluation of Classification Models
DMTM 2015 - 08 Representative-Based Clustering
DMTM Lecture 06 Classification evaluation
An Overview of Naïve Bayes Classifier
Ad

Viewers also liked (17)

PDF
Focus Junior - 14 Maggio 2016
PDF
DMTM 2015 - 12 Classification Rules
PDF
DMTM 2015 - 07 Hierarchical Clustering
PDF
Course Introduction
PDF
DMTM 2015 - 02 Data Mining
PDF
DMTM 2015 - 01 Course Introduction
PDF
Course Organization
PDF
DMTM 2015 - 05 Association Rules
PDF
Machine Learning and Data Mining: 12 Classification Rules
PDF
Transparency in Game Mechanics
PDF
Idea Generation and Conceptualization
PDF
Game Balancing
PPTX
Introduction to Procedural Content Generation - Codemotion 29 Novembre 2014
PDF
Working with Formal Elements
PDF
The Structure of Games
PDF
The Design Document
PDF
Elements for the Theory of Fun
Focus Junior - 14 Maggio 2016
DMTM 2015 - 12 Classification Rules
DMTM 2015 - 07 Hierarchical Clustering
Course Introduction
DMTM 2015 - 02 Data Mining
DMTM 2015 - 01 Course Introduction
Course Organization
DMTM 2015 - 05 Association Rules
Machine Learning and Data Mining: 12 Classification Rules
Transparency in Game Mechanics
Idea Generation and Conceptualization
Game Balancing
Introduction to Procedural Content Generation - Codemotion 29 Novembre 2014
Working with Formal Elements
The Structure of Games
The Design Document
Elements for the Theory of Fun
Ad

Similar to DMTM 2015 - 16 Data Preparation (20)

PPTX
Data .pptx
PPT
Data preprocessing 2
PPTX
machine learning.pptx
PPT
data clean.ppt
PPT
Data1
PPT
Data1
PPTX
Data reduction
PPT
Pre-Processing and Data Preparation
PDF
AIML_UNIT 2 _PPT_HAND NOTES_MPS.pdf
PPT
Datapreprocessingppt
PPT
Data preperation
PPT
Data preparation
PPT
Data preparation
PPT
Data preparation
PPT
Data preparation
PPT
Data preperation
PPT
Data preperation
PDF
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
PPT
Data Mining
PDF
Lecture 01 Data Mining
Data .pptx
Data preprocessing 2
machine learning.pptx
data clean.ppt
Data1
Data1
Data reduction
Pre-Processing and Data Preparation
AIML_UNIT 2 _PPT_HAND NOTES_MPS.pdf
Datapreprocessingppt
Data preperation
Data preparation
Data preparation
Data preparation
Data preparation
Data preperation
Data preperation
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
Data Mining
Lecture 01 Data Mining

More from Pier Luca Lanzi (16)

PDF
11 Settembre 2021 - Giocare con i Videogiochi
PDF
Breve Viaggio al Centro dei Videogiochi
PDF
Global Game Jam 19 @ POLIMI - Morning Welcome
PPTX
Data Driven Game Design @ Campus Party 2018
PDF
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
PDF
GGJ18 al Politecnico di Milano - Presentazione di apertura
PDF
Presentation for UNITECH event - January 8, 2018
PDF
DMTM Lecture 18 Graph mining
PDF
DMTM Lecture 14 Density based clustering
PDF
DMTM Lecture 13 Representative based clustering
PDF
DMTM Lecture 12 Hierarchical clustering
PDF
DMTM Lecture 08 Classification rules
PDF
DMTM Lecture 01 Introduction
PDF
VDP2016 - Lecture 16 Rendering pipeline
PDF
VDP2016 - Lecture 15 PCG with Unity
PDF
VDP2016 - Lecture 14 Procedural content generation
11 Settembre 2021 - Giocare con i Videogiochi
Breve Viaggio al Centro dei Videogiochi
Global Game Jam 19 @ POLIMI - Morning Welcome
Data Driven Game Design @ Campus Party 2018
GGJ18 al Politecnico di Milano - Presentazione che precede la presentazione d...
GGJ18 al Politecnico di Milano - Presentazione di apertura
Presentation for UNITECH event - January 8, 2018
DMTM Lecture 18 Graph mining
DMTM Lecture 14 Density based clustering
DMTM Lecture 13 Representative based clustering
DMTM Lecture 12 Hierarchical clustering
DMTM Lecture 08 Classification rules
DMTM Lecture 01 Introduction
VDP2016 - Lecture 16 Rendering pipeline
VDP2016 - Lecture 15 PCG with Unity
VDP2016 - Lecture 14 Procedural content generation

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Classroom Observation Tools for Teachers
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
Pre independence Education in Inndia.pdf
PDF
Business Ethics Teaching Materials for college
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
master seminar digital applications in india
PDF
VCE English Exam - Section C Student Revision Booklet
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Classroom Observation Tools for Teachers
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
O7-L3 Supply Chain Operations - ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Final Presentation General Medicine 03-08-2024.pptx
Cell Types and Its function , kingdom of life
Pre independence Education in Inndia.pdf
Business Ethics Teaching Materials for college
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Cell Structure & Organelles in detailed.
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Module 4: Burden of Disease Tutorial Slides S2 2025
master seminar digital applications in india
VCE English Exam - Section C Student Revision Booklet

DMTM 2015 - 16 Data Preparation

  • 1. Prof. Pier Luca Lanzi Data Preparation Data Mining andText Mining (UIC 583 @ Politecnico di Milano)
  • 2. Prof. Pier Luca Lanzi Why Data Preprocessing? •  Data in the real world are “dirty” •  They are usually incomplete § Missing attribute values § Missing attributes of interest, or containing only aggregate data •  They are usually noisy, containing errors or outliers § e.g., Salary=“-10” •  They are usually inconsistent and contain discrepancies § 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 2
  • 3. Prof. Pier Luca Lanzi 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 3
  • 4. Prof. Pier Luca Lanzi Why Is Data Preprocessing Important? •  No quality in data, no quality in the mining results! (trash in, trash out) •  Quality decisions needs quality in data •  E.g., duplicate or missing data may cause incorrect or even misleading statistics. •  Data warehouses need consistent integration of quality data •  Data extraction, cleaning, and transformation comprises the majority of the work of building a data warehouse 4
  • 5. Prof. Pier Luca Lanzi 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 reduction § Dimensionality reduction § Numerosity reduction § Data compression •  Data transformation and data discretization § Normalization § Concept hierarchy generation 5
  • 6. Prof. Pier Luca Lanzi Outliers •  Outliers are data objects with characteristics that are considerably different than most of the other data objects in the data set 6
  • 7. Prof. Pier Luca Lanzi Missing Values •  Reasons for missing values § Information is not collected (e.g., people decline to give their age and weight) § Attributes may not be applicable to all cases (e.g., annual income is not applicable to children) •  Handling missing values § Eliminate Data Objects § Estimate Missing Values § Ignore the Missing Value During Analysis § Replace with all possible values (weighted by their probabilities) 7
  • 8. Prof. Pier Luca Lanzi Duplicate Data •  Data set may include data objects that are duplicates, or almost duplicates of one another •  Major issue when merging data from heterogeous sources •  Examples: same person with multiple email addresses •  Data cleaning: process of dealing with duplicate data issues 8
  • 9. Prof. Pier Luca Lanzi Data Preprocessing •  Aggregation •  Sampling •  Dimensionality Reduction •  Feature subset selection •  Feature creation •  Discretization and Binarization 9
  • 10. Prof. Pier Luca Lanzi Aggregation •  Combining two or more attributes (or objects) into a single attribute (or object) •  Data reduction § Reduce the number of attributes or objects •  Change of scale § Cities aggregated into regions § States, countries, etc •  More “stable” data § Aggregated data tends to have less variability 10
  • 11. Prof. Pier Luca Lanzi Sampling •  Sampling is the main technique employed for data selection •  It is often used for both the preliminary investigation of the data and the final data analysis. •  Statisticians sample because obtaining the entire set of data of interest is too expensive or time consuming •  Sampling is used in data mining because processing the entire set of data of interest is too expensive or time consuming •  Using a sample will work almost as well as using the entire data sets, if the sample is representative •  A sample is representative if it has approximately the same property (of interest) as the original set of data 11
  • 12. Prof. Pier Luca Lanzi Types of Sampling •  Simple Random Sampling § There is an equal probability of selecting any particular item •  Sampling without replacement § As each item is selected, it is removed from the population •  Sampling with replacement § Objects are not removed from the population as they are selected for the sample. § In sampling with replacement, the same object can be picked up more than once •  Stratified sampling § Split the data into several partitions § Then draw random samples from each partition 12
  • 13. Prof. Pier Luca Lanzi 2000 Points8000 points 500 Points
  • 14. Prof. Pier Luca Lanzi Sample Size •  What sample size is necessary to get at least one object from each of 10 groups. 14
  • 15. Prof. Pier Luca Lanzi Dimensionality Reduction •  Purpose § Avoid curse of dimensionality § Reduce amount of time and memory required by data mining algorithms § Allow data to be more easily visualized § May help to eliminate irrelevant features or reduce noise •  Techniques § Principle Component Analysis § Singular Value Decomposition § Others: supervised and non-linear techniques 15
  • 16. Prof. Pier Luca Lanzi Dimensionality Reduction: Principal Component Analysis (PCA) •  Given N data vectors from n-dimensions, find k ≤ n orthogonal vectors (principal components) that can be best used to represent data •  Works for numeric data only •  Used when the number of dimensions is large 16
  • 17. Prof. Pier Luca Lanzi Dimensionality Reduction: Principal Component Analysis (PCA) •  Normalize input data •  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 17
  • 18. Prof. Pier Luca Lanzi Dimensionality Reduction: Principal Component Analysis (PCA) •  Goal is to find a projection that captures the largest amount of variation in data 18 Original axes ** * * * * * * * * * * * * * * * * * * * * * * Data points First principal componentSecond principal component
  • 21. Prof. Pier Luca Lanzi Singular Value Decomposition •  Theorem (Press 1992). It is always possible to decompose matrix A into A = UΛVT where U, Λ, V are unique •  U, V are column orthonormal, i.e., columns are unit vectors, orthogonal to each other, so that UTU = I; VTV = I •  Li,i are the singular values, they are positive, and sorted in decreasing order 21
  • 22. Prof. Pier Luca Lanzi Singular Value Decomposition •  Data are viewed as a matrix A with n examples described by m numerical attributes A[n x m] = U[n x r] Λ [ r x r] (V[m x r])T •  A stores the original data •  U represents the n examples using r new concepts/attributes •  Λ represents the strength of each ‘concept’ (r is the rank of A) •  V contain m terms, r concepts •  Λi,i are called the singular values of A, if A is singular, some of the wi will be 0; in general rank(A) = number of nonzero wi •  SVD is mostly unique (up to permutation of singular values, or if some Li are equal) 22
  • 23. Prof. Pier Luca Lanzi Singular Value Decomposition for Dimensionality Reduction •  Suppose you want to find best rank-k approximation to A •  Set all but the largest k singular values to zero •  Can form compact representation by eliminating columns of U and V corresponding to zeroed Li 23 1 1 1 0 0 2 2 2 0 0 1 1 1 0 0 5 5 5 0 0 0 0 0 2 2 0 0 0 3 3 0 0 0 1 1 0.18 0 0.36 0 0.18 0 0.90 0 0 0.53 0 0.80 0 0.27 = 9.64 0 0 5.29 x 0.58 0.58 0.58 0 0 0 0 0 0.71 0.71 x
  • 24. Prof. Pier Luca Lanzi Singular Value Decomposition for Dimensionality Reduction 1 1 1 0 0 2 2 2 0 0 1 1 1 0 0 5 5 5 0 0 0 0 0 2 2 0 0 0 3 3 0 0 0 1 1 0.18 0.36 0.18 0.90 0 0 0 ~ 9.64 x 0.58 0.58 0.58 0 0 x 24
  • 25. Prof. Pier Luca Lanzi Singular Value Decomposition for Dimensionality Reduction 1 1 1 0 0 2 2 2 0 0 1 1 1 0 0 5 5 5 0 0 0 0 0 2 2 0 0 0 3 3 0 0 0 1 1 ~ 1 1 1 0 0 2 2 2 0 0 1 1 1 0 0 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25
  • 26. Prof. Pier Luca Lanzi Feature Subset Selection •  Another way to reduce dimensionality of data •  Redundant features § duplicate much or all of the information contained in one or more other attributes § Example: purchase price of a product and the amount of sales tax paid •  Irrelevant features § contain no information that is useful for the data mining task at hand § Example: students' ID is often irrelevant to the task of predicting students' GPA 26
  • 27. Prof. Pier Luca Lanzi Feature Subset Selection •  Brute-force approach § Try all possible feature subsets as input to data mining algorithm •  Embedded approaches § Feature selection occurs naturally as part of the data mining algorithm •  Filter approaches § Features are selected using a procedure that is independent from a specific data mining algorithm § E.g., attributes are selected based on correlation measures •  Wrapper approaches § Use a data mining algorithm as a black box to find best subset of attributes § E.g., apply a genetic algorithm and an algorithm for decision tree to find the best set of features for a decision tree 27
  • 28. Prof. Pier Luca Lanzi Example of using the information gain to rank the importance of attributes.
  • 29. Prof. Pier Luca Lanzi Decision trees applied to all the attributes.
  • 30. Prof. Pier Luca Lanzi Decision trees applied to all the breast dataset without the four least ranked attributes.
  • 31. Prof. Pier Luca Lanzi Wrapper approach using exhaustive search and decision trees.
  • 32. Prof. Pier Luca Lanzi Feature Creation •  Create new attributes that can capture the important information in a data set much more efficiently than the original attributes •  E.g., given the birthday, create the attribute age •  Three general methodologies: § Feature Extraction: domain-specific § Mapping Data to New Space § Feature Construction: combining features 32
  • 33. Prof. Pier Luca Lanzi Discretization •  Three types of attributes § Nominal: values from an unordered set, e.g., color § Ordinal: values from an ordered set, e.g., military or academic rank § Continuous: real numbers, e.g., integer or real numbers •  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 33
  • 34. Prof. Pier Luca Lanzi Discretization Approaches •  Supervised § Attributes are discretized using the class information § Generates intervals that tries to minimize the loss of information about the class •  Unsupervised § Attributes are discretized solely based on their values 34
  • 35. Prof. Pier Luca Lanzi Supervised Discretization •  Entropy based approach 35 3 categories for both x and y 5 categories for both x and y
  • 36. Prof. Pier Luca Lanzi Discretization Without Using Class Labels 36 Data Equal interval width Equal frequency K-means
  • 37. Prof. Pier Luca Lanzi Segmentation by Natural Partitioning •  A simply 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 equi-width intervals (3 equal-width intervals for 3, 6, and 9; and 3 intervals in the grouping of 2-3-2 for 7) •  If it covers 2, 4, or 8 distinct values at the most significant digit, partition the range into 4 intervals •  If it covers 5 or 10 distinct values at the most significant digit, partition the range into 5 intervals 37
  • 38. Prof. Pier Luca Lanzi Summary •  Data exploration and preparation, or preprocessing, is a big issue for both data warehousing and data mining •  Descriptive data summarization is need for quality data preprocessing •  Data preparation includes § Data cleaning and data integration § Data reduction and feature selection § Discretization •  A lot a methods have been developed but data preprocessing still an active area of research 38