Model Documentation
churn_rate_by_risk_level(rfm_table)
Calculate churn rates by risk level based on customer churn risk classification.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rfm_table |
DataFrame
|
Data with churn risk levels. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Churn rate percentages by churn risk level. |
Source code in CRR/model/model.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
classify_churn_risk(rfm_table)
Classify customers into churn risk levels based on their RFM scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rfm_table |
DataFrame
|
Data with RFM scores. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Data updated with a 'ChurnRiskLevel' column. |
Source code in CRR/model/model.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
get_clusters(df)
Apply K-Means clustering to customer data based on RFM metrics and save the results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
Customer data with RFM metrics. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
Updated customer data including cluster assignments. |
Source code in CRR/model/model.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
get_rfm(customers_df, products_df, orders_df)
Calculate Recency, Frequency, and Monetary values for each customer and assign RFM scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
customers_df |
DataFrame
|
Contains customer data with at least 'CustomerID'. |
required |
products_df |
DataFrame
|
Contains product data with at least 'ProductID'. |
required |
orders_df |
DataFrame
|
Contains order data with 'OrderDate', 'CustomerID', 'ProductID', 'Price', and 'Quantity'. |
required |
Returns:
Name | Type | Description |
---|---|---|
DataFrame |
DataFrame
|
A DataFrame with each customer's RFM scores and metrics, merged with the customer information. |
Source code in CRR/model/model.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|