01 Data
01 Data
Data Visualization
Summary
1
Types of Data Sets
Record
Relational records
Data matrix, e.g., numerical matrix,
crosstabs
Document data: text documents: term-
frequency vector
Transaction data
Graph and network
World Wide Web
Social or information networks
Molecular Structures
Ordered
Video data: sequence of images
Temporal data: time-series
Sequential Data: transaction sequences
Genetic sequence data
Spatial, image and multimedia:
Spatial data: maps
Image data:
Video data:
2
Types of dataset Visualization
Example
Document Term Matrix
Documents :
Binary
Ordinal
Numeric: quantitative
Interval-scaled
Ratio-scaled
15
Attribute Types
Nominal: categories, states, or “names of things”
Hair_color = {auburn, black, blond, brown, grey, red, white}
marital status, occupation, ID numbers, zip codes
Binary
Nominal attribute with only 2 states (0 and 1)
Symmetric binary: both outcomes equally important
e.g., gender
Asymmetric binary: outcomes not equally important.
e.g., medical test (positive vs. negative)
Convention: assign 1 to most important outcome (e.g., HIV
positive)
Ordinal
Values have a meaningful order (ranking) but magnitude between
successive values is not known.
Size = {small, medium, large}, grades, army rankings
16
Numeric Attribute Types
Quantity (integer or real-valued)
Interval
Measured on a scale of equal-sized units
Values have order
E.g., temperature in C˚or F˚, calendar dates
No true zero-point
Ratio
Inherent zero-point
We can speak of values as being an order of
magnitude larger than the unit of measurement
(10 K˚ is twice as high as 5 K˚).
e.g., temperature in Kelvin, length, counts,
monetary quantities
17
Features Interval scale Ratio scale
Ratio scale has all the characteristics
All variables measured in an interval
of an interval scale, in addition, to be
Variable scale can be added, subtracted, and
able to calculate ratios. That is, you
property multiplied. You cannot calculate a
can leverage numbers on the scale
ratio between them.
against 0.
Zero-point in an interval scale is
arbitrary. For example, the The ratio scale has an absolute zero
Absolute Point
temperature can be below 0 degrees or character of origin. Height and
Zero
Celsius and into negative weight cannot be zero or below zero.
temperatures.
Statistically, in a ratio scale, the
Statistically, in an interval scale, the
Calculation geometric or harmonic mean is
arithmetic mean is calculated.
calculated.
Interval scale can measure size and Ratio scale can measure size and
Measurement magnitude as multiple factors of a magnitude as a factor of one defined
defined unit. unit in terms of another.
collection of documents
Sometimes, represented as integer variables
attributes
Continuous Attribute
Has real numbers as attribute values
floating-point variables
19
Basic Statistical Descriptions of Data
Motivation
To better understand the data: central tendency,
variation and spread
Data dispersion characteristics
median, max, min, quantiles, outliers, variance, etc.
Numerical dimensions correspond to sorted intervals
Data dispersion: analyzed with multiple granularities
of precision
Boxplot or quantile analysis on sorted intervals
Dispersion analysis on computed measures
Folding measures into numerical dimensions
Boxplot or quantile analysis on the transformed cube
20
Measuring the Central Tendency
Mean (algebraic measure) (sample vs. population): 1 n
x xi x
Note: n is sample size and N is population size. n i 1 N
n
Weighted arithmetic mean:
w x i i
Trimmed mean: chopping extreme values x i 1
n
Median: w
i 1
i
22
Estimating the Mean from Grouped Data
23
24
Estimating the Median from Grouped Data
The median is the middle value, which in
our case is the 11th one, which is in the 61
- 65 group:
We can say "the median group is 61 - 65"
•L = 60.5
•n = 21
•B = 2 + 7
•G = 8
•w = 5
25
26
Estimating the Mode from Grouped Data
We can easily find the modal group (the group with the highest frequency),
which is 61 - 65
We can say "the modal group is 61 - 65"
But the actual Mode may not even be in that group! Or there may be more than
one mode. Without the raw data we don't really know.
But, we can estimate the Mode using the following formula:
•L = 60.5
•f
m-1 = 7
•f
m = 8
•f
m+1 = 4
•w = 5
27
28
Baby Carrots Example
Example: You grew fifty baby carrots using special soil. You dig them up and measure
their lengths (to the nearest mm) and group the results:
29
Mean
30
Median
31
Mode
32
Symmetric vs. Skewed Data
39
Range
40
Inter-Quartile Range
The interquartile range gives you the spread of the middle of your
distribution.
For any distribution that’s ordered from low to high, the interquartile range
contains half of the values. While the first quartile (Q1) contains the first
25% of values, the fourth quartile (Q4) contains the last 25% of values.
41
42
Standard Deviation
43
Variance
44
Measuring the Dispersion of Data
Quartiles, outliers and boxplots
Quartiles: Q1 (25th percentile), Q3 (75th percentile)
Inter-quartile range: IQR = Q3 – Q1
Five number summary: min, Q1, median, Q3, max
Boxplot: ends of the box are the quartiles; median is marked; add
whiskers, and plot outliers individually
Outlier: usually, a value higher/lower than 1.5 x IQR
Variance and standard deviation (sample: s, population: σ)
Variance: (algebraic, scalable computation)
1 n 1 n 2 1 n 1 n
1 n
s
2
n 1 i 1
( xi x )
2
[ xi ( xi ) 2 ]
n 1 i 1 n i 1
2
N
i 1
( xi
2
)
N
xi 2
i 1
2
45
Boxplot Analysis
Five-number summary of a distribution
Minimum, Q1, Median, Q3, Maximum
Boxplot
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 IQR
The median is marked by a line within the
box
Whiskers: two lines outside the box extended
to Minimum and Maximum
Outliers: points beyond a specified outlier
threshold, plotted individually
46
Inclassexercise#
a) Find the mean price in each city and then state which
city has the lower mean
b) Find the standard deviation of each city's prices.
c) Which city has the more consistently priced petrol? Give
reasons for your answer
Solution
Example 1: If a die is rolled, then find the variance and
standard deviation of the possibilities.
50
Example 2: Find the standard deviation of the average
temperatures recorded over a five-day period last winter:
18, 22, 19, 25, 12 (The mean = 19.2)
22,25,17,19,33,64,23,17,20,18
54
Histogram Analysis
Histogram: Graph display of
tabulated frequencies, shown as 40
bars 35
It shows what proportion of cases 30
fall into each of several categories
25
Differs from a bar chart in that it is
20
the area of the bar that denotes the
value, not the height as in bar 15
charts, a crucial distinction when the 10
categories are not of uniform width
5
The categories are usually specified
0
as non-overlapping intervals of 10000 30000 50000 70000 90000
some variable. The categories (bars)
must be adjacent
55
Histograms Often Tell More than Boxplots
56
Quantile Plot
Displays all of the data (allowing the user to assess both
the overall behavior and unusual occurrences)
Plots quantile information
For a data x data sorted in increasing order, f
i i
indicates that approximately 100 fi% of the data are
below or equal to the value xi
58
Scatter plot
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
59
Positively and Negatively Correlated Data
60
Uncorrelated Data
61
Data Visualization
Why data visualization?
Gain insight into an information space by mapping data onto graphical
primitives
Provide qualitative overview of large data sets
Search for patterns, trends, structure, irregularities, relationships among
data
Help find interesting regions and suitable parameters for further
quantitative analysis
Provide a visual proof of computer representations derived
Categorization of visualization methods:
Pixel-oriented visualization techniques
Geometric projection visualization techniques
Icon-based visualization techniques
Hierarchical visualization techniques
Visualizing complex data and relations
62
Similarity and Dissimilarity
Similarity
Numerical measure of how alike two data objects are
are
Lower when objects are more alike
63
Data Matrix and Dissimilarity Matrix
Data matrix
n data points with p x11 ... x1f ... x1p
dimensions ... ... ... ... ...
Two modes x ... xif ... xip
i1
... ... ... ... ...
x ... xnf ... xnp
n1
Dissimilarity matrix
n data points, but
0
d(2,1) 0
registers only the
d(3,1) d ( 3,2) 0
distance
A triangular matrix : : :
d ( n,1) d ( n,2) ... ... 0
Single mode
64
Suppose that we have n objects (e.g., persons,
items, or courses) described by p attributes (also
called measurements or features, such as age,
height, weight, or gender).
65
Data Matrix and Dissimilarity Matrix
Data matrix (object by attribute structure or n by p
matrix)
n data points with p dimensions
Two-mode
66
Dissimilarity matrix (object by object structure)
n data points, but registers only the distance
A triangular matrix
Single-mode
0
d(2,1) 0
d(3,1) d ( 3,2) 0
: : :
d ( n,1) d ( n,2) ... ... 0
67
Proximity Measure for Binary Attributes
Object j
A contingency table for binary data
Object i
68
Dissimilarity between Binary Variables
Example
Name Gender Fever Cough Test-1 Test-2 Test-3 Test-4
Jack M Y N P N N N
Mary F Y N P N P N
Jim M Y P N N N N
69
Distance measure for asymmetric attributes
Contingency table
01
d ( jack , mary ) 0.33
2 01
11
d ( jack , jim ) 0.67
111
1 2
d ( jim , mary ) 0.75
11 2
70
Proximity Measure for Nominal Attributes
71
Example I
1-0/1 = 1
72
Example II
RollNo Marks Grade
1 90 A
2 80 B
3 82 B
4 90 A
distance(object1, Object2) = P – M / P
P is total number of attributes
M is total number of matches
73
Distance measure
d(1,1)
=P–M/P
d(RollNo1,RollNo2) d(RollNo1,RollNo3) d(RollNo1,RollNo4)
=2–2/2
=0
d(2,1)
d(2,2) = P – M / P
=P–M/P
= (2 – 2) / 2 d(RollNo2,RollNo3) d(RollNo2,RollNo4)
= (2 – 0) / 2
=0
=1
d(3,1)
d(3,2) = P – M / P d(3,3) = P – M / P
=P–M/P
= (2 – 1 )/ 2 = (2 – 2 )/ 2 d(RollNo3,RollNo4)
= (2 – 0) / 2
= 0.5 =0
=1
d(4,1)
d(4,2) = P – M / P d(4,3) = P – M / P d(4,4) = P – M / P
=P–M/P
= (2 – 0) / 2 =( 2 – 0 )/ 2 =( 2 – 2) / 2
= (2 – 2) / 2
=1 =1 =0
=0
74
Standardizing Numeric Data
x
z
Z-score:
X: raw score to be standardized, μ: mean of the population, σ:
standard deviation
the distance between the raw score and the population mean in
units of the standard deviation
negative when the raw score is below the mean, “+” when above
An alternative way: Calculate the mean absolute deviation
s f 1n (| x1 f m f | | x2 f m f | ... | xnf m f |)
where m 1 (x x ... x )
n 1f 2 f xif m f
.
f nf
zif sf
standardized measure (z-score):
Using mean absolute deviation is more robust than using standard
deviation
75
Example:
Data Matrix and Dissimilarity Matrix
Data Matrix
x2 x4
point attribute1 attribute2
4 x1 1 2
x2 3 5
x3 2 0
x4 4 5
2 x1
Dissimilarity Matrix
(with Euclidean Distance)
x3
0 4 x1 x2 x3 x4
2
x1 0
x2 3.61 0
x3 5.1 5.1 0
x4 4.24 1 5.39 0
76
Distance on Numeric Data: Minkowski Distance
Minkowski distance: A popular distance measure
where i = (xi1, xi2, …, xip) and j = (xj1, xj2, …, xjp) are two p-
dimensional data objects, and h is the order (the
distance so defined is also called L- h norm)
Properties
d(i, j) > 0 if i ≠ j, and d(i, i) = 0 (Positive definiteness)
d(i, j) = d(j, i) (Symmetry)
d(i, j) d(i, k) + d(k, j) (Triangle Inequality)
A distance that satisfies these properties is a metric
77
Special Cases of Minkowski Distance
h = 1: Manhattan (city block, L1 norm) distance
E.g., the Hamming distance: the number of bits that are
different between two binary vectors
d (i, j) | x x | | x x | ... | x x |
i1 j1 i2 j 2 ip jp
78
Example
f1 difference |1-3| = 2
f2 difference |2-5| = 3
Select maximum difference i.e. 3
79
Example: Minkowski Distance
Dissimilarity Matrices
point attribute 1 attribute 2
x1 1 2
x2 3 5
x3 2 0
x4 4 5 Manhattan (L1)
Euclidean (L2)
x2 x4
4 Supremum
2 x1
x3
0 2 4
80
Example: Minkowski Distance
Dissimilarity Matrices
point attribute 1 attribute 2 Manhattan (L1)
x1 1 2
L x1 x2 x3 x4
x2 3 5 x1 0
x3 2 0 x2 5 0
x4 4 5 x3 3 6 0
x4 6 1 7 0
Euclidean (L2)
x2 x4
L2 x1 x2 x3 x4
4 x1 0
x2 3.61 0
x3 2.24 5.1 0
x4 4.24 1 5.39 0
2 x1
Supremum
L x1 x2 x3 x4
x1 0
x2 3 0
x3 x3 2 5 0
0 2 4 x4 3 1 5 0
81
Example
82
83
Ordinal Variables
84
Example
85
Dissimilarity measure for ordinal data
There are three states for test-2: fair, good, and
excellent, that is, Mf = 3.
step 1 - Replace each value for test-2 by its rank,
four objects are assigned the ranks 3, 1, 2, and
3, respectively.
Step 2 - Normalizes the ranking by mapping rank
1 to 0.0, rank 2 to 0.5, and rank 3 to 1.0.
step 3 – Use the Euclidean distance
86
Example
87
Cosine Similarity
A document can be represented by thousands of attributes, each
recording the frequency of a particular word (such as keywords) or
phrase in the document.
d1 = (5, 0, 3, 0, 2, 0, 0, 2, 0, 0)
d2 = (3, 0, 2, 0, 1, 1, 0, 1, 0, 1)
d1d2 = 5*3+0*0+3*2+0*0+2*1+0*1+0*1+2*1+0*0+0*1 = 25
||d1||= (5*5+0*0+3*3+0*0+2*2+0*0+0*0+2*2+0*0+0*0)0.5=(42)0.5
= 6.481
||d2||= (3*3+0*0+2*2+0*0+1*1+1*1+0*0+1*1+0*0+1*1)0.5=(17)0.5
= 4.12
cos(d1, d2 ) = 0.94
89
Attributes of Mixed Type
A database may contain all attribute types
Nominal, symmetric binary, asymmetric binary,
numeric, ordinal
One may use a weighted formula to combine their effects
pf 1 ij( f ) dij( f )
d (i, j)
pf 1 ij( f )
if either
xif or xjf missing (i.e., there is no measurement of attribute f for
object i or object j), or
xif = xjf = 0 and attribute f is asymmetric binary;
otherwise,
90
Attributes of Mixed Type
f is binary or nominal:
dij(f) = 0 if xif = xjf
dij(f) = 1 otherwise
f is numeric: use the normalized distance
Where h runs over all non missing objects for the attribute f.
f is ordinal
Compute ranks rif and r 1
zif
if
Treat zif as interval-scaled M 1 f
91
Example
92
Dissimilarity Matrix for test I
di,j = p – m / p ( simple matching)
P=1
93
Dissimilarity Matrix for test II
zif r 1
if
M 1 f
94
Dissimilarity Matrix for test III
95
Solution
Dissimilarity Matrix
96
Example
97
Solution (a)
98
Solution (b)
99
References
W. Cleveland, Visualizing Data, Hobart Press, 1993
T. Dasu and T. Johnson. Exploratory Data Mining and Data Cleaning. John Wiley, 2003
U. Fayyad, G. Grinstein, and A. Wierse. Information Visualization in Data Mining and
Knowledge Discovery, Morgan Kaufmann, 2001
L. Kaufman and P. J. Rousseeuw. Finding Groups in Data: an Introduction to Cluster
Analysis. John Wiley & Sons, 1990.
H. V. Jagadish, et al., Special Issue on Data Reduction Techniques. Bulletin of the Tech.
Committee on Data Eng., 20(4), Dec. 1997
D. A. Keim. Information visualization and visual data mining, IEEE trans. on Visualization
and Computer Graphics, 8(1), 2002
D. Pyle. Data Preparation for Data Mining. Morgan Kaufmann, 1999
S. Santini and R. Jain,” Similarity measures”, IEEE Trans. on Pattern Analysis and
Machine Intelligence, 21(9), 1999
E. R. Tufte. The Visual Display of Quantitative Information, 2nd ed., Graphics Press,
2001
C. Yu , et al., Visual data mining of multimedia data for social and behavioral studies,
Information Visualization, 8(1), 2009
100