CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
  • Week 1
    • 1.The ML Lifecycle (from a Specialty Perspective)
    • 2.Data Storage for ML: S3, EFS, FSx for Lustre, and Data Formats
    • 3.Data Ingestion: Kinesis, Glue, Batch vs. Streaming
    • 4.Data Labeling: SageMaker Ground Truth, Active Learning, Label Quality
    • 5.Week 1 Comprehensive Review: ML Overview & Data Engineering 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
    • 1.Statistics Basics: Distributions, Central Tendency, Spread, Transformations, and Sample vs Population
    • 2.Correlation and Relationships: Correlation Coefficients, Causation vs. Correlation, Multivariate Relationships
    • 3.Data Leakage: Causes, Detection, Prevention, and Time-Series and Target Leakage
    • 4.Validation Design: Train/Validation/Test Splits, Cross-Validation, Time-Series Splits, Stratified Sampling
    • 5.Week 5 Comprehensive Review: Statistics and Validation Design
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 5/Day 1

Based on the MLS-C01 exam guide·Report an error

MLS-C01· AssociateWeek 5 · Day 1~32 min read

Day 1 - Statistics Basics: Distributions, Central Tendency, Spread, Transformations, and Sample vs Population

📌 Key Takeaways

  • Don't compute the mean first; look at the distribution shape (skewness, kurtosis) first. Even with identical summary statistics, the actual shape can be completely different.
  • When the data is skewed or has outliers, use robust statistics such as the median and IQR instead of the mean and standard deviation.
  • Linear scaling (standardization, Min-Max) does not change the distribution shape. Reducing skewness requires a nonlinear transformation such as log or Box-Cox.
  • What you hold in your hands is always a sample. Always doubt whether it represents the population (selection bias) and whether the sample is large enough (CLT).
  • Distribution diagnosis is not an end in itself but a prescription that leads to choices of preprocessing, metrics and algorithms. MLS asks about the prescription, not the diagnosis.

Distributions: Look at the Shape First

The final week of EDA is about "summarizing data honestly in numbers and verifying whether that summary can be trusted." Before asking about algorithms, MLS-C01 asks about statistical intuition. Is the distribution skewed? Should you trust the mean or the median? Does this sample fairly represent the population? If you go wrong here, the conclusion is wrong whichever model you choose.

Look at the distribution before the mean. Look at the shape first. Even with the same mean, shapes vary enormously.

Distribution featureMeaningEDA implication
SymmetricBalanced left and right, close to normalMean and standard deviation are representative
Right-skewed (positive skewness)The right tail is long (income, prices)Mean > median, a log-transform candidate
Left-skewed (negative skewness)The left tail is long (scores near a perfect mark)Mean < median
MultimodalMultiple peaksSuspect that subgroups are mixed together
High kurtosisSharp peak with heavy tailsOutliers and extreme values are frequent
  • Skewness: degree of asymmetry. 0 is symmetric; positive means a right tail.
  • Kurtosis: thickness of the tails. The larger it is, the more frequent the extreme values.
  Symmetric (normal)    Right tail (positive skew)   Left tail (negative skew)
    ▁▃▅█▅▃▁              ▂▅█▆▄▃▂▁▁▁                ▁▁▁▂▃▄▆█▅▂
   mean = median          mean > median                mean < median
                        (income · house price · dwell time)   (exam scores near a perfect mark)

  Multimodal                            High kurtosis (heavy tail)
    ▁▃█▄▁▁▂▅█▃▁                          ▁▁▂▄█▄▂▁▁
   Suspect mixed subgroups → split segments   Sharp center, heavy tails → frequent outliers
import pandas as pd
 
df = pd.read_csv("data/transactions.csv")
 
# Summarize the distribution shape in numbers
print(df["amount"].skew())      # skewness: positive means right-skewed
print(df["amount"].kurt())      # kurtosis: positive means sharp with heavy tails
print(df["amount"].describe())  # count, mean, std, min, 25/50/75%, max

