Challenge: Compose a Data Pipeline
Uppgift
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ösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 4
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Fantastiskt!
Completion betyg förbättrat till 5.26
Challenge: Compose a Data Pipeline
Svep för att visa menyn
Uppgift
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ösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 3. Kapitel 4
single