Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Scaling the Features | Preprocessing Data with Scikit-learn
ML Introduction with scikit-learn

book
Challenge: Scaling the Features

In this challenge, you need to scale the features using StandardScaler. The data is the penguins dataset (encoded and with no missing values).

import 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)
12345
import 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)
copy

Here is a little reminder of the StandardScaler class.

Завдання

Swipe to start coding

  1. Import the class that standardizes features by making the mean equal to 0 and the variance equal to 1.
  2. Initialize the scaler.
  3. Scale the X matrix of features.

Рішення

import pandas as pd
from sklearn.preprocessing import StandardScaler

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a65bbc96-309e-4df9-a790-a1eb8c815a1c/penguins_imputed_encoded.csv')
# Assign X,y variables
X, y = df.drop('species', axis=1), df['species']
# Initialize a sclaer and scale the X matrix
scaler = StandardScaler()
X = scaler.fit_transform(X)
print(X)

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 11
import pandas as pd
from sklearn.preprocessing import ___

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a65bbc96-309e-4df9-a790-a1eb8c815a1c/penguins_imputed_encoded.csv')
# Assign X,y variables
X, y = df.drop('species', axis=1), df['species']
# Initialize a sclaer and scale the X matrix
scaler = ___
X = ___
print(X)
toggle bottom row
some-alt