Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Transformation Grid | Section
Data Preprocessing and Feature Engineering

bookChallenge: Transformation Grid

Uppgift

Swipe to start coding

You are given the Titanic dataset from the seaborn library. Your goal is to perform data transformation using pandas and scikit-learn.

Perform the following steps:

  1. Load the dataset with sns.load_dataset("titanic").
  2. Fill missing values in age and embarked (mean and mode).
  3. Encode the categorical columns sex and embarked using pd.get_dummies() (drop the first category to avoid redundancy).
  4. Scale the numeric columns age and fare using StandardScaler.
  5. Create a new column family_size = sibsp + parch + 1.
  6. Return the transformed dataset as transformed_data.

Print .head() to preview the result.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 8
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookChallenge: Transformation Grid

Svep för att visa menyn

Uppgift

Swipe to start coding

You are given the Titanic dataset from the seaborn library. Your goal is to perform data transformation using pandas and scikit-learn.

Perform the following steps:

  1. Load the dataset with sns.load_dataset("titanic").
  2. Fill missing values in age and embarked (mean and mode).
  3. Encode the categorical columns sex and embarked using pd.get_dummies() (drop the first category to avoid redundancy).
  4. Scale the numeric columns age and fare using StandardScaler.
  5. Create a new column family_size = sibsp + parch + 1.
  6. Return the transformed dataset as transformed_data.

Print .head() to preview the result.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 8
single

single

some-alt