MLA-C01 Question 54
Select 2You are building a machine learning model to predict housing prices, and your dataset contains several columns, including 'lot_size', 'number_of_rooms', and 'house_age'. Upon inspecting the dataset, you notice that the 'lot_size' column contains several large values that are far beyond the typical range of other data points, and the 'number_of_rooms' column has multiple missing values. How should you handle this data before training the model?
- A
Remove the rows with missing values in the 'number_of_rooms' column to ensure a clean dataset.
- B
Impute the missing values in the 'number_of_rooms' column using the median value of the column.
- C
Normalize the 'lot_size' column to bring its values into a comparable range with other features.
- D
Replace the outliers in the 'lot_size' column with the mean value of the column.
- E
Drop the 'lot_size' column entirely as it contains outliers.
Show answer and explanation
Correct answers: B, C
Explanation
Handling missing values and outliers effectively is crucial for building a robust machine learning model. Imputing missing values with the median helps retain data integrity without being affected by outliers, and normalizing the 'lot_size' column ensures that the feature scales are comparable, reducing the impact of extreme values. These transformations prepare the data for modeling without losing important information or introducing bias.
- A. Incorrect.
Removing rows with missing values can lead to unnecessary loss of data, especially if the number of missing values is small. Imputation is a better approach in this case.
- B. Correct.
Imputing missing values with the median is a common and effective technique, especially when the data might have outliers, as the median is less affected by extreme values.
- C. Correct.
Normalizing the 'lot_size' column is an appropriate way to handle large-scale differences between features, ensuring that outliers do not disproportionately affect the model.
- D. Incorrect.
Replacing outliers with the mean can distort the data, as the mean is sensitive to extreme values. A more robust technique is needed for handling outliers.
- E. Incorrect.
Dropping the 'lot_size' column is not recommended unless it is determined to be irrelevant to the prediction task. Outliers can be managed using normalization instead.