Removing outliers with mean ± 3 standard deviations, which statistic must be computed first on the training data?
- Exam domain
- Data Processing20% of the exam
- Difficulty
- Medium
- In this mock
- 10 questions on this domainPractise this domain
Why the exam asks this
Data Processing (20% of the exam)
Objective in the exam guide: Remove outliers from a Spark DataFrame based on standard deviation or IQR
Removing outliers by standard deviation is named.
Why D is the answer
The mean and standard deviation of the feature
The standard-deviation rule keeps values within mean ± k × stddev, so both are computed first, on training data to avoid leakage.
Remember: Mean and stddev define bounds.
How it works
The standard-deviation rule needs mean and spread.
In detail
- Mean and stddev first.
- Compute on training data.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. The number of distinct valuesWrong
Distinct counts are unrelated.
B. The quartiles onlyWrongMost tempting
Quartiles belong to the IQR rule.
Why it tempts: Quartiles belong to the other rule.
C. The median of every column, because the rule uses mediansWrong
That rule uses mean, not median.
D. The mean and standard deviation of the featureRight
Mean and stddev define bounds.
Use case
An illustrative scenario, not a real incident.
Illustrative: transaction amounts beyond mean + 3σ are reviewed before training.
See it in different ways
flowchart LR S0["Compute mean and stddev"] --> S1["Set bounds"] --> S2["Filter rows"]
How to read this chart
- Read it in order: Compute mean and stddev, then Set bounds, then Filter rows.
sequenceDiagram participant P0 as Notebook participant P1 as Spark P0->>P1: agg mean, stddev P1-->>P0: values P0->>P1: filter within bounds
How to read this chart
- 1. Notebook sends "agg mean, stddev" to Spark.
- 2. Notebook gets a reply from Spark: "values".
- 3. Notebook sends "filter within bounds" to Spark.