Download 002 Descriptive Data Analysis

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Time series wikipedia , lookup

Transcript
22.02.17
Characterisedata
use Big_University_DB
mine characteristics as "Science_Students"
in relevance to
name,gender,major,birth_date,residence,pho
ne#,gpa
from student
where statusin graduate
DataMiningMTAT.03.183
Descriptiveanalysis,preprocessing,
visualisation...
JaakVilo
2017Spring
JaakViloandotherauthors
Knowledge Discovery (KDD) Process
n
Data in the real world is dirty
n incomplete: lacking attribute values, lacking
certain attributes of interest, or containing
only aggregate data
n
Task-relevant Data
n
Selection
Data Cleaning
n
Databases
n
DataMining:ConceptsandTechniques
February 22, 2017
n
n
n
n
n
n
n
n
n
Different data sources
Functional dependency violation (e.g., modify some linked data)
n
Duplicate records also need data cleaning
Data Mining: Concepts and Techniques
Quality decisions must be based on quality data
n
Faulty data collection instruments
Human or computer error at data entry
Errors in data transmission
February 22, 2017
4
No quality data, no quality mining results!
n
Inconsistent data may come from
n
n
n
“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
n
Data Mining: Concepts and Techniques
Why Is Data Preprocessing Important?
Incomplete data may come from
n
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
3
Why Is Data Dirty?
n
e.g., Salary=“-10”
inconsistent: containing discrepancies in codes
or names
n
Data Integration
e.g., occupation=“ ”
noisy: containing errors or outliers
n
n
Jiawei Han, Micheline
Kamber, and Jian Pei
2
Why Data Preprocessing?
• This is a view from typical
database systems and data
Pattern Evaluation
warehousing communities
• Data mining plays an essential
role in the knowledge discovery
Data Mining
process
Data Warehouse
UT:DataMining2009
5
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
Garbage in, garbage out
February 22, 2017
Data Mining: Concepts and Techniques
6
1
22.02.17
High quality data requirements
n
n
n
n
n
n
n
n
n
Multi-Dimensional Measure of Data Quality
High-quality data needs to pass a set of quality criteria. Those
include:
Accuracy: an aggregated value over the criteria of integrity,
consistency, and density
Integrity: an aggregated value over the criteria of completeness and
validity
Completeness: achieved by correcting data containing anomalies
Validity: approximated by the amount of data satisfying integrity
constraints
Consistency: concerns contradictions and syntactical anomalies
Uniformity: directly related to irregularities and in compliance with
the set 'unit of measure'
Density: the quotient of missing values in the data and the number
of total values ought to be known
http://en.wikipedia.org/wiki/Data_cleansing
February 22, 2017
n
Data Mining: Concepts and Techniques
n
n
7
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
February 22, 2017
Major Tasks in Data Preprocessing
n
8
Forms of Data Preprocessing
Data cleaning
n
Fill in missing values, smooth noisy data, identify or remove
outliers, and resolve inconsistencies
n
Data integration
n
Data transformation
n
Data reduction
n
n
n
n
Data Mining: Concepts and Techniques
Integration of multiple databases, data cubes, or files
Normalization and aggregation
Obtains reduced representation in volume but produces the same
or similar analytical results
Data discretization
n
Part of data reduction but with particular importance, especially
for numerical data
February 22, 2017
Data Mining: Concepts and Techniques
9
February 22, 2017
Data Mining: Concepts and Techniques
10
Chapter 2: Data Preprocessing
n
Why preprocess the data?
n
Descriptive data summarization
n
Data cleaning
n
Data integration and transformation
n
Data reduction
n
Discretization and concept hierarchy generation
n
Summary
• 0.480.030.060.050.430.190.160.350.250.07
0.290.140.960.020.110.220.800.050.540.36
0.230.280.020.100.480.310.360.210.330.45
0.640.040.480.560.160.580.330.110.420.06
0.000.230.240.000.540.020.260.200.180.01
0.170.170.040.970.250.040.340.010.500.15
0.430.050.500.160.520.820.230.090.020.21
0.130.170.330.260.000.330.570.430.090.43
0.240.080.080.540.080.020.020.010.350.62
0.100.030.140.780.300.070.080.480.570.30
JaakViloandotherauthors
February 22, 2017
Data Mining: Concepts and Techniques
UT:DataMining2009
12
11
2
22.02.17
1,20#
1,20#
1,00#
1,00#
0,80#
0,80#
0,60#
0,60#
Series1#
Series1#
0,40#
0,40#
0,20#
0,20#
0,00#
0#
20#
40#
60#
80#
100#
120#
0,00#
0#
20#
40#
60#
80#
100#
120#
JaakViloandotherauthors
1,20#
15
1,00#
UT:DataMining2009
14
0,80#
JaakViloandotherauthors
UT:DataMining2009
0,60#
JaakViloandotherauthors
0,40#
13
0,20#
UT:DataMining2009
0,00#
JaakViloandotherauthors
0#
20#
40#
60#
80#
100#
120#
n
n
n
To better understand the data: central tendency, variation
and spread
n
median, max, min, quantiles, outliers, variance, etc.
n
n
Weighted arithmetic mean:
n
Trimmed mean: chopping extreme values
x=
Median: A holistic measure
n
n
Boxplot or quantile analysis on sorted intervals
x
N
åw x
i =1
n
i
i
åw
i =1
i
Middle value if odd number of values, or average of the middle two
Estimated by interpolation (for grouped data):
median = L1 + (
Mode
n
Value that occurs most frequently in the data
n
Folding measures into numerical dimensions
n
Unimodal, bimodal, trimodal
n
Boxplot or quantile analysis on the transformed cube
n
Empirical formula:
Dispersion analysis on computed measures
Data Mining: Concepts and Techniques
µ=å
n
values otherwise
Data dispersion: analyzed with multiple granularities of
precision
February 22, 2017
1 n
å xi
n i =1
Mean (algebraic measure) (sample vs. population): x =
n
Numerical dimensions correspond to sorted intervals
n
n
n
Data dispersion characteristics
n
16
Measuring the Central Tendency
Motivation
n
Series1#
Mining Data Descriptive Characteristics
UT:DataMining2009
17
February 22, 2017
n / 2 - (å f )l
f median
)c
mean - mode = 3 ´ (mean - median )
Data Mining: Concepts and Techniques
18
3
22.02.17
•
•
HistogramsandProbabilityDensityFunctions
ProbabilityDensityFunctions
•
FrequencyHistograms
–
•
Totalareaundercurveintegratesto1
–
–
Y-axisiscounts
Simpleinterpretation
–
Can'tbedirectlyrelatedtoprobabilitiesordensityfunctions
RelativeFrequencyHistograms
–
–
Dividecountsbytotalnumberofobservations
Y-axisisrelativefrequency
–
–
Canbeinterpretedasprobabilitiesforeachrange
Can'tbedirectlyrelatedtodensityfunction
•
•
Barheightssumto1butwon'tintegrateto1unlessbarwidth=1
DensityHistograms
–
–
–
–
Dividecountsby(totalnumberofobservationsXbarwidth)
Y-axisisdensityvalues
BarheightXbarwidthgivesprobabilityforeachrange
Canbedirectlyrelatedtodensityfunction
•
Barareassumto1
http://www.geog.ucsb.edu/~joel/g210_w07/lecture_notes/lect04/oh07_04_1.html
JaakViloandotherauthors
UT:DataMining2009
19
JaakViloandotherauthors
UT:DataMining2009
20
JaakViloandotherauthors
UT:DataMining2009
21
JaakViloandotherauthors
UT:DataMining2009
22
histograms
• equalsub-intervals,knownas`bins‘
• breakpoints
• binwidth
The data are (the log of) wing spans of aircraft built in from 1956 - 1984.
JaakViloandotherauthors
UT:DataMining2009
23
JaakViloandotherauthors
UT:DataMining2009
24
4
22.02.17
JaakViloandotherauthors
UT:DataMining2009
25
2-dimensionaldata:dot-plot
JaakViloandotherauthors
UT:DataMining2009
26
Histogramvskerneldensity
• propertiesofhistogramswiththesetwoexamples:
– theyarenotsmooth
– dependonendpointsofbins
– dependonwidthofbins
• Wecanalleviatethefirsttwoproblemsbyusing
kerneldensityestimators.
• Toremovethedependenceontheendpointsofthe
bins,wecentreeachoftheblocksateachdatapoint
ratherthanfixingtheendpointsoftheblocks.
DataMining:ConceptsandTechniques
February 22, 2017
27
JaakViloandotherauthors
UT:DataMining2009
28
• Blocks- itisstilldiscontinuousaswehave
usedadiscontinuouskernelasourbuilding
block
• Ifweuseasmoothkernelforourbuilding
block,thenwewillhaveasmoothdensity
estimate.
block of width 1 and height 1/12 (the dotted boxes) as they
are 12 data points, and then add them up
JaakViloandotherauthors
UT:DataMining2009
29
JaakViloandotherauthors
UT:DataMining2009
30
5
22.02.17
• It'simportanttochoosethemostappropriate
bandwidthasavaluethatistoosmallortoolargeis
notuseful.
• Ifweuseanormal(Gaussian)kernelwithbandwidth
orstandarddeviationof0.1(whichhasarea1/12
undertheeachcurve)thenthekerneldensity
estimateissaidtoundersmoothedasthebandwidth
istoosmallinthefigurebelow.
• Itappearsthatthereare4modesinthisdensitysomeofthesearesurelyartificesofthedata.
JaakViloandotherauthors
UT:DataMining2009
31
JaakViloandotherauthors
UT:DataMining2009
32
• Chooseoptimalbandwith
–Methodstoestimateit
• AMISE=AsymptoticMeanIntegratedSquaredError
• optimalbandwidth=argminAMISE
JaakViloandotherauthors
UT:DataMining2009
33
JaakViloandotherauthors
UT:DataMining2009
34
JaakViloandotherauthors
UT:DataMining2009
36
• Theoptimalvalueofthebandwidthforourdatasetis
about0.25.
• Fromtheoptimallysmoothedkerneldensity
estimate,therearetwomodes.Asthesearethelog
ofaircraftwingspan,itmeansthattherewerea
groupofsmaller,lighterplanesbuilt,andtheseare
clusteredaround2.5(whichisabout12m).
• Whereasthelargerplanes,maybeusingjetengines
astheseusedonacommercialscalefromaboutthe
1960s,aregroupedaround3.5(about33m).
JaakViloandotherauthors
UT:DataMining2009
35
6
22.02.17
KernelDensityestimation- links
• Thepropertiesofkerneldensityestimators
are,ascomparedtohistograms:
• Wikipedia:
http://en.wikipedia.org/wiki/Kernel_density_estimation
• RicardoGutierrez-Osuna
– smooth
– noendpoints
– dependonbandwidth
http://research.cs.tamu.edu/prism/lectures/pr/pr_l7.pdf
• TutorialandJavaappletfortesting:
– http://parallel.vub.ac.be/research/causalModels/tutorial/kde.html
• SimpleinteractivewebdemoatU.Tartu:
– https://courses.cs.ut.ee/demos/kernel-density-estimation/
– http://kde.tume-maailm.pri.ee/
–
JaakViloandotherauthors
UT:DataMining2009
37
JaakViloandotherauthors
UT:DataMining2009
38
R– example(dueK.Tretjakov)
d=c(1,2,2,2,2,1,2,2,2,3,2,3,4,5,4,3,2,3,4,4,5,6,7);
kernelsmooth<- function(data,sigma,x){
result=0;
for(dindata){
result=result+exp(-(x-d)^2/2/sigma^2);
}
result/sqrt(2*pi)/sigma;
}
x=seq(min(d),max(d),by=0.1);
y=sapply(x,function(x){kernelsmooth(d,1,x)});
hist(d);
lines(x,y);
JaakViloandotherauthors
UT:DataMining2009
39
JaakViloandotherauthors
UT:DataMining2009
40
41
JaakViloandotherauthors
UT:DataMining2009
42
http://parallel.vub.ac.be/research/causalModels/tutorial/kde.html
JaakViloandotherauthors
UT:DataMining2009
7
22.02.17
http://kde.tume-maailm.pri.ee/
JaakViloandotherauthors
UT:DataMining2009
43
http://kde.tume-maailm.pri.ee/
JaakViloandotherauthors
JaakViloandotherauthors
UT:DataMining2009
44
UT:DataMining2009
46
http://kde.tume-maailm.pri.ee/
UT:DataMining2009
45
JaakViloandotherauthors
Aggregation,analysisand
visualizationofgeodata
• http://sightsmap.com
• Severallargecrowd-sourceddatasets:
– ThewholePanoramiophotobankusedbyGooglemaps
– ThewholeWikipedia,geotagsandwikipediaarticlelogs
– Foursquare
– ...More
• Aggregatedata,calculatepopularitesofplaces,calculatetypetags
• Translateandcategorizetitlesanddescriptionstogettypes
• Improveaggregationalgorithmsbylearning
• Visualizeheatmaps,typetags,aggregatedsources
By: Tanel Tammet
By: Tanel Tammet
8
22.02.17
By: Tanel Tammet
By: Tanel Tammet
By: Tanel Tammet
By: Tanel Tammet
• http://176.32.89.45/~hideaki/res/kernel.html
JaakViloandotherauthors
UT:DataMining2009
53
JaakViloandotherauthors
UT:DataMining2009
54
9
22.02.17
http://jmlr.csail.mit.edu/proceedings/papers/v2/kontkanen07a/kontkanen07a.pdf
JaakViloandotherauthors
UT:DataMining2009
55
JaakViloandotherauthors
UT:DataMining2009
56
MorelinksonRandkerneldensity
• http://en.wikipedia.org/wiki/Kernel_density_estimation
• http://sekhon.berkeley.edu/stats/html/density.html
• http://stat.ethz.ch/R-manual/Rpatched/library/stats/html/density.html
• http://www.google.com/search?q=kernel+density+estimation+R
JaakViloandotherauthors
UT:DataMining2009
57
JaakViloandotherauthors
UT:DataMining2009
58
JaakViloandotherauthors
UT:DataMining2009
59
JaakViloandotherauthors
UT:DataMining2009
60
10
22.02.17
JaakViloandotherauthors
UT:DataMining2009
61
JaakViloandotherauthors
UT:DataMining2009
62
Symmetric vs. Skewed Data
n
Median, mean and mode of
symmetric, positively and
negatively skewed data
Author:
Gea Pajula
JaakViloandotherauthors
UT:DataMining2009
63
February 22, 2017
Quartiles, outliers and boxplots
n
Quartiles: Q1 (25th percentile), Q3 (75th percentile)
n
Inter-quartile range: IQR = Q3 – Q1
n
Five number summary: min, Q1, M, Q3, max
n
Boxplot: ends of the box are the quartiles, median is marked, whiskers, and
n
Five-number summary of a distribution:
n
Boxplot
Minimum, Q1, M, Q3, Maximum
n
plot outlier individually
n
n
n
Outlier: usually, a value higher/lower than 1.5 x IQR
Variance and standard deviation (sample: s, population: σ)
n
Variance: (algebraic, scalable computation)
1 n
1 n 2 1 n 2
s =
xi - (å xi ) ]
å ( xi - x )2 = n - 1[å
n - 1 i =1
n i =1
i =1
2
n
64
Boxplot Analysis
Measuring the Dispersion of Data
n
Data Mining: Concepts and Techniques
1
s =
N
2
n
1
( xi - µ ) =
å
N
i =1
2
n
åx
i =1
i
2
-µ
2
Data is represented with a box
The ends of the box are at the first and third
quartiles, i.e., the height of the box is IRQ
n
The median is marked by a line within the box
n
Whiskers: two lines outside the box extend to
Minimum and Maximum
Standard deviation s (or σ) is the square root of variance s2 (or σ2)
February 22, 2017
Data Mining: Concepts and Techniques
65
February 22, 2017
Data Mining: Concepts and Techniques
66
11
22.02.17
BoxPlots
• Tukey77:JohnW.Tukey,"ExploratoryData
Analysis".Addison-Wesley,Reading,MA.
1977.
• http://informationandvisualization.de/blog/box-plot
•
JaakViloandotherauthors
UT:DataMining2009
67
JaakViloandotherauthors
UT:DataMining2009
68
1.5 x IQR – Inter Quartile range
JaakViloandotherauthors
UT:DataMining2009
JaakViloandotherauthors
UT:DataMining2009
69
JaakViloandotherauthors
UT:DataMining2009
70
71
JaakViloandotherauthors
UT:DataMining2009
72
Gea Pajula
12
22.02.17
Visualization of Data Dispersion: Boxplot Analysis
February 22, 2017
Data Mining: Concepts and Techniques
73
February 22, 2017
Data Mining: Concepts and Techniques
74
Violin plot
February 22, 2017
Data Mining: Concepts and Techniques
75
Violin plot – R
Combining plots…
vertical kernel density
http://gallery.r-enthusiasts.com/graph/Violin_plot,43
76
77
13
22.02.17
Properties of Normal Distribution Curve
n
February 22, 2017
Data Mining: Concepts and Techniques
79
February 22, 2017
n
February 22, 2017
Data Mining: Concepts and Techniques
81
Quantile-Quantile (q-q) Plots
n
n
n
The normal (distribution) curve
n From μ–σ to μ+σ: contains about 68% of the
measurements (μ: mean, σ: standard deviation)
n
From μ–2σ to μ+2σ: contains about 95% of it
n From μ–3σ to μ+3σ: contains about 99.7% of it
Data Mining: Concepts and Techniques
80
Example of plots-containing article:
n http://www.kgs.ku.edu/Magellan/WaterLevels/
CD/Reports/OFR04_57/rep00.htm
February 22, 2017
Data Mining: Concepts and Techniques
82
Cumulative Distribution Function (CDF)
http://onlinestatbook.com/2/advanced_graphs/q-q_plots.html
http://www.itl.nist.gov/div898/handbook/eda/section3/eda33o.htm
A q-q plot is a plot of the quantiles of the first
data set against the quantiles of the second data
set. By a quantile, we mean the fraction (or
percent) of points below the given value. That is,
the 0.3 (or 30%) quantile is the point at which
30% percent of the data fall below and 70% fall
above that value.
February 22, 2017
Data Mining: Concepts and Techniques
83
February 22, 2017
Data Mining: Concepts and Techniques
84
14
22.02.17
n
n
n
February 22, 2017
Data Mining: Concepts and Techniques
85
These 2 batches do not appear to have come
from populations with a common distribution.
The batch 1 values are significantly higher than
the corresponding batch 2 values.
The differences are increasing from values 525 to
625. Then the values for the 2 batches get closer
again.
February 22, 2017
Data Mining: Concepts and Techniques
86
The advantages of the q-q plot are:
n
n
February 22, 2017
Data Mining: Concepts and Techniques
87
The sample sizes do not need to be equal.
Many distributional aspects can be simultaneously
tested. For example, shifts in location, shifts in
scale, changes in symmetry, and the presence of
outliers can all be detected from this plot. For
example, if the two data sets come from
populations whose distributions differ only by a
shift in location, the points should lie along a
straight line that is displaced either up or down
from the 45-degree reference line.
February 22, 2017
Data Mining: Concepts and Techniques
88
A Q–Q plot comparing the distributions of standardizeddaily maximum
temperatures at 25 stations in the US state of Ohio in March and in July. The
curved pattern suggests that the central quantiles are more closely spaced in
July than in March, and that the March distribution is skewed to the right
compared to the July distribution. The data cover the period 1893–2001.
February 22, 2017
Data Mining: Concepts and Techniques
89
February 22, 2017
Data Mining: Concepts and Techniques
90
15
22.02.17
n
Parametric modeling usually involves making
assumptions about the shape of data, or the
shape of residuals from a regression fit. Verifying
such assumptions can take many forms, but an
exploration of the shape using histograms and qq plots is very effective. The q-q plot does not
have any design parameters such as the
number of bins for a histogram.
February 22, 2017
Data Mining: Concepts and Techniques
91
February 22, 2017
Kemmeren et.al. (Mol. Cell, 2002)
Data Mining: Concepts and Techniques
92
Scatter plot
Randomized expression data
Yeast 2-hybrid studies
n
Known (literature) PPI
n
Provides a first look at bivariate data to see clusters of
points, outliers, etc
Each pair of values is treated as a pair of coordinates and
plotted as points in the plane
MPK1 YLR350w
SNF4 YCL046W
SNF7 YGR122W.
February 22, 2017
Data Mining: Concepts and Techniques
94
Pearson Correlation
February 22, 2017
Data Mining: Concepts and Techniques
95
96
16
22.02.17
Not Correlated Data
February 22, 2017
Data Mining: Concepts and Techniques
97
Abalone data set – P. Danelson hw.
98
Bias vs Variance
Several sets of (x, y) points, with the Pearson correlation coefficient of x and y for
each set. Note that the correlation reflects the noisiness and direction of a linear
relationship (top row), but not the slope of that relationship (middle), nor many
aspects of nonlinear relationships (bottom). N.B.: the figure in the center has a
slope of 0 but in that case the correlation coefficient is undefined because the
variance of Y is zero.
Scott Fortmann-Roe
http://scott.fortmann-roe.com/docs/BiasVariance.html
99
Numerical summary?
February 22, 2017
Data Mining: Concepts and Techniques
100
Anscombe’s quartet
101
February 22, 2017
Data Mining: Concepts and Techniques
102
17
22.02.17
February 22, 2017
Data Mining: Concepts and Techniques
103
February 22, 2017
Data Mining: Concepts and Techniques
104
February 22, 2017
Data Mining: Concepts and Techniques
105
February 22, 2017
Data Mining: Concepts and Techniques
106
February 22, 2017
Data Mining: Concepts and Techniques
107
February 22, 2017
Data Mining: Concepts and Techniques
108
18
22.02.17
Loess Curve
Adds a smooth curve to a scatter plot in order to
provide better perception of the pattern of dependence
Loess curve is fitted by setting two parameters: a
smoothing parameter, and the degree of the
polynomials that are fitted by the regression
n
n
February 22, 2017
Data Mining: Concepts and Techniques
109
February 22, 2017
n
Histogram: (shown before)
Boxplot: (covered before)
Quantile plot: each value xi is paired with fi indicating
that approximately 100 fi % of data are £ xi
n Quantile-quantile (q-q) plot: graphs the quantiles of one
univariant distribution against the corresponding quantiles
of another
n Scatter plot: each pair of values is a pair of coordinates
and plotted as points in the plane
n Loess (local regression) curve: add a smooth curve to a
scatter plot to provide better perception of the pattern of
dependence
n
February 22, 2017
Data Mining: Concepts and Techniques
111
n
Why preprocess the data?
n
Descriptive data summarization
n
Data cleaning
n
Data integration and transformation
n
Data reduction
n
Discretization and concept hierarchy generation
n
Summary
February 22, 2017
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
n
n
Fill in missing values
n
Identify outliers and smooth out noisy data
n
Correct inconsistent data
n
Resolve redundancy caused by data integration
February 22, 2017
Data Mining: Concepts and Techniques
112
Data is not always available
n
Data cleaning tasks
n
Data Mining: Concepts and Techniques
Missing Data
Data Cleaning
n
110
Chapter 2: Data Preprocessing
Graphic Displays of Basic Statistical Descriptions
n
Data Mining: Concepts and Techniques
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
113
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.
February 22, 2017
Data Mining: Concepts and Techniques
114
19
22.02.17
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
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
February 22, 2017
Data Mining: Concepts and Techniques
115
February 22, 2017
Data Mining: Concepts and Techniques
K-NN impute
116
Noisy Data
n
n
K nearest neighbours imputation
n
Noise: random error or variance in a measured variable
Incorrect attribute values may due to
faulty data collection instruments
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
n
Find K neighbours on available data points
n
Estimate the missing value
n
n
(Hastie, Tibshirani, Troyanskaya, … Stanford 19992001)
n
n
n
February 22, 2017
Data Mining: Concepts and Techniques
117
February 22, 2017
How to Handle Noisy Data?
n
Binning
n first sort data and partition into (equal-frequency) bins
n
then one can smooth by bin means, smooth by bin
median, smooth by bin boundaries, etc.
Regression
n
smooth by fitting the data into regression functions
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)
February 22, 2017
Data Mining: Concepts and Techniques
118
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
n
Data Mining: Concepts and Techniques
Simple Discretization Methods: Binning
n
n
incomplete data
inconsistent data
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
119
n
Good data scaling
n
Managing categorical attributes can be tricky
February 22, 2017
Data Mining: Concepts and Techniques
120
20
22.02.17
Binning Methods for Data Smoothing
Regression
Sorted data for price (in dollars): 4, 8, 9, 15, 21, 21, 24, 25, 26,
28, 29, 34
* Partition into equal-frequency (equi-depth) bins:
- Bin 1: 4, 8, 9, 15
- Bin 2: 21, 21, 24, 25
- Bin 3: 26, 28, 29, 34
* Smoothing by bin means:
- Bin 1: 9, 9, 9, 9
- Bin 2: 23, 23, 23, 23
- Bin 3: 29, 29, 29, 29
* Smoothing by bin boundaries:
- Bin 1: 4, 4, 4, 15
- Bin 2: 21, 21, 25, 25
- Bin 3: 26, 26, 26, 34
y
q
February 22, 2017
Data Mining: Concepts and Techniques
Y1
X1
121
February 22, 2017
Cluster Analysis
G3
G2
n
n
February 22, 2017
Data Mining: Concepts and Techniques
123
February 22, 2017
n
Data cleaning
n
Data integration and transformation
n
Data reduction
n
Discretization and concept hierarchy generation
n
Summary
February 22, 2017
n
Data Mining: Concepts and Techniques
122
Data Mining: Concepts and Techniques
124
Data Integration
n
Why preprocess the data?
Data Mining: Concepts and Techniques
Data discrepancy detection
n Use metadata (e.g., domain, range, dependency, distribution)
n Check field overloading
n Check uniqueness rule, consecutive rule and null rule
n Use commercial tools
n Data scrubbing: use simple domain knowledge (e.g., postal
code, spell-check) to detect errors and make corrections
n Data auditing: by analyzing data to discover rules and
relationship to detect violators (e.g., correlation and clustering
to find outliers)
Data migration and integration
n Data migration tools: allow transformations to be specified
n ETL (Extraction/Transformation/Loading) tools: allow users to
specify transformations through a graphical user interface
Integration of the two processes
n Iterative and interactive (e.g., Potter’s Wheels)
Chapter 2: Data Preprocessing
n
x
Data Cleaning as a Process
n
G1
y=x+1
Y1’
n
n
125
Data integration:
n Combines data from multiple sources into a coherent
store
Schema integration: e.g., A.cust-id º B.cust-#
n Integrate metadata from different sources
Entity identification problem:
n Identify real world entities from multiple data sources,
e.g., Bill Clinton = William Clinton
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
February 22, 2017
Data Mining: Concepts and Techniques
126
21
22.02.17
Handling Redundancy in Data Integration
n
Redundant data occur often when integration of multiple
databases
n
n
n
n
Object identification: The same attribute or object
may have different names in different databases
Derivable data: One attribute may be a “derived”
attribute in another table, e.g., annual revenue
Redundant attributes may be able to be detected by
correlation analysis
Careful integration of the data from multiple sources may
help reduce/avoid redundancies and inconsistencies and
improve mining speed and quality
February 22, 2017
Data Mining: Concepts and Techniques
127
February 22, 2017
Data Mining: Concepts and Techniques
128
February 22, 2017
Data Mining: Concepts and Techniques
129
February 22, 2017
Data Mining: Concepts and Techniques
130
Normalisation
n
February 22, 2017
Data Mining: Concepts and Techniques
131
Making data comparable…
February 22, 2017
Data Mining: Concepts and Techniques
132
22
22.02.17
Elements of microarray statistics
0,8%
Reference
0,6%
Test
0,4%
0,2%
M
= log2R – log2G
= log2(R/G)
A
= 1/2 (log2R + log2G)
Series1%
Series2%
Series3%
Series4%
0%
0%
20%
40%
60%
80%
100%
120%
!0,2%
!0,4%
!0,6%
February
22, 2017
Data Mining: Concepts and Techniques
133
Normalisation
can be used to
transform data
JaakViloandotherauthors
UT:DataMining2009
135
Expression Profiler
Data Reduction Strategies
Chapter 2: Data Preprocessing
n
n
Why preprocess the data?
n
Data cleaning
n
Data integration and transformation
n
Data reduction
n
Discretization and concept hierarchy generation
n
Summary
n
n
February 22, 2017
Data Mining: Concepts and Techniques
136
137
Why data reduction?
n A database/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 — e.g., remove unimportant attributes
n Data Compression
n Numerosity reduction — e.g., fit data into models
n Discretization and concept hierarchy generation
February 22, 2017
Data Mining: Concepts and Techniques
138
23
22.02.17
Discretization
Chapter 2: Data Preprocessing
n
Why preprocess the data?
n
Data cleaning
n
Data integration and transformation
n
Three types of attributes:
n
Nominal — values from an unordered set, e.g., color, profession
n
Ordinal — values from an ordered set, e.g., military or academic
rank
n
n
Data reduction
n
Discretization and concept hierarchy generation
n
n
Summary
February 22, 2017
Data Mining: Concepts and Techniques
139
Continuous — real numbers, e.g., integer or 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
February 22, 2017
Data Mining: Concepts and Techniques
Discretization and Concept Hierarchy
n
E.g.
Discretization
n
n
Reduce the number of values for a given continuous attribute by
n
dividing the range of the attribute into intervals
n
n
Interval labels can then be used to replace actual data values
n
Supervised vs. unsupervised
n
Split (top-down) vs. merge (bottom-up)
n
Discretization can be performed recursively on an attribute
n
n
Concept hierarchy formation
n
n
concepts (such as numeric values for age) by higher level concepts
n
(such as young, middle-aged, or senior)
n
Data Mining: Concepts and Techniques
141
0-18 y
19-65 y
66-105
1580
8394
2700
0-20
21-40
41-60
61-105
1780
4200
4767
2900
Vs
n
Recursively reduce the data by collecting and replacing low level
February 22, 2017
140
February 22, 2017
Data Mining: Concepts and Techniques
142
Example of 3-4-5 Rule
Segmentation by Natural Partitioning
count
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 equi-
Step 1:
-$351
-$159
Min
Low (i.e, 5%-tile)
Step 2:
msd=1,000
Step 3:
(-$1,000 - 0)
(-$400 - 0)
significant digit, partition the range into 4 intervals
n
(-$400 -$300)
If it covers 1, 5, or 10 distinct values at the most
(-$300 -$200)
significant digit, partition the range into 5 intervals
February 22, 2017
Data Mining: Concepts and Techniques
(-$200 -$100)
143
(-$100 0)
$4,700
Max
($1,000 - $2,000)
(0 -$ 1,000)
(-$400 -$5,000)
Step 4:
If it covers 2, 4, or 8 distinct values at the most
$1,838
High(i.e, 95%-0 tile)
High=$2,000
(-$1,000 - $2,000)
width intervals
n
profit
Low=-$1,000
February 22, 2017
($1,000 - $2, 000)
(0 - $1,000)
(0 $200)
($1,000 $1,200)
($200 $400)
($1,200 $1,400)
($600 $800)
($3,000 $4,000)
($1,400 $1,600)
($400 $600)
($800 $1,000)
($1,600 $1,800)
($2,000 - $5, 000)
($2,000 $3,000)
($1,800 $2,000)
Data Mining: Concepts and Techniques
($4,000 $5,000)
144
24
22.02.17
Recursive …
Example
-351,976.00 .. 4,700,896.50
1.1. (-400,000 .. -300,000 ]
1.2. (-300,000 .. -200,000 ]
1.3. (-200,000 .. -100,000 ]
1.4. (-100,000 .. 0 ]
MIN= -351,976.00
MAX=4,700,896.50
LOW = 5th percentile -159,876
HIGH = 95th percentile 1,838,761
msd = 1,000,000 (most significant digit)
LOW = -1,000,000 (round down) HIGH = 2,000,000 (round up)
2.1. (0 .. 200,000 ]
2.2. (200,000 .. 400,000 ]
2.3. (400,000 .. 600,000 ]
2.4. (600,000 .. 800,000 ]
2.5. (800,000 .. 1,000,000 ]
3 value ranges
1. (-1,000,000 .. 0]
2. (0 .. 1,000,000]
3. (1,000,000 .. 2,000,000]
3.1. (1,000,000 .. 1,200,000 ]
3.2. (1,200,000 .. 1,400,000 ]
3.3. (1,400,000 .. 1,600,000 ]
3.4. (1,600,000 .. 1,800,000 ]
3.5. (1,800,000 .. 2,000,000 ]
Adjust with real MIN and MAX
1.
2.
3.
4.
(-400,000 .. 0]
(0 .. 1,000,000]
(1,000,000 .. 2,000,000]
(2,000,000 .. 5,000,000]
February 22, 2017
Data Mining: Concepts and Techniques
4.1. (2,000,000 .. 3,000,000 ]
4.2. (3,000,000 .. 4,000,000 ]
4.3. (4,000,000 .. 5,000,000 ]
JaakViloandotherauthors
145
Concept Hierarchy Generation for Categorical Data
• Specification of a partial/total ordering of attributes
explicitly at the schema level by users or experts
n
– street < city < state < country
Some hierarchies can be automatically generated based
on the analysis of the number of distinct values per
attribute in the data set
n The attribute with the most distinct values is placed
at the lowest level of the hierarchy
n Exceptions, e.g., weekday, month, quarter, year
– {Urbana, Champaign, Chicago} < Illinois
15 distinct values
country
• Specification of only a partial set of attributes
– E.g., only street < city, not others
• Automatic generation of hierarchies (or attribute levels) by
the analysis of the number of distinct values
– E.g., for a set of attributes: {street, city, state, country}
DataMining:ConceptsandTechniques
province_or_ state
365 distinct values
city
3567 distinct values
674,339 distinct values
street
147
February 22, 2017
Chapter 2: Data Preprocessing
n
Why preprocess the data?
n
Data cleaning
n
Data integration and transformation
n
Data reduction
n
Data Mining: Concepts and Techniques
n
n
n
Data preparation or preprocessing is a big issue for both
data warehousing and data mining
Discriptive data summarization is need for quality data
preprocessing
Data preparation includes
n
Data cleaning and data integration
Discretization and concept hierarchy
n
Data reduction and feature selection
generation
n
Discretization
Summary
February 22, 2017
Data Mining: Concepts and Techniques
148
Summary
n
n
146
Automatic Concept Hierarchy Generation
• Specification of a hierarchy for a set of values by explicit
data grouping
February 22, 2017
UT:DataMining2009
149
A lot a methods have been developed but data
preprocessing still an active area of research
February 22, 2017
Data Mining: Concepts and Techniques
150
25
22.02.17
References
n
D. P. Ballou and G. K. Tayi. Enhancing data quality in data warehouse environments. Communications
of ACM, 42:73-78, 1999
n
T. Dasu and T. Johnson. Exploratory Data Mining and Data Cleaning. John Wiley & Sons, 2003
n
T. Dasu, T. Johnson, S. Muthukrishnan, V. Shkapenyuk. Mining Database Structure; Or, How to Build
a Data Quality Browser. SIGMOD’02.
n
H.V. 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
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
V. Raman and J. Hellerstein. Potters Wheel: An Interactive Framework for Data Cleaning and
Transformation, VLDB’2001
n
T. Redman. Data Quality: Management and Technology. Bantam Books, 1992
n
Y. Wand and 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
February 22, 2017
Data Mining: Concepts and Techniques
151
26