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

Tâche

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.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 4
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

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

Glissez pour afficher le menu

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 4
single

single

some-alt