Course Content
ML Introduction with scikit-learn
ML Introduction with scikit-learn
Encode Categorical Variables
To summarize the previous three chapters, here is a table showing what encoder you should use.
Column | Encoder |
X , ordinal values | OrdinalEncoder |
X , nominal values | OneHotEncoder |
y | LabelEncoder |
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:
import 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())
Here 'island'
and 'sex'
are categorical features and 'species'
is a categorical target
Task
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 the correct encoder for features.
- Initialize the features encoder object.
- Fit and transform the categorical feature columns using the
feature_enc
object. - Fit and transform the target using
LabelEncoder
.
Thanks for your feedback!
Encode Categorical Variables
To summarize the previous three chapters, here is a table showing what encoder you should use.
Column | Encoder |
X , ordinal values | OrdinalEncoder |
X , nominal values | OneHotEncoder |
y | LabelEncoder |
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:
import 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())
Here 'island'
and 'sex'
are categorical features and 'species'
is a categorical target
Task
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 the correct encoder for features.
- Initialize the features encoder object.
- Fit and transform the categorical feature columns using the
feature_enc
object. - Fit and transform the target using
LabelEncoder
.
Thanks for your feedback!
Encode Categorical Variables
To summarize the previous three chapters, here is a table showing what encoder you should use.
Column | Encoder |
X , ordinal values | OrdinalEncoder |
X , nominal values | OneHotEncoder |
y | LabelEncoder |
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:
import 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())
Here 'island'
and 'sex'
are categorical features and 'species'
is a categorical target
Task
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 the correct encoder for features.
- Initialize the features encoder object.
- Fit and transform the categorical feature columns using the
feature_enc
object. - Fit and transform the target using
LabelEncoder
.
Thanks for your feedback!
To summarize the previous three chapters, here is a table showing what encoder you should use.
Column | Encoder |
X , ordinal values | OrdinalEncoder |
X , nominal values | OneHotEncoder |
y | LabelEncoder |
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:
import 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())
Here 'island'
and 'sex'
are categorical features and 'species'
is a categorical target
Task
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 the correct encoder for features.
- Initialize the features encoder object.
- Fit and transform the categorical feature columns using the
feature_enc
object. - Fit and transform the target using
LabelEncoder
.