Challenge: Compose a Data Pipeline
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 4
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Mahtavaa!
Completion arvosana parantunut arvoon 5.26
Challenge: Compose a Data Pipeline
Pyyhkäise näyttääksesi valikon
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 4
single