Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Compose a Data Pipeline | Pipelines and Composition Patterns
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Mastering scikit-learn API and Workflows

bookChallenge: 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.

  1. Create a ColumnTransformer named preprocessor:
    • For numeric columns, use SimpleImputer(strategy="mean");
    • For categorical columns, use OneHotEncoder(sparse_output=False, handle_unknown="ignore").
  2. Create a Pipeline named pipeline with two steps:
    • "preprocessor": the preprocessor;
    • "model": a LogisticRegression estimator with random_state=42.
  3. Fit pipeline using X_train and y_train.
  4. Predict labels for X_test and store them in y_pred.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

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?

close

bookChallenge: 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.

  1. Create a ColumnTransformer named preprocessor:
    • For numeric columns, use SimpleImputer(strategy="mean");
    • For categorical columns, use OneHotEncoder(sparse_output=False, handle_unknown="ignore").
  2. Create a Pipeline named pipeline with two steps:
    • "preprocessor": the preprocessor;
    • "model": a LogisticRegression estimator with random_state=42.
  3. Fit pipeline using X_train and y_train.
  4. Predict labels for X_test and store them in y_pred.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 4
single

single

some-alt