Osio 1. Luku 16
single
Challenge: Scaling the Features
Pyyhkäise näyttääksesi valikon
In this challenge, scale the features of the penguins dataset (already encoded and without missing values) using StandardScaler.
12345import pandas as pd df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a65bbc96-309e-4df9-a790-a1eb8c815a1c/penguins_imputed_encoded.csv') print(df)
Here is a little reminder of the StandardScaler class.
Tehtävä
Pyyhkäise aloittaaksesi koodauksen
You are given a DataFrame named df that contains encoded and imputed penguin data.
Your goal is to standardize all feature values so that each column has a mean of 0 and a variance of 1. This ensures that features are on the same scale before training a machine learning model.
- Import the
StandardScalerclass fromsklearn.preprocessing. - Separate the feature matrix
Xand the target variableyfrom theDataFrame. - Create a
StandardScalerobject. - Apply the scaler to the feature matrix
Xand store the scaled values back intoX.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 16
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme