Challenge: Encoding Categorical Variables
To summarize the previous three chapters, here is a table showing what encoder you should use:
In this challenge, you have the penguins dataset file (with no missing values). You need to deal with all the categorical values, including the target ('species'
column).
Here is the reminder of the data you will work with:
12345import pandas as pd df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a65bbc96-309e-4df9-a790-a1eb8c815a1c/penguins_imputed.csv') print(df.head())
Keep in mind that 'island'
and 'sex'
are categorical features and 'species'
is a categorical target.
Swipe to start coding
Encode all the categorical values. For this, you need to choose the correct encoder for the 'island'
, and 'sex'
columns and follow the steps.
- Import
OnehotEncoder
andLabelEncoder
. - Initialize the features encoder object.
- Encode the categorical feature columns using the
feature_enc
object. - Initialize the target encoder object.
- Encode the target using the
label_enc
object.
Lösning
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 3.13Awesome!
Completion rate improved to 3.13
Challenge: Encoding Categorical Variables
To summarize the previous three chapters, here is a table showing what encoder you should use:
In this challenge, you have the penguins dataset file (with no missing values). You need to deal with all the categorical values, including the target ('species'
column).
Here is the reminder of the data you will work with:
12345import pandas as pd df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a65bbc96-309e-4df9-a790-a1eb8c815a1c/penguins_imputed.csv') print(df.head())
Keep in mind that 'island'
and 'sex'
are categorical features and 'species'
is a categorical target.
Swipe to start coding
Encode all the categorical values. For this, you need to choose the correct encoder for the 'island'
, and 'sex'
columns and follow the steps.
- Import
OnehotEncoder
andLabelEncoder
. - Initialize the features encoder object.
- Encode the categorical feature columns using the
feature_enc
object. - Initialize the target encoder object.
- Encode the target using the
label_enc
object.
Lösning
Tack för dina kommentarer!
single
Awesome!
Completion rate improved to 3.13
Challenge: Encoding Categorical Variables
Svep för att visa menyn
To summarize the previous three chapters, here is a table showing what encoder you should use:
In this challenge, you have the penguins dataset file (with no missing values). You need to deal with all the categorical values, including the target ('species'
column).
Here is the reminder of the data you will work with:
12345import pandas as pd df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a65bbc96-309e-4df9-a790-a1eb8c815a1c/penguins_imputed.csv') print(df.head())
Keep in mind that 'island'
and 'sex'
are categorical features and 'species'
is a categorical target.
Swipe to start coding
Encode all the categorical values. For this, you need to choose the correct encoder for the 'island'
, and 'sex'
columns and follow the steps.
- Import
OnehotEncoder
andLabelEncoder
. - Initialize the features encoder object.
- Encode the categorical feature columns using the
feature_enc
object. - Initialize the target encoder object.
- Encode the target using the
label_enc
object.
Lösning
Tack för dina kommentarer!