Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-214

RFM Scores

Problem

Compute RFM scores as 3 (>= high threshold), 2 (>= low threshold), or 1. r_thr, f_thr, m_thr are [low, high] pairs; return [r_score, f_score, m_score].

All metrics are treated the same way (higher is better).

Hint

Binning each metric into three levels yields a compact customer profile.

Test cases

case 1
in: [3,12,500,[2,5],[5,10],[100,1000]]
expected: [2,3,2]
case 2
in: [1,2,50,[2,5],[5,10],[100,1000]]
expected: [1,1,1]
case 3
in: [10,1,2000,[2,5],[5,10],[100,1000]]
expected: [3,1,3]
Starter codePython
def rfm_scores(recency, frequency, monetary, r_thr, f_thr, m_thr):
    # Your code here
    pass

3 test cases · run your code against them in the editor