Calculate RFM Score
Great work, you will now finish the job by assigning customers to three groups based on the MonetaryValue percentiles and then calculate an RFM_Score which is a sum of the R, F, and M values.
The datamart has been loaded with the R and F values you have created in the previous exercise.
Diese Übung ist Teil des Kurses
Customer Segmentation in Python
Anleitung zur Übung
- Create labels for
MonetaryValuewith an increasing range of 1 through 3. - Assign these labels to three equal percentile groups based on
MonetaryValue. - Create new column
Mbased on theMonetaryValuepercentile group. - Calculate
RFM_Scorebased on the sum of R, F, and M column values.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Create labels for MonetaryValue
m_labels = range(1, ____)
# Assign these labels to three equal percentile groups
m_groups = pd.qcut(datamart['MonetaryValue'], q=____, labels=____)
# Create new column M
datamart = datamart.assign(____=____)
# Calculate RFM_Score
datamart['RFM_Score'] = datamart[['R','F','M']].____(axis=____)
print(datamart['____'].head())