Data Science FREE Data Science Data Wrangling and Preprocessing Questions and Answers 2 — Questions and Answers
Question 1: Which technique is most appropriate for handling missing numerical data when the dataset contains significant outliers?
- Mean imputation
- Median imputation (Correct answer)
- Mode imputation
- Listwise deletion
Correct answer: Median imputation
Median imputation is preferred over mean imputation when outliers are present because the median is robust to extreme values.
Question 2: What is the primary purpose of one-hot encoding in data preprocessing?
- To normalize numerical features to a standard scale
- To convert categorical variables into binary vector representations (Correct answer)
- To reduce the dimensionality of the dataset
- To remove duplicate records from the dataset
Correct answer: To convert categorical variables into binary vector representations
One-hot encoding transforms each categorical value into a separate binary column, enabling algorithms that require numerical input to process categorical data.
Question 3: When performing a log transformation on a feature that contains zero values, what is the standard approach?
- Replace zeros with the mean of the column
- Apply log1p (log of 1 plus the value) instead of a standard log (Correct answer)
- Remove all rows containing zero values
- Use square root transformation exclusively
Correct answer: Apply log1p (log of 1 plus the value) instead of a standard log
Log1p adds 1 before taking the logarithm, which handles zero values without producing undefined results while preserving the transformation's variance-stabilizing effect.
Question 4: In the context of data wrangling, what does the term 'tidy data' refer to?
- Data that has been cleaned of all missing values
- Data where each variable is a column, each observation is a row, and each value is a cell (Correct answer)
- Data that has been normalized to a 0-1 range
- Data stored in a compressed file format for efficiency
Correct answer: Data where each variable is a column, each observation is a row, and each value is a cell
Tidy data follows Hadley Wickham's principles where each variable forms a column, each observation forms a row, and each type of observational unit forms a table.
Question 5: Which method is most effective for detecting multicollinearity among features during preprocessing?
- Checking for missing value patterns
- Calculating the Variance Inflation Factor (VIF) (Correct answer)
- Performing a chi-square test
- Applying principal component analysis
Correct answer: Calculating the Variance Inflation Factor (VIF)
VIF quantifies how much the variance of a regression coefficient is inflated due to collinearity with other predictors, with values above 5-10 indicating problematic multicollinearity.
Question 6: What is the key difference between label encoding and ordinal encoding for categorical variables?
- Label encoding preserves order while ordinal encoding does not
- Ordinal encoding respects a meaningful rank order while label encoding assigns arbitrary integers (Correct answer)
- Label encoding creates binary columns while ordinal encoding creates a single column
- There is no difference; the terms are interchangeable
Correct answer: Ordinal encoding respects a meaningful rank order while label encoding assigns arbitrary integers
Ordinal encoding assigns integers that reflect a meaningful order (e.g., low=1, medium=2, high=3), while label encoding assigns arbitrary integers without implying any rank relationship.
Which technique is most appropriate for handling missing numerical data when the dataset contains significant outliers?