A dramatic illustration of the principle "look at the distribution first" is Anscombe's Quartet (1973). Four datasets share the same mean, variance, correlation coefficient and even regression line, yet their scatter plots come out in completely different shapes (a straight line, a curve, one outlier pulling the line, and so on). If you trust summary statistics alone and skip visualization, the real structure of the data stays entirely hidden. This is why EDA always includes histograms, box plots and scatter plots.

Distribution Diagnosis → Prescription Table

The exam asks not "how large is the skewness" but "so what do you do."

Observed shapeDiagnostic signalPrescription (transform / preprocessing)Representative value / metric
Long right tailskew > 0 (by rule of thumb, clearly so above +1)log1p / Box-Cox / Yeo-JohnsonReport the median
Long left tailskew < 0Square or exponential transform, Yeo-JohnsonReport the median
A few extreme valuesMaximum far exceeds Q3 + 1.5·IQRRobustScaler, median for missing-value imputationReport spread with IQR
Two or more peaksMultimodal histogramSplit into subgroups and analyze/model eachMean per segment
Values cluster at one pointVariance near 0 (quasi-constant column)Remove the feature—
Zeros and negatives mixed inLog and Box-Cox cannot be appliedYeo-Johnson (log1p works only down to 0)—

Central Tendency: Mean, Median, Mode

The "middle value" that represents the data is its central tendency.

  • Mean: sum of all values ÷ count. Sensitive to outliers.
  • Median: the middle value when sorted. Robust to outliers.
  • Mode: the most frequent value. Useful for categorical data.

In a skewed distribution, the mean and median diverge. With right skew, the long tail pulls the mean up so that mean > median. Income and house prices are right-skewed, so the median is more representative than the mean.

SituationRecommended central statisticReason
Symmetric distributionMeanUses information from all values without distortion
Skewed, or outliers presentMedianExtreme values only change the ranks and cannot shake the middle value
CategoricalModeMean and median are not even defined
Representative value for missing-value imputationMedian if skewed, mean if symmetricThe imputed value must not distort the center of the distribution

Spread: How Widely Is It Scattered?

The center alone is not enough. You must also look at how scattered the data is.

StatisticDefinitionCharacterWhen to use
RangeMaximum − minimumExtremely sensitive to outliersChecking the physical limits of the values
VarianceMean of squared deviationsUnits are squared, so it is hard to interpretTheory and intermediate computation steps
Standard deviation (std)Square root of the varianceInterpretable in the original unitsThe default spread for symmetric distributions
IQRQ3 − Q1Robust to outliersWhen there is skew or outliers
Coefficient of variation (CV)Standard deviation ÷ meanUnitless, so different variables can be comparedComparing relative variability across variables with different scales

The standard deviation tells you "how far, on average, values lie from the mean" in the original units. In a normal distribution, about 68% fall within the mean ±1σ, about 95% within ±2σ, and about 99.7% within ±3σ (the 68-95-99.7 rule).

