Challenge: Compose a Data Pipeline
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Incrível!
Completion taxa melhorada para 5.26
Challenge: Compose a Data Pipeline
Deslize para mostrar o menu
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single