Challenge: Compose a Data Pipeline
Task
Swipe to start coding
You are building a scikit-learn data pipeline that keeps preprocessing and modeling in a single reusable object.
- Create a
ColumnTransformernamedpreprocessor:- For numeric columns, use
SimpleImputer(strategy="mean"); - For categorical columns, use
OneHotEncoder(sparse_output=False, handle_unknown="ignore").
- For numeric columns, use
- Create a
Pipelinenamedpipelinewith two steps:"preprocessor": thepreprocessor;"model": aLogisticRegressionestimator withrandom_state=42.
- Fit
pipelineusingX_trainandy_train. - Predict labels for
X_testand store them iny_pred.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 5.26
Challenge: Compose a Data Pipeline
Swipe to show menu
Task
Swipe to start coding
You are building a scikit-learn data pipeline that keeps preprocessing and modeling in a single reusable object.
- Create a
ColumnTransformernamedpreprocessor:- For numeric columns, use
SimpleImputer(strategy="mean"); - For categorical columns, use
OneHotEncoder(sparse_output=False, handle_unknown="ignore").
- For numeric columns, use
- Create a
Pipelinenamedpipelinewith two steps:"preprocessor": thepreprocessor;"model": aLogisticRegressionestimator withrandom_state=42.
- Fit
pipelineusingX_trainandy_train. - Predict labels for
X_testand store them iny_pred.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 4
single