© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               1
Data Mining: Data
Lecture Notes for Chapter 2
Introduction to Data Mining
by
Tan, Steinbach, Kumar
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               2
Data Preprocessing
lAggregation
lSampling
lDimensionality Reduction
lFeature subset selection
lFeature creation
lDiscretization and Binarization
lAttribute Transformation
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               3
Aggregation
lCombining two or more attributes (or objects) intoa single attribute (or object)
lPurpose
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
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               4
Aggregation
Standard Deviation of AverageMonthly Precipitation
Standard Deviation of AverageYearly Precipitation
Variation of Precipitation in Australia
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               5
Sampling
lSampling is the main technique employed for data selection.
It is often used for both the preliminary investigation of the dataand the final data analysis.
 
lStatisticians sample because obtaining the entire set of dataof interest is too expensive or time consuming.
 
lSampling is used in data mining because processing theentire set of data of interest is too expensive or timeconsuming.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               6
Sampling …
lThe key principle for effective sampling is thefollowing:
using a sample will work almost as well as using theentire data sets, if the sample is representative
A sample is representative if it has approximately thesame property (of interest) as the original set of data
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               7
Types of Sampling
lSimple Random Sampling
There is an equal probability of selecting any particular item
lSampling without replacement
As each item is selected, it is removed from the population
lSampling with replacement
Objects are not removed from the population as they areselected for the sample.
  In sampling with replacement, the same object can be picked upmore than once
lStratified sampling
Split the data into several partitions; then draw random samplesfrom each partition
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               8
Sample Size
 
8000 points         2000 Points500 Points
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               9
Sample Size
lWhat sample size is necessary to get at least oneobject from each of 10 groups.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               10
Curse of Dimensionality
lWhen dimensionalityincreases, data becomesincreasingly sparse in thespace that it occupies
lDefinitions of density anddistance between points,which is critical forclustering and outlierdetection, become lessmeaningful
Randomly generate 500 points
Compute difference between max and mindistance between any pair of points
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               11
Dimensionality Reduction
lPurpose:
Avoid curse of dimensionality
Reduce amount of time and memory required by datamining algorithms
Allow data to be more easily visualized
May help to eliminate irrelevant features or reducenoise
lTechniques
Principle Component Analysis
Singular Value Decomposition
Others: supervised and non-linear techniques
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               12
Dimensionality Reduction: PCA
lGoal is to find a projection that captures thelargest  amount of variation in data
x2
x1
e
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               13
Dimensionality Reduction: PCA
lFind the eigenvectors of the covariance matrix
lThe eigenvectors define the new space
x2
x1
e
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               14
Dimensionality Reduction: PCA
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               15
Feature Subset Selection
lAnother way to reduce dimensionality of data
lRedundant features
duplicate much or all of the information contained inone or more other attributes
Example: purchase price of a product and the amountof sales tax paid
lIrrelevant features
contain no information that is useful for the datamining task at hand
Example: students' ID is often irrelevant to the task ofpredicting students' GPA
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               16
Feature Subset Selection
lTechniques:
Brute-force approch:
Try all possible feature subsets as input to data mining algorithm
Embedded approaches:
 Feature selection occurs naturally as part of the data miningalgorithm
Filter approaches:
 Features are selected before data mining algorithm is run
Wrapper approaches:
 Use the data mining algorithm as a black box to find best subsetof attributes
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               17
Feature Creation
lCreate new attributes that can capture theimportant information in a data set much moreefficiently than the original attributes
lThree general methodologies:
Feature Extraction
 domain-specific
Mapping Data to New Space
Feature Construction
 combining features
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               18
Mapping Data to a New Space
Two Sine Waves
Two Sine Waves + Noise
Frequency
lFourier transform
lWavelet transform
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               19
Discretization Using Class Labels
lEntropy based approach
3 categories for both x and y
5 categories for both x and y
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               20
Discretization Without Using Class Labels
Data
Equal interval width
Equal frequency
K-means
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               21
Attribute Transformation
lA function that maps the entire set of values of agiven attribute to a new set of replacement valuessuch that each old value can be identified withone of the new values
Simple functions: xk, log(x), ex, |x|
Standardization and Normalization
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               22
Similarity and Dissimilarity
lSimilarity
Numerical measure of how alike two data objects are.
Is higher when objects are more alike.
Often falls in the range [0,1]
lDissimilarity
Numerical measure of how different are two dataobjects
Lower when objects are more alike
Minimum dissimilarity is often 0
Upper limit varies
lProximity refers to a similarity or dissimilarity
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               23
Similarity/Dissimilarity for Simple Attributes
p and q are the attribute values for two data objects.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               24
Euclidean Distance
lEuclidean Distance
 
   Where n is the number of dimensions (attributes) and pk and qkare, respectively, the kth attributes (components) or dataobjects p and q.
lStandardization is necessary, if scales differ.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               25
Euclidean Distance
Distance Matrix
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               26
Minkowski Distance
lMinkowski Distance is a generalization of EuclideanDistance
 
   Where r is a parameter, n is the number of dimensions(attributes) and pk and qk are, respectively, the kth attributes(components) or data objects p and q.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               27
