Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Build a Preprocessing Pipeline | Choosing and Evaluating Techniques
Feature Scaling and Normalization Deep Dive

bookChallenge: Build a Preprocessing Pipeline

Aufgabe

Swipe to start coding

You're given a small mixed-type dataset. Build a leakage-safe preprocessing + model pipeline with scikit-learn:

  1. Split data into X (features) and y (target), then do a train/test split (test_size=0.3, random_state=42).
  2. Create a ColumnTransformer named preprocess:
    • numeric columns → StandardScaler()
    • categorical columns → OneHotEncoder(handle_unknown="ignore")
  3. Build a Pipeline named pipe with steps:
    • ("preprocess", preprocess)
    • ("clf", LogisticRegression(max_iter=1000, random_state=0))
  4. Fit on train only, then predict on test:
    • compute y_pred and test_accuracy = accuracy_score(y_test, y_pred)
  5. Add a few prints at the end to show shapes and the accuracy.

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 5. Kapitel 3
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Can you explain this in simpler terms?

What are the main points I should remember?

Can you give me an example?

close

Awesome!

Completion rate improved to 5.26

bookChallenge: Build a Preprocessing Pipeline

Swipe um das Menü anzuzeigen

Aufgabe

Swipe to start coding

You're given a small mixed-type dataset. Build a leakage-safe preprocessing + model pipeline with scikit-learn:

  1. Split data into X (features) and y (target), then do a train/test split (test_size=0.3, random_state=42).
  2. Create a ColumnTransformer named preprocess:
    • numeric columns → StandardScaler()
    • categorical columns → OneHotEncoder(handle_unknown="ignore")
  3. Build a Pipeline named pipe with steps:
    • ("preprocess", preprocess)
    • ("clf", LogisticRegression(max_iter=1000, random_state=0))
  4. Fit on train only, then predict on test:
    • compute y_pred and test_accuracy = accuracy_score(y_test, y_pred)
  5. Add a few prints at the end to show shapes and the accuracy.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 5. Kapitel 3
single

single

some-alt