0
0
Data Analysis Pythondata~10 mins

Label encoding in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the LabelEncoder class from sklearn.

Data Analysis Python
from sklearn.preprocessing import [1]
Drag options to blanks, or click blank then click option'
AMinMaxScaler
BStandardScaler
COneHotEncoder
DLabelEncoder
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong class like StandardScaler or OneHotEncoder.
Forgetting to import from sklearn.preprocessing.
2fill in blank
medium

Complete the code to create a LabelEncoder object named 'encoder'.

Data Analysis Python
encoder = [1]()
Drag options to blanks, or click blank then click option'
ALabelEncoder
BStandardScaler
COneHotEncoder
DMinMaxScaler
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to create an instance of a scaler or one-hot encoder instead.
Forgetting the parentheses to call the class.
3fill in blank
hard

Fix the error in the code to fit the encoder to the list of labels 'colors'.

Data Analysis Python
encoder.[1](colors)
Drag options to blanks, or click blank then click option'
Afit
Bfit_transform
Cencode
Dtransform
Attempts:
3 left
💡 Hint
Common Mistakes
Using transform before fitting the encoder.
Using a non-existent method like encode.
4fill in blank
hard

Fill both blanks to encode the list 'colors' and store the result in 'encoded_colors'.

Data Analysis Python
encoded_colors = encoder.[1](colors)
print([2])
Drag options to blanks, or click blank then click option'
Afit_transform
Bencoded_colors
Ccolors
Dtransform
Attempts:
3 left
💡 Hint
Common Mistakes
Using transform without fitting first.
Printing the original list instead of the encoded one.
5fill in blank
hard

Fill all three blanks to create a label encoder, fit it to 'fruits', and transform 'fruits' into 'encoded_fruits'.

Data Analysis Python
encoder = [1]()
encoder.[2](fruits)
encoded_fruits = encoder.[3](fruits)
Drag options to blanks, or click blank then click option'
ALabelEncoder
Bfit
Ctransform
Dfit_transform
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit_transform and then transform again.
Not fitting the encoder before transforming.