Minkowski Distance: Examples
lr = 1.  City block (Manhattan, taxicab, L1 norm) distance.
A common example of this is the Hamming distance, which is just thenumber of bits that are different between two binary vectors
lr = 2.  Euclidean distance
lr  .  “supremum” (Lmax norm, L norm) distance.
This is the maximum difference between any component of the vectors
lDo not confuse r with n, i.e., all these distances aredefined for all numbers of dimensions.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               28
Minkowski Distance
Distance Matrix
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               29
Mahalanobis Distance
For red points, the Euclidean distance is 14.7, Mahalanobis distance is 6.
 is the covariance matrix ofthe input data X
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               30
Mahalanobis Distance
Covariance Matrix:
B
A
C
A: (0.5, 0.5)
B: (0, 1)
C: (1.5, 1.5)
Mahal(A,B) = 5
Mahal(A,C) = 4
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               31
Common Properties of a Distance
lDistances, such as the Euclidean distance,have some well known properties.
1.d(p, q)  0   for all p and q and d(p, q) = 0 only ifp = q. (Positive definiteness)
2.d(p, q) = d(q, p)   for all p and q. (Symmetry)
3.d(p, r)  d(p, q) + d(q, r)   for all points pq, and r.(Triangle Inequality)
where d(p, q) is the distance (dissimilarity) betweenpoints (data objects), p and q.
lA distance that satisfies these properties is ametric
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               32
Common Properties of a Similarity
lSimilarities, also have some well knownproperties.
1.s(p, q) = 1 (or maximum similarity) only if p = q.
2.s(p, q) = s(q, p)   for all p and q. (Symmetry)
where s(p, q) is the similarity between points (dataobjects), p and q.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               33
Similarity Between Binary Vectors
lCommon situation is that objects, p and q, have onlybinary attributes
lCompute similarities using the following quantities
M01 = the number of attributes where was 0 and was 1
M10 = the number of attributes where was 1 and was 0
M00 = the number of attributes where was 0 and was 0
M11 = the number of attributes where was 1 and was 1
lSimple Matching and Jaccard Coefficients
SMC =  number of matches / number of attributes
          =  (M11 + M00) / (M01 + M10 + M11 + M00)
J = number of 11 matches / number of not-both-zero attributes values
      = (M11) / (M01 + M10 + M11)
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               34
SMC versus Jaccard: Example
p =  1 0 0 0 0 0 0 0 0 0
q =  0 0 0 0 0 0 1 0 0 1
M01 = 2   (the number of attributes where was 0 and was 1)
M10 = 1   (the number of attributes where was 1 and was 0)
M00 = 7   (the number of attributes where was 0 and was 0)
M11 = 0   (the number of attributes where was 1 and was 1)
SMC = (M11 + M00)/(M01 + M10 + M11 + M00) = (0+7) / (2+1+0+7) = 0.7
J = (M11) / (M01 + M10 + M11) = 0 / (2 + 1 + 0) = 0
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               35
Cosine Similarity
l If d1 and d2 are two document vectors, then
             cos( d1d2 =  (d1  d2||d1|| ||d2|| ,
   where  indicates vector dot product and || || is  the   length of vector d.
l Example:
  d1 =  3 2 0 5 0 0 0 2 0 0
   d2 =  1 0 0 0 0 0 0 1 0 2
    d1  d2=  3*1 + 2*0 + 0*0 + 5*0 + 0*0 + 0*0 + 0*0 + 2*1 + 0*0 + 0*2 = 5
   ||d1|| = (3*3+2*2+0*0+5*5+0*0+0*0+0*0+2*2+0*0+0*0)0.5 =  (42) 0.5 = 6.481
    ||d2|| = (1*1+0*0+0*0+0*0+0*0+0*0+0*0+1*1+0*0+2*2) 0.5 = (6) 0.5 = 2.245
    cos( d1, d2 ) = .3150
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               36
Extended Jaccard Coefficient (Tanimoto)
lVariation of Jaccard for continuous or countattributes
Reduces to Jaccard for binary attributes
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               37
Correlation
lCorrelation measures the linear relationshipbetween objects
lTo compute correlation, we standardize dataobjects, p and q, and then take their dot product
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               38
Visually Evaluating Correlation
Scatter plotsshowing thesimilarity from–1 to 1.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               39
General Approach for Combining Similarities
lSometimes attributes are of many differenttypes, but an overall similarity is needed.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               40
Using Weights to Combine Similarities
lMay not want to treat all attributes the same.
Use weights wk which are between 0 and 1 and sumto 1.
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               41
Density
lDensity-based clustering require a notion ofdensity
lExamples:
Euclidean density
 Euclidean density = number of points per unit volume
Probability density
Graph-based density
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               42
Euclidean Density – Cell-based
lSimplest approach is to divide region into anumber of rectangular cells of equal volume anddefine density as # of points the cell contains
© Tan,Steinbach, Kumar     Introduction to Data Mining              4/18/2004               43
Euclidean Density – Center-based
lEuclidean density is the number of points within aspecified radius of the point