02data Part2
02data Part2
http://turing.cs.pub.ro/mas_11
curs.cs.pub.ro
[email protected]
University of Management and Technology
Fall 2018
Chapter 2: Getting to Know Your Data
Data Visualization
Summary
2
2.2 Basic Statistical Descriptions of Data
Motivation
To better understand the data: central tendency,
variation and spread
3
4
Basic Statistical Descriptions of Data
Numerical dimensions
correspond to sorted intervals
Data dispersion: analyzed with multiple granularities
of precision
Boxplot or quantile analysis on sorted intervals
5
Measuring the Central Tendency
Mean (algebraic measure) (sample vs. population): 1 n
x xi
n i 1
Note: n is sample size and N is population size.
Weighted arithmetic mean:
Trimmed mean: chopping extreme values x
N
w x i i
x i 1
n
w
i 1
i
6
Activity
Calculate Mean,
Data: 3, 1, 5
> 85 80-84 75-79 70-74 63-69 60-62 55-59 50-54 < 50 …..
6 10 14 18 15 12 8 6 2 1
20 B
18
16
14 B+ B- C+
12 A-
10
8
A
6
4
2
0
8
Measuring the Central Tendency…
Mode
Value that occurs most frequently in the data
1,2,3,3,3,4,4,5 (mode = 3)
Fm Fm 1
mod e L ( ) width Mode
( Fm Fm 1 ) ( Fm Fm 1 ) interval
n / 2 ( freq ) l
median L1 ( ) width Median
freq median interval
10
Measuring the Central Tendency…
Midrange
Average of max and min values
(Max + Min)/2
Activity
Calculate Median, Mode, Midrange
Data: 3, 1, 5
14
A student has gotten the following grades on his
tests: 87, 95, 76, and 88.
He wants an 85 or better overall. What is the
minimum grade he must get on the last test in
order to achieve that average?
15
Symmetric vs. Skewed Data
Boxplot: ends of the box are the quartiles; median is marked; add whiskers,
18
Measuring the Dispersion of Data
Variance and standard deviation (sample: s, population: σ)
Variance: (algebraic, scalable computation)
The average of the squared differences from the Mean.
1 n 1 n 2 1 n 2 1 n
1 n
s
2
n 1 i 1
( xi x )
2
[ xi ( xi ) ]
n 1 i 1 n i 1
2
N
i 1
( xi
2
)
N
x
i 1
i
2
2
19
Standard Deviation
http://standard-deviation.appspot.com/
20
Python Code Examples
Describing a numeric Series. Describing a categorical Series.
s = pd.Series([1, 2, 3])
s.describe() s = pd.Series(['a', 'a', 'b', 'c'])
count 3.0 s.describe()
mean 2.0 count 4
std 1.0 unique 3
min 1.0 top a
25% 1.5 freq 2
50% 2.0 dtype: object
75% 2.5
max 3.0
21
Standard Deviation
A C E
Test Score (X) X–Mean (d) d2
100 50
110 40
120 30
130 20
140 10
150 0
160 -10
170 -20
180 -30
190 -40
200 -50
SUM
22
Standard Deviation
A B C D E
Test Score Frequency X–Mean (d) fd fd2
(X) (f)
100 8 50 400 20,000
110 13 40 520 20,800
120 17 30 510 15,300
130 20 20 400 8,000
140 21 10 210 2,100
150 22 0 0 0
160 21 -10 -210 2,100
170 20 -20 -400 8,000
180 17 -30 -510 15,300
190 13 -40 -520 20,800
200 8 -50 -400 20,000
SUM 180 132,400
23
Example: Dispersion of Data
30, 36, 47, 50, 52, 52, 56, 60, 63, 70, 70, 110
Q1
Q2
Q3
IQR
Five Number Summary
Variance
SD
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
25
Visualization of Data Dispersion: 3-D Boxplots
28
Graphic Displays of Basic Statistical Descriptions
30
Histograms Often Tell More than Boxplots
31
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 indicates
i i
that approximately 100 fi% of the data are below or
equal to the value xi
33
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
34
Positively and Negatively Correlated Data
35
Uncorrelated Data
36