LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Customer Segmentation in Python

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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)
Code bearbeiten und ausführen