1. LPU MCA Semester 1
  2. CAB107
  3. Unit 3

CAB107 · Unit 3: Data collection, preprocessing and visualization

Handling missing values and outliers, data cleaning

10 practice questions · in the MTE and ETE syllabus

Key points

  • MCAR, MAR and MNAR describe why data is missing
  • Mean imputation shrinks variance; median resists outliers
  • IQR fences are Q1 minus 1.5 IQR and Q3 plus 1.5 IQR
  • Winsorisation keeps all rows, trimming removes them

Data cleaning fixes errors, duplicates, inconsistent formats, missing values and outliers before modelling.

Missing data mechanisms: MCAR (missing completely at random, unrelated to any value), MAR (missing at random, depends only on other observed columns) and MNAR (missing not at random, depends on the unseen value itself, for example high earners skipping the income question).

Treatments: listwise deletion drops incomplete rows, which risks heavy data loss and bias if the dropped rows differ; imputation fills gaps with the mean, median, mode or a model prediction. Mean imputation reduces variance because the filled values sit exactly at the mean and add no spread. The median is preferred for skewed columns with outliers because it resists extreme values.

Outlier detection uses the IQR rule: values below Q1 minus 1.5 IQR or above Q3 plus 1.5 IQR. With Q1 = 10 and Q3 = 20, IQR is 10 and the upper fence is 35, so a point at 38 is an outlier.

TreatmentRows kept?
Trimming or deletionNo, rows removed
Winsorisation (cap at a percentile)Yes

Exam trap: an outlier is not necessarily an error, and a blank answer to a question is genuinely missing, not a valid category.

Try two questions

Question 1 · Tier 2, Understand

Why does mean imputation reduce the variance of a column?

  1. The filled values are chosen far away from the mean in order to widen the spread
  2. Imputation silently deletes the rows that have the largest deviations from the mean value
  3. The filled values equal the mean, so they add no spread while the count grows
  4. Imputation converts the numeric column into a categorical column of labels
Show the answer

C. Points at the mean contribute zero deviation but increase n, which lowers the variance estimate.

Why not A: Mean-filled values sit exactly at the mean, not away from it.

Why not B: Imputation keeps rows; deleting rows is a different method.

Why not D: Imputation does not change the data type.

Question 2 · Tier 3, Apply

A feature has Q1 = 20 and Q3 = 36. Which value is flagged as an outlier by the 1.5 IQR rule?

  1. 61
  2. 55
  3. 40
  4. -3
Show the answer

A. IQR = 16, so the fences are 20 - 24 = -4 and 36 + 24 = 60; only 61 lies beyond.

Why not B: The upper fence is 60, so 55 is inside.

Why not C: 40 is between the quartiles and is not extreme.

Why not D: The lower fence is -4, so -3 is inside.