1. University MCA (AI/ML) Semester 2
  2. CAB212
  3. Unit 1

CAB212 · Unit 1: Machine learning foundations

Feature scaling, encoding and handling missing data

8 practice questions

Key points

  • Scale for distance- and gradient-based models
  • Min-max -> [0,1]; z-score -> mean 0, sd 1
  • One-hot for nominal categories
  • Median imputation resists outliers

Scaling puts features on comparable ranges. It matters for distance-based and gradient-based models (k-NN, SVM, k-means, logistic regression, neural networks) but not for tree-based models.

  • Min-max: x' = (x - min) / (max - min), range [0, 1].
  • Standardization (z-score): x' = (x - mean) / std, mean 0 and standard deviation 1.

Encoding categorical data: one-hot encoding makes a binary column per category (no false ordering); ordinal/label encoding maps categories to integers (only for truly ordered categories).

Missing values: drop rows/columns, or impute with mean/median (numeric) or mode (categorical). Median is robust to outliers. Impute using training-set statistics only.

Worked example: values [10, 20, 30]: min-max of 20 = (20-10)/(30-10) = 0.5.

Exam pitfall: label-encoding a nominal feature as integers 1, 2, 3 wrongly implies order and distance; use one-hot encoding instead.

Try two questions

Question 1 · Tier 3, Apply

Which imputation is most robust for a skewed numeric feature with outliers?

  1. Maximum
  2. Zero always
  3. Median
  4. Mean
Show the answer

C. The median is not pulled by extreme values.

Question 2 · Tier 3, Apply

Why is feature scaling important for k-NN?

  1. k-NN is trained with gradient descent
  2. k-NN cannot take numeric input at all
  3. Scaling increases the number of neighbours used
  4. Distance is dominated by features with large ranges
Show the answer

D. Unscaled large-range features dominate Euclidean distance.