Level 01
Univariate.
One variable, examined on its own. Where its values sit, how far they spread, which way they lean, how wild its tails are, and what is missing.
1.1
Univariate analysis
The examination and understanding of a single variable in a dataset.
Its purpose is to explore the distribution, central tendency, spread and potential anomalies of that variable before using it in a model.
Statistical summary
Basic statistics like mean, median, mode, standard deviation, min/max are calculated to summarize the variable's behavior.
Feature insights
Analyzing one variable at a time shows its range, skewness and variability, which informs feature engineering and preprocessing steps like normalization or encoding.
Visualization
Histograms, boxplots, bar charts and density plots to visually inspect patterns or irregularities.
Understanding data quality
It helps identify missing values, outliers or inconsistent entries, which are critical in data-centric approaches where the quality of data often matters more than the complexity of the model.
1.2
Statistical summary for categorical attributes
The main statistics to collect are:
- Frequency counts: number of occurrences of each category. Given the attribute ‘Municipality of residence’ for the Italian citizen dataset, the ‘Bologna’ value appears in about 0.6% of cases (\approx 3.7\times10^5 / 6\times10^7).
- Relative frequency / proportions: percentage of each category relative to the total. Example: 50% Red, 30% Blue, 20% Green.
- Mode: the most frequent category. The mode of ‘Municipality of residence’ is ‘Rome’, appearing in about 4.5% of cases (\approx 2.7\times10^6 / 6\times10^7).
- Unique values / cardinality: number of distinct categories. Helps identify high-cardinality variables that may need special handling.
- Missing values: count and proportion of missing or null entries.
Count the categories
1.3
Statistical summary for numerical attributes
The main statistics to collect are:
Central tendency
- Mean: average value
- Median: middle value (robust to outliers)
- Mode: most frequent value
Position
Describes where values lie within the distribution.
- Minimum / Maximum
- Quartiles (Q1, Q2/median, Q3)
- Percentiles (e.g., 5th, 95th)
Dispersion
Describes how spread out the values are.
- Standard deviation: average spread around the mean
- Variance: squared dispersion
- Range: difference between max and min
- Interquartile range (IQR): spread between Q1 and Q3 (robust to outliers)
Distribution shape
- Skewness: measures asymmetry (left/right tail)
- Kurtosis: measures “tailedness” or peakness of the distribution
Missing values
Count and proportion of missing or null entries.
1.4
Measures of position: mean and median
The mean is the most common measure for locating a set of points.
Unfortunately, the mean is very sensitive to outliers. In many cases it is preferred to use the median or a “controlled” mean. In a set of n data arranged in ascending order, the median is the term occupying the central place if the terms are odd; if the terms are even, it is the arithmetic mean of the 2 central terms.
Tug of war: drag a value, watch who follows
1.5
Measures of dispersion
Range is the difference between the minimum and maximum values taken by the attribute. Variance and standard deviation are the most common measures of dispersion of a data set.
Variance is sensitive to outliers since it is quadratically related to the concept of mean. Other measures less sensitive to this problem are:
Contaminate a sample: which measures flinch?
Sample clean vs contaminated
Change from the clean sample
The course example compares two samples whose histograms look alike, except that the second one has a longer left tail. Variance grows by 48%, while MAD moves by only 4%:
| Statistic | Sample 1 | Sample 2 (left tail) |
|---|---|---|
| Mean | 19.826 | 18.676 |
| Median | 19.656 | 19.272 |
| 25% quartile | 16.793 | 15.256 |
| 75% quartile | 22.750 | 22.552 |
| Variance | 25.313 | 37.581 |
| StandDev | 5.031 | 6.130 |
| RI | 5.958 | 7.296 |
| AAD | 3.857 | 4.580 |
| MAD | 2.980 | 3.095 |
1.6
Percentiles and quartiles
Given an ordinal or continuous attribute x and a number p between 0 and 100, the p-th percentile is the value x_p of x such that p\% of the observed values for x are lower than x_p.
- For the attribute “height in centimeters” of the population of Italian female infants at one year of age: the 50th percentile = 78 cm → half of the girls are taller than 78 cm; the 97th percentile = 81 cm → only 3% of girls are taller than 81 cm.
- Percentiles are useful when high precision is needed, for example to define thresholds, normalize data, or analyze distribution tails (e.g., 95th or 99th percentile).
Quartiles are a special case of percentiles: they divide the data into 4 equal parts.
- Q1 (first quartile) = 25th percentile
- Q2 (second quartile) = 50th percentile (the median)
- Q3 (third quartile) = 75th percentile
- Quartiles are often used for quick analysis and to compute the IQR (useful for detecting outliers: the box plot flags values beyond Q1 - 1.5\,IQR and Q3 + 1.5\,IQR).
Slide p, find xp
1.7
Skewness
Skewness measures how asymmetrical a distribution is relative to the mean.
- \gamma(\bx) = 0 symmetric distribution
- \gamma(\bx) > 0 positive asymmetry (longer right tail)
- \gamma(\bx) < 0 negative asymmetry (longer left tail)
Why the third power?
- If we just compute \sum(x_i - \xb) we would get 0 by definition of mean.
- Squaring, (x_i - \xb)^2, gives the variance but loses the sign.
- Cubing, (x_i - \xb)^3, preserves the sign: positive deviations (values above the mean) contribute positively, negative deviations (values below the mean) contribute negatively.
Why divide by σ³?
- To make skewness dimensionless (so it doesn't depend on the units of measurement).
- To standardize it, so that we can compare distributions of different scales.
Power up the deviations
Bend the distribution
1.8
Kurtosis
Kurtosis measures how heavy the tails of a distribution are (propensity to extreme values).
- \kappa(\bx) = 3 mesokurtic (tails as heavy as in the normal distribution)
- \kappa(\bx) > 3 leptokurtic (heavier tails: more extreme values)
- \kappa(\bx) < 3 platykurtic (lighter tails: fewer extreme values)
- Excess kurtosis = \kappa(\bx) - 3 (= 0 for the normal distribution)
Why the fourth power?
- As in the variance, an even power makes all deviations positive: the direction of a deviation is lost (it is measured by skewness).
- Compared with the square, the fourth power amplifies large deviations: a value at 1σ from the mean contributes 1, at 2σ contributes 16, at 3σ contributes 81.
- Kurtosis is therefore dominated by the few values in the tails, not by the values close to the mean.
Why divide by σ⁴?
To make kurtosis dimensionless and to compare distributions of different scales.
Since \kappa = 3 for every normal distribution, tools
often return the excess kurtosis \kappa - 3 (e.g., pandas
.kurt(), scipy.stats.kurtosis).
- Skewness tells on which side of the mean the deviations are; kurtosis tells how extreme the largest deviations are, whatever their side.
- Distributions with the same mean, variance and skewness can still differ: values spread evenly vs. many values close to the mean plus a few very far away (potential outliers).
The 4th-power magnifier
Same mean, same σ, same skewness: spot the difference
1.9
Additional profiling information
Data granularity
Which is the level of detail of raw data?
- Setting the right level of abstraction of the data provided to a model impacts performance.
- It can hide or emphasize patterns and bias.
Data quality
Which errors are present in the data?
- missing values
- noise
- inconsistencies
- duplicates
- measurement errors
Label availability
Are labels available? How many labeled instances exist? Are labels reliable?
Granularity: the same incomes at four zoom levels
Missing values in the Titanic dataset
1.10 · Boss level
Profile the bank data
bank-data.csv: 600 instances, no missing data. Pick any attribute and
read its full statistical summary: the same profile a notebook would print, but you
can poke at it.