Project - Predicting Titanic Passenger Survival using Machine Learning and Python

You are currently auditing this course.
13 / 21

Titanic Machine Learning Project - Build the Pipeline for the Categorical Attributes

Now let us build the pipeline for the categorical attributes:

INSTRUCTIONS

Import OneHotEncoder from sklearn.preprocessing

from << your code goes here >> import OneHotEncoder

Now save the pipeline we create for categorical attributes in a variable named cat_pipeline:

<< your code goes here >> = Pipeline([
        ("select_cat", DataFrameSelector(["Pclass", "Sex", "Embarked"])),
        ("imputer", MostFrequentImputer()),
        ("cat_encoder", OneHotEncoder(sparse=False)),
    ])

Now fit the training data into this pipeline:

cat_pipeline.fit_transform(<< your code goes here >>)
Get Hint See Answer

Loading comments...