Customer loss prediction system based on hybrid model
By combining RFM model, K-means clustering and random forest classification algorithm in the customer churn prediction system, the problem of insufficient accuracy in customer churn prediction is solved, and higher prediction accuracy and customer retention rate are achieved.
Patent Information
- Application Number
- CN202411556286.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
It is difficult for enterprises to effectively predict and reduce the loss of old customers. The existing technology is insufficient in predicting customer churn, and it is difficult to formulate an effective retention strategy.
A customer churn prediction system based on hybrid model is developed, combining RFM model, K-means clustering algorithm and random forest classification algorithm, and combining unsupervised learning and supervised learning, the prediction accuracy is improved and the customer churn rate is reduced.
By combining the advantages of RFM model with K-means clustering and random forest classification, the system can effectively deal with customer churn problems, improve the accuracy of churn prediction and the robustness of the model, help enterprises formulate effective retention strategies, and improve customer retention rates. and economic benefits.
Smart Images

Figure CN119494666A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of customer relationship management and machine learning, and in particular to an RFM model in customer relationship management and a K-means and random forest algorithm in the field of machine learning, and their application in an enterprise customer prediction system. Background Art
[0002] The loss of old customers will bring great losses to the company, and reducing the loss of old customers is crucial to the long-term development of the company. The company needs to predict potential lost customers, analyze the reasons for their loss before the customer is lost, find ways to improve customer retention rate, and formulate effective retention measures.
[0003] With the continuous development of big data technology and the network information industry, machine learning technology provides a more efficient tool for data analysis. Enterprises can build a characteristic model of customer churn based on basic customer information and order data, identify customers who may churn in advance, and formulate targeted retention strategies based on key characteristics, thereby reducing customer churn. Summary of the invention
[0004] The purpose of the present invention is to develop a customer churn prediction system based on a hybrid model, including an RFM model, a K-means clustering algorithm, and a random forest classification algorithm. The system improves prediction accuracy and reduces customer churn rate by combining the advantages of unsupervised learning and supervised learning. In order to achieve the above purpose, the present invention adopts the following technical solutions:
[0005] A customer churn prediction system based on a hybrid model includes a data preprocessing module, a feature selection module, and a customer churn prediction module.
[0006] The data preprocessing module is used for data collection and preprocessing and then feeds back to the feature selection module;
[0007] The feature selection module is used to filter out the features required by the customer churn prediction system from the data set, and feed the filtered data set back to the customer churn prediction module.
[0008] The customer churn prediction module first clusters the customers, predicts the customers in the category identified as insufficiently loyal in the customer classification module, and uses a random forest algorithm to predict the customers who may churn.
[0009] The data in the data preprocessing module comes from the historical data of users' consumption in the store, and the historical data is put into the data set. The read_csv function of the pandas library is used to read the data from the CSV file and put it into the data set.
[0010] When preprocessing the data set, check whether there are duplicate values in the data set. The data set contains a customer information table, in which the customer ID is the unique primary key. Delete the records with duplicate customer IDs. The data set contains an order details table, in which the order ID is the unique primary key. Delete the duplicate records of the order ID in this table.
[0011] When preprocessing the data set, check whether there are outliers in the data set. The data set contains an order details table, and delete the locked and unpaid records in this table.
[0012] The feature selection module uses the RFM model to identify customers, where R is the number of days from the customer's most recent consumption to the end of the observation window, F is the customer's total consumption times in the observation window, and M is the customer's total consumption amount in the observation window.
[0013] In the feature selection module, the data needs to be standardized to eliminate the impact of the magnitude data. The standardization process uses the Z-score standardization method based on the mean and variance of the data to import the numpy library and the pandas library, use the read_csv function of the pandas library to read the data from the CSV file, and use the mean and std functions of the numpy library to calculate the mean and standard deviation. The formula for calculating the Z-Score value is: Z = (X-mean) / std, where X is the original data, mean is the mean, and std is the standard deviation.
[0014] In the customer churn prediction module, the silhouette coefficient is used to determine the number of clusters. The steps to determine the number of clusters by the silhouette coefficient are as follows:
[0015] For one point i, the average value a(i) of the dissimilarity between the i vector and other points in the same cluster is calculated to reflect the cohesion, and the minimum value b(i) of the average dissimilarity between the i vector and other clusters is calculated to reflect the separation.
[0016] The calculation formula of the silhouette coefficient of sample i is:
[0017]
[0018] The range of the silhouette coefficient of sample i is: [-1, 1]. -1 represents poor classification effect, 1 represents good classification effect. 0 represents cluster overlap and the clusters are not well divided.
[0019] Use the Kmeans function in the sklearn library to cluster the data set according to the number of clusters and determine the cluster labels of customers with low loyalty. The steps are as follows:
[0020] (1) First, select K cluster centers, which can be selected randomly or based on the characteristics of the data itself.
[0021] (2) All data points are assigned to the cluster where the nearest center point is located.
[0022] (3) Recalculate the center point of each cluster, that is, the mean of all points in the cluster.
[0023] (4) Repeat steps (2) and (3) until the cluster center no longer changes or the specified number of iterations is reached.
[0024] The random forest algorithm is used to predict the churn of low-loyalty customer categories, and the high-loyalty customer clusters are not predicted. The steps for using the random forest algorithm to predict customer churn are as follows:
[0025] Import the numpy library, pandas library, and matplotlib library to use the read_csv function of the pandas library to read data from the CSV file, then divide the data set into a training set and a test set, use the RandomForestClassifier() function to create a random forest model instance, and fit the training data in the training set. After fitting, use the test set to evaluate the created random forest model, and finally implement regression prediction of customer data.
[0026] Beneficial effects of the present invention
[0027] The system can effectively handle the customer churn problem of enterprises by combining the advantages of the RFM model with K-means clustering and random forest classification. K-means provides preliminary clustering information of customers, enabling the random forest model to make targeted churn predictions among different customer groups. The ensemble learning mechanism of random forest enhances the ability to predict complex customer behaviors, while reducing the reliance on a single data point and improving the robustness and generalization of the model. Ultimately, the system can provide accurate customer churn predictions for catering companies and help them develop effective retention strategies, thereby improving customer retention and the overall economic benefits of the company. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0029] Figure 1 It is a structural block diagram of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0031] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0033] In the description of the present invention, it should be understood that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, or are the orientations or positional relationships in which the product of the invention is conventionally placed when in use, or are the orientations or positional relationships conventionally understood by those skilled in the art. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0034] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0035] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0036] Implementation steps: The specific implementation steps of the present invention are as follows.
[0037] A customer churn prediction system based on a hybrid model includes a data preprocessing module, a feature selection module, and a customer churn prediction module.
[0038] The data preprocessing module is used to collect and preprocess data and then feed it back to the feature selection module; the feature selection module is used to filter out the features required by the customer churn prediction system in the data set, and feed the filtered data set back to the customer churn prediction module; the customer churn prediction module first clusters the customers, predicts the categories of customers identified as insufficiently loyal in the customer classification module, and uses the random forest algorithm to predict the customers who may churn.
[0039] The data in the data preprocessing module comes from the historical data of users' consumption in the store, and the historical data is put into the data set. The read_csv function of the pandas library is used to read the data from the CSV file and put it into the data set.
[0040] Preferably, when preprocessing the data set, first check whether there are duplicate values in the data set. The data set contains a customer information table, in which the customer ID is the unique primary key, and delete the records with duplicate customer IDs. The data set contains an order details table, in which the order ID is the unique primary key, and delete the duplicate records of the order ID in this table.
[0041] The next step is to check whether there are outliers in the data set. There is an order details table in the data set, and delete the locked and unpaid records in this table.
[0042] The feature selection module uses the RFM model to identify customers. The number of days from the last consumption of the customer in the data set to the end of the observation window is set to R, the total number of consumption times of the customer in the observation window is set to F, and the total consumption amount of the customer in the observation window is set to M.
[0043] In the feature selection module, the data needs to be standardized to eliminate the impact of the magnitude data. The standardization process uses the Z-score standardization method based on the mean and variance of the data to import the numpy library and the pandas library, use the read_csv function of the pandas library to read the data from the CSV file, and use the mean and std functions of the numpy library to calculate the mean and standard deviation. The formula for calculating the Z-Score value is: Z = (X-mean) / std, where X is the original data, mean is the mean, and std is the standard deviation.
[0044] Preferably, the customer churn prediction module uses the silhouette coefficient index to determine the number of clusters, and the steps of determining the silhouette coefficient index to determine the number of clusters are as follows:
[0045] For one point i, the average value a(i) of the dissimilarity between the i vector and other points in the same cluster is calculated to reflect the cohesion, and the minimum value b(i) of the average dissimilarity between the i vector and other clusters is calculated to reflect the separation.
[0046] The calculation formula of the silhouette coefficient of sample i is:
[0047]
[0048] The range of the silhouette coefficient of sample i is: [-1, 1]. -1 represents poor classification effect, 1 represents good classification effect. 0 represents cluster overlap and the clusters are not well divided.
[0049] Preferably, the Kmeans function in the sklearn library is used to cluster the data set according to the number of clusters to determine the cluster labels of customers with low loyalty. The steps are as follows:
[0050] (1) First, select K cluster centers, which can be selected randomly or based on the characteristics of the data itself.
[0051] (2) All data points are assigned to the cluster where the nearest center point is located.
[0052] (3) Recalculate the center point of each cluster, that is, the mean of all points in the cluster.
[0053] (4) Repeat steps (2) and (3) until the cluster center no longer changes or the specified number of iterations is reached.
[0054] Preferably, the random forest algorithm is used to predict the churn of low-loyalty customer categories, and the high-loyalty customer clusters are not predicted. The steps of using the random forest algorithm to predict customer churn are as follows:
[0055] Import the numpy library, pandas library, and matplotlib library to use the read_csv function of the pandas library to read data from the CSV file, then divide the data set into a training set and a test set, use the RandomForestClassifier() function to create a random forest model instance, and fit the training data in the training set. After fitting, use the test set to evaluate the created random forest model, and finally implement regression prediction of customer data.
[0056] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A customer churn prediction system based on a hybrid model, characterized in that: Includes data preprocessing module, feature selection module, and customer churn prediction module; The data preprocessing module is used for data collection and preprocessing and then feeds back to the feature selection module; The feature selection module is used to filter out the features required by the customer churn prediction system from the data set, and feed the filtered data set back to the customer churn prediction module. The customer churn prediction module first clusters the customers, predicts the customers in the category identified as insufficiently loyal in the customer classification module, and uses a random forest algorithm to predict the customers who may churn.
2. A customer churn prediction system based on a hybrid model according to claim 1, characterized in that: The data comes from the historical data of users' consumption in stores. The data is read from the CSV file using the read_csv function of the pandas library and then put into the dataset.
3. A customer churn prediction system based on a hybrid model according to claim 1, characterized in that: When preprocessing the data set, check whether there are duplicate values in the data set. The data set contains a customer information table, in which the customer ID is the unique primary key. Delete the records with duplicate customer IDs. The data set contains an order details table, in which the order ID is the unique primary key. Delete the duplicate records of the order ID in this table.
4. The customer churn prediction system based on hybrid model according to claim 1, characterized in that: When preprocessing the data set, check whether there are outliers in the data set. The data set contains an order details table, and delete the locked and unpaid records in this table.
5. The customer churn prediction system based on hybrid model according to claim 1, characterized in that: The feature selection module uses the RFM model to identify customers, where R is the number of days from the customer's most recent consumption to the end of the observation window, F is the customer's total consumption times in the observation window, and M is the customer's total consumption amount in the observation window.
6. The customer churn prediction system based on hybrid model according to claim 1, characterized in that: In the feature selection module, the data needs to be standardized to eliminate the impact of magnitude data. The standardization process uses the Z-score standardization method based on the data mean and variance.
7. A customer churn prediction system based on a hybrid model according to claim 6, characterized in that: The steps of the Z-score standardization method based on the mean and variance of the data are as follows: import the numpy library and the pandas library to use the read_csv function of the pandas library to read the data from the CSV file, and use the mean and std functions of the numpy library to calculate the mean and standard deviation. The value of the Z-Score is calculated as follows: Z = (X-mean) / std, where X is the original data, mean is the mean, and std is the standard deviation.
8. The customer churn prediction system based on hybrid model according to claim 1, characterized in that: After the customer prediction module uses the Silhouette Coefficient Index to determine the number of clusters, it uses the Kmeans function in the sklearn library to cluster the data set and determine the cluster labels of customers with low loyalty.
9. The customer churn prediction system based on hybrid model according to claim 8, characterized in that: The steps to determine the number of clusters using the Silhouette Coefficient Index are as follows: For one point i, the average value a(i) of the dissimilarity between the i vector and other points in the same cluster is calculated to reflect the cohesion, and the minimum value b(i) of the average dissimilarity between the i vector and other clusters is calculated to reflect the separation. The calculation formula of the silhouette coefficient of sample i is: The range of the silhouette coefficient of sample i is: [-1, 1]. -1 represents poor classification effect, 1 represents good classification effect. 0 represents cluster overlap and the clusters are not well divided.
10. The customer churn prediction system based on hybrid model according to claim 8, characterized in that: Use the Kmeans function in the sklearn library to cluster the data set. The steps are as follows: (1) First, select K cluster centers, which can be selected randomly or based on the characteristics of the data itself. (2) All data points are assigned to the cluster where the nearest center point is located. (3) Recalculate the center point of each cluster, that is, the mean of all points in the cluster. (4) Repeat steps (2) and (3) until the cluster center no longer changes or the specified number of iterations is reached.
11. The customer churn prediction system based on hybrid model according to claim 1, characterized in that: The customer prediction module uses the random forest algorithm to predict churn for customer categories with low loyalty, and does not predict for customer clusters with high loyalty.
12. A customer churn prediction system based on a hybrid model according to claim 11, characterized in that: The steps to use the random forest algorithm to predict customer churn are as follows: Import the numpy library, pandas library, and matplotlib library to use the read_csv function of the pandas library to read data from the CSV file, then divide the data set into a training set and a test set, use the RandomForestClassifier() function to create a random forest model instance, and fit the training data in the training set. After fitting, use the test set to evaluate the created random forest model, and finally perform regression prediction on the customer data.