Complete the code to import the LabelEncoder class from sklearn.
from sklearn.preprocessing import [1]
The LabelEncoder class is used to convert categorical labels into numbers. It is found in sklearn.preprocessing.
Complete the code to create a LabelEncoder object named 'encoder'.
encoder = [1]()To use label encoding, you create an instance of LabelEncoder by calling it like a function.
Fix the error in the code to fit the encoder to the list of labels 'colors'.
encoder.[1](colors)transform before fitting the encoder.encode.The fit method learns the unique labels from the data. transform applies the encoding. fit_transform does both at once.
Fill both blanks to encode the list 'colors' and store the result in 'encoded_colors'.
encoded_colors = encoder.[1](colors) print([2])
transform without fitting first.fit_transform fits the encoder and transforms the data in one step. The result is stored in encoded_colors, which we print.
Fill all three blanks to create a label encoder, fit it to 'fruits', and transform 'fruits' into 'encoded_fruits'.
encoder = [1]() encoder.[2](fruits) encoded_fruits = encoder.[3](fruits)
fit_transform and then transform again.First, create the encoder with LabelEncoder(). Then fit it to learn labels with fit. Finally, transform the data with transform.