Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer 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

Taak

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.

Oplossing

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

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

Veeg om het menu te tonen

Taak

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.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
single

single

some-alt