Challenge: Compose a Data Pipeline
Aufgabe
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.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 3. Kapitel 4
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Großartig!
Completion Rate verbessert auf 5.26
Challenge: Compose a Data Pipeline
Swipe um das Menü anzuzeigen
Aufgabe
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.
Lösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 3. Kapitel 4
single