Recall & Review
beginner
What is one-hot encoding in data science?
One-hot encoding is a way to turn categories into numbers by creating new columns for each category. Each column shows 1 if the category is present, and 0 if not.
Click to reveal answer
beginner
Why do we use one-hot encoding before machine learning?
Machine learning models need numbers, not words. One-hot encoding changes categories into numbers so models can understand and learn from them.
Click to reveal answer
beginner
Which Python library is commonly used for one-hot encoding?
Pandas is commonly used for one-hot encoding with its function called get_dummies().
Click to reveal answer
beginner
What does the output look like after one-hot encoding a column with values ['red', 'blue', 'red']?
You get two new columns: one for 'red' and one for 'blue'. Rows with 'red' have 1 in the 'red' column and 0 in 'blue'. Rows with 'blue' have 1 in 'blue' and 0 in 'red'.
Click to reveal answer
intermediate
What is a potential downside of one-hot encoding?
It can create many new columns if there are many categories, which can make the data big and slow to work with.
Click to reveal answer
What does one-hot encoding do to a categorical column?
✗ Incorrect
One-hot encoding creates new columns for each category and marks presence with 1 and absence with 0.
Which pandas function is used for one-hot encoding?
✗ Incorrect
pd.get_dummies() converts categorical variables into one-hot encoded columns.
If a column has 4 unique categories, how many new columns will one-hot encoding create?
✗ Incorrect
One-hot encoding creates one new column for each unique category.
Why might one-hot encoding increase data size?
✗ Incorrect
One-hot encoding adds a new column for each category, increasing the number of columns.
Which type of data is one-hot encoding mainly used for?
✗ Incorrect
One-hot encoding is used to convert categorical data into numerical form.
Explain what one-hot encoding is and why it is useful in data science.
Think about how computers understand data and why categories need to be numbers.
You got /3 concepts.
Describe a simple example of one-hot encoding with a small list of colors.
Imagine you have colors like red, blue, and green.
You got /3 concepts.