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

Tarea

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.

Solución

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

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

Desliza para mostrar el menú

Tarea

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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 4
single

single

some-alt