DY0-001 practice question 8 of 15

A data scientist is analyzing a data set with categorical features and would like to make those features more useful when building a model. Which of the following data transformation techniques should the data scientist use? (Choose two.)

Full set: 85 questions
Answer options
A: Normalization
B: One-hot encoding Correct answer
C: Linearization
D: Label encoding Correct answer
E: Scaling
F: Pivoting
Correct Answer:
B. One-hot encoding; D. Label encoding
Explanation

Machine learning algorithms require numerical input. Categorical features, which represent qualitative data (e.g., 'color', 'city'), must be transformed into a numerical format. One-hot encoding is a technique that converts a categorical feature into multiple new binary (0 or 1) columns, with each column representing a unique category. This is ideal for nominal data where no inherent order exists. Label encoding is another technique that assigns a unique integer to each category (e.g., 'low' -> 0, 'medium' -> 1, 'high' -> 2). This method is particularly suitable for ordinal data where a meaningful order is present. Both are fundamental techniques for making categorical features useful for model building.

Why Incorrect

A. Normalization: This technique scales numerical features to a specific range (e.g., 0 to 1) and is not used for categorical data.
C. Linearization: This is not a standard term for encoding categorical features; it relates to transforming data to fit a linear model.
E. Scaling: This is a general term for adjusting the range of numerical data, not for converting categorical data into a numerical format.
F. Pivoting: This is a data reshaping operation used for aggregation and summarization, not a feature encoding technique for modeling.

References

1. Scikit-learn Developers. (n.d.). 6.3. Preprocessing data. Scikit-learn User Guide. Retrieved from scikit-learn.org.

Section 6.3.4

"Encoding categorical features": This section explicitly details the use of OneHotEncoder to "create a binary column for each category" and OrdinalEncoder (which functions like label encoding for features) to "convert each category into an integer value." This directly supports the use of both one-hot and label encoding for categorical features.

2. VanderPlas

J. (2016). Python Data Science Handbook. O'Reilly Media

Inc.

Chapter 5

Section "Feature Engineering"

Subsection "Categorical Features": This section explains the problem with feeding categorical data directly to models and presents solutions. It states

"For categorical features... we can split the category into a number of binary features... This is often called one-hot encoding." It also discusses the alternative of using integer codes for categories (label encoding).

3. Massachusetts Institute of Technology. (2020). MIT 6.036: Introduction to Machine Learning

Fall 2020. MIT OpenCourseWare.

Lecture 9 Notes

Section 4

"Features": The course notes discuss feature representation

stating: "Discrete features with no natural ordering (like 'animal' = 'dog'

'cat'

'bird') are often converted into a one-hot vector representation." This validates one-hot encoding as a standard academic practice.

Scroll to Top