When computing the standard deviation from a sample, you divide by n−1, not n (Bessel's correction). The sample mean is the value that minimizes the squared deviations for that very sample, so using it as is systematically underestimates the population variance. Reducing the degrees of freedom by one (n−1) corrects this bias. pandas .std() defaults to the sample basis (ddof=1) while numpy np.std() defaults to the population basis (ddof=0), so the values differ subtly on the same data. This is an exam trap point.

How Transformations Affect Distributions

The decisive difference between scaling and transformation is whether the shape changes.

ProcessingEffectDistribution shape
Standardization (Z-score)Mean 0, standard deviation 1Unchanged. Only location and scale shift
Min-Max normalizationCompresses to [0,1]Unchanged. Only the scale changes
Log transformCompresses large valuesThe right tail approaches symmetry
Square-root transformGentle compressionRelieves weak skew
Box-Cox / Yeo-JohnsonSearches for the optimal λApproaches a normal distribution

The key distinction: linear scaling (standardization, Min-Max) does not change the shape. Skewness remains as it was. Reducing skewness itself requires a nonlinear transformation such as log or Box-Cox.

Transformation Technique Selection Table

TechniqueMethodDistribution shapeRequirementTypical useCaution
Standardization (Z-score)(x − μ) / σUnchangedNoneThe default for linear models, neural networks, PCA, distance-based methodsSensitive to outliers
Min-Max(x − min) / (max − min)UnchangedWhen the range must be fixed[0,1] inputs such as image pixelsOne outlier compresses the rest near 0
RobustScaler(x − median) / IQRUnchangedNoneNumeric data with many outliersThe output range is not fixed
Log (log1p)log(1 + x)Relieves the right tailx ≥ 0Amounts, view counts, dwell timeNegatives not allowed
Square root√xWeak reliefx ≥ 0Count data, weak skewInsufficient for strong skew
Box-CoxSearches for the optimal λApproaches normalx > 0 (positive only)Analyses that need a normality assumptionCannot be used on data with 0 or negatives
Yeo-JohnsonSearches for the optimal λApproaches normalAllows negatives and 0Data with zeros and negatives mixed inValues after the transform are hard to interpret
import numpy as np
from sklearn.preprocessing import StandardScaler, PowerTransformer
 
# Standardization: shape stays the same, only the scale changes
scaler = StandardScaler()
df["amount_std"] = scaler.fit_transform(df[["amount"]])
print(df["amount_std"].skew())   # same as the original — shape unchanged
 
# Log transform: relieves right skew (positive values only)
df["amount_log"] = np.log1p(df["amount"])  # log(1+x), can handle 0
print(df["amount_log"].skew())   # closer to 0 — more symmetric
 
# Box-Cox / Yeo-Johnson: the data decides the optimal transformation
pt = PowerTransformer(method="yeo-johnson")
df["amount_yj"] = pt.fit_transform(df[["amount"]])

⚠️ Pitfall: The question "Does standardizing or normalizing skewed data make it normal?" is a trap. No. Standardization changes only the mean and scale, and the skewness and kurtosis remain. To move closer to normality you need a nonlinear transformation such as log or Box-Cox. Also, log is undefined at 0 and for negatives, so use log1p or Yeo-Johnson.

⚠️ Pitfall: Whatever the transformation, fit it on the training set only and apply just transform to the validation and test sets. Computing the mean, maximum or λ from all the data is leakage at that very moment. This principle is covered in earnest on Day 3.

Sample and Population

Your data is almost always a sample, and what you want to know is the population.

CategoryObjectSymbolCharacter
PopulationThe entire set of interestμ (mean), σ (standard deviation)Parameter, usually unknowable
SampleA subset drawn from the populationx̄ (sample mean), s (sample standard deviation)Statistic, the value we compute
  • A good sample represents the population without bias.
  • Collecting from only one region or one period creates selection bias, and the model learns a distribution that differs from reality.
  • With a small sample the estimate wobbles; as it grows, the standard error σ/√n shrinks and the estimate becomes more precise.

The basis for trusting that the sample mean estimates the population mean is the Central Limit Theorem (CLT). Regardless of the shape of the population distribution, when n is large enough, the distribution of sample means approximates a normal distribution with standard error σ/√n. The larger the sample, the tighter the estimate, and the confidence interval also follows a normal distribution. The habit of asking in EDA "is the sample large enough and representative?" comes from here.

The MLS View: Where Statistical Diagnosis Leads

AWS Service Mapping Table

SituationAWS service / featureReason
Visually profile distributions, missing values and outliers without codeSageMaker Data WranglerAfter importing data, check distributions with built-in analyses and visualizations, and export the applied transformations as a processing flow as they are
Scan large raw data in S3 with SQL to check basic statisticsAmazon AthenaQuery S3 directly without preparing servers to pull count, mean and quantiles
Operate profile reports and cleaning recipes through a visual UIAWS Glue DataBrewManage data profiling and cleaning steps in a reusable form without writing code
Check class imbalance and bias in the data before trainingSageMaker ClarifyProduces pre-training bias metrics to catch sample-representativeness problems early
Fix large-scale transformations as a reproducible jobSageMaker Processing JobReuse the same preprocessing script in training and inference to prevent training-serving skew
Manage computed statistics and derived features team-wideSageMaker Feature StoreLets training and inference share the same feature definitions

Question Clue → Answer Mapping Table

Phrase in the questionSignal to readAnswer to choose
"The income distribution is stretched long to the right"Positive skewnessLog or Box-Cox transform, median as the representative value
"Even after standardizing, it is still skewed"Linear transforms leave the shape unchangedA nonlinear transformation is needed
"There are a few extremely expensive listings"Outliers presentMedian, IQR, RobustScaler
"The values mix zeros and negatives"Log and Box-Cox cannot be usedYeo-Johnson
"The histogram has two peaks"Mixed subgroupsSplit the segments and analyze/model each
"Data was collected from only one region and one month"Selection biasRedesign the sample, secure representativeness
"Increasing the sample made the mean estimate stable"Standard error σ/√n decreasesCentral Limit Theorem (CLT)
"The standard deviations from pandas and numpy differ"Difference in default ddofBessel's correction (sample ddof=1 vs population ddof=0)

Tomorrow covers the relationships between variables — correlation coefficients and the problem of causation.

📖 Glossary

  • Skewness: The degree to which a distribution leans to one side. Positive means a long right tail.
  • Kurtosis: A value showing how thick the tails are. The larger it is, the more frequent the extreme values.
  • Robust statistic: A statistic that is not greatly shaken by outliers. The median and IQR are the classic examples.
  • IQR (interquartile range): Q3 (the upper 25% boundary) − Q1 (the lower 25% boundary). The width over which the middle half is spread.
  • Coefficient of variation (CV): The standard deviation divided by the mean. Used to compare variability among variables whose differing units prevent direct comparison.
  • Bessel's correction: A method that divides by n−1 instead of n when computing the sample variance, correcting the underestimation bias.
  • Linear-transform invariance: The property that transformations that change only location and scale, such as standardization and Min-Max, cannot change the distribution shape.
  • Yeo-Johnson transform: A normalization-oriented nonlinear transformation that, unlike Box-Cox, can be used even when zeros and negatives are present.
  • Selection bias: An error in which the way the sample was gathered produces a distribution different from the population.
  • Central Limit Theorem (CLT): The theorem that, regardless of the population's shape, when the sample is large the distribution of sample means approaches a normal distribution.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

You applied standardization (StandardScaler) to a right-skewed income distribution. Which result is correct?

Question 2

Four datasets with the same mean, variance, and correlation coefficient showed completely different shapes on scatter plots. Which EDA principle does this case emphasize?

Question 3

You want to report a "representative price" for highly skewed housing price data. Which central tendency statistic is robust to outliers?

Question 4

Which is the correct reason that pandas series.std() and numpy np.std(array) return different values on the same data?

Question 5

Which theorem underlies the phenomenon in which, as the sample size grows, the sample mean converges more precisely to the population mean and the distribution of the sample mean approaches a normal distribution?

PreviousWeek 4 Comprehensive Review: Dimensionality, Feature Selection, Visualization, ImbalanceWeek 4 · Day 5Next Correlation and Relationships: Correlation Coefficients, Causation vs. Correlation, Multivariate RelationshipsWeek 5 · Day 2

Official references

  • MLS-C01 official exam page(opens in a new tab)
  • Amazon SageMaker AI documentation(opens in a new tab)

On this page

  • Key Takeaways
  • Distributions: Look at the Shape First
  • Distribution Diagnosis → Prescription Table
  • Central Tendency: Mean, Median, Mode
  • Spread: How Widely Is It Scattered?
  • How Transformations Affect Distributions
  • Transformation Technique Selection Table
  • Sample and Population
  • The MLS View: Where Statistical Diagnosis Leads
  • AWS Service Mapping Table
  • Question Clue → Answer Mapping Table
  • Glossary
  • Practice Questions