Skip to content

Commit 95c130f

Browse files
committed
Improving robustness of recency score creation. @c-simpson and I worked out a bug which was appending improper max values. Now it is robust to max values which are either max for data if it is below max bin edge or will use pre-existing max bin edge
1 parent 5367b6e commit 95c130f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/server/rfm_funcs/create_scores.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ def create_scores(query_date):
6868

6969
grouped_past_year[('days_since', 'min')]= grouped_past_year[('days_since', 'min')].dt.days
7070

71-
recency_bins.append(grouped_past_year[('days_since', 'min')].max())
71+
max_maybe = grouped_past_year[('days_since', 'min')].max()
72+
73+
real_max = max(max_maybe, max(recency_bins)+1 )
74+
75+
recency_bins.append(real_max)
76+
77+
78+
# recency_bins.append(grouped_past_year[('days_since', 'min')].max())
7279

7380
grouped_past_year['recency_score'] = pd.cut(grouped_past_year[('days_since','min')], bins= recency_bins, labels=recency_labels, include_lowest = True)
7481
grouped_past_year.rename(columns={('recency_score', ''): 'recency_score'})

0 commit comments

Comments
 (0)