MulaiMulai sekarang secara gratis

Normalization

As discussed in the video, in normalization you linearly scale the entire column between 0 and 1, with 0 corresponding with the lowest value in the column, and 1 with the largest.
When using scikit-learn (the most commonly used machine learning library in Python) you can use a MinMaxScaler to apply normalization. (It is called this as it scales your values between a minimum and maximum value.)

Latihan ini adalah bagian dari kursus

Feature Engineering for Machine Learning in Python

Lihat Kursus

Petunjuk latihan

  • Import MinMaxScaler from sklearn's preprocessing module.
  • Instantiate the MinMaxScaler() as MM_scaler.
  • Fit the MinMaxScaler on the Age column of so_numeric_df.
  • Transform the same column with the scaler you just fit.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import MinMaxScaler
____

# Instantiate MinMaxScaler
MM_scaler = ____()

# Fit MM_scaler to the data
____.____(so_numeric_df[['Age']])

# Transform the data using the fitted scaler
so_numeric_df['Age_MM'] = ____.____(so_numeric_df[['Age']])

# Compare the origional and transformed column
print(so_numeric_df[['Age_MM', 'Age']].head())
Edit dan Jalankan Kode