CommencerCommencer gratuitement

Pre-process RFM data

We have loaded the dataset with RFM values you calculated previously as datamart_rfm. Since the variables are skewed and are on different scales, you will now un-skew and normalize them.

The pandas library is loaded as pd, and numpy as np. Take some time to explore the datamart_rfm in the console.

Cet exercice fait partie du cours

Customer Segmentation in Python

Afficher le cours

Instructions

  • Apply log transformation to unskew the datamart_rfm and store it as datamart_log.
  • Initialize a StandardScaler() instance as scaler and fit it on the datamart_log data.
  • Transform the data by scaling and centering it with scaler.
  • Create a pandas DataFrame from 'datamart_normalized' by adding index and column names from datamart_rfm.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Unskew the data
datamart_log = np.____(____)

# Initialize a standard scaler and fit it
scaler = ____()
scaler.____(____)

# Scale and center the data
datamart_normalized = ____.____(____)

# Create a pandas DataFrame
datamart_normalized = pd.____(data=____, index=____.index, columns=____.columns)
Modifier et exécuter le code