A customer grouping method and system based on decision tree and binary K-means clustering
By combining the decision tree and the bipartite K mean clustering algorithm in the customer grouping method, processing customer characteristics and implementing the grouping algorithm, the existing customer grouping method has been solved, and high precision and explanatory can be achieved customer grouping results.
Patent Information
- Application Number
- CN202111483322.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2041-12-07
AI Technical Summary
The existing customer grouping methods have problems such as low degree of refinement, dependence on business experience, poor interpretability of algorithm results, unclear boundaries of grouping results, and prone to abnormality.
The customer grouping method based on decision tree and bipartite K mean clustering is adopted, and customer grouping rules with good interpretability and high precision are generated through customer feature processing and clustering algorithm implementation, and two types of training methods such as unsupervised learning and supervised learning are supported.
It realizes high-precision and interpretable customer segmentation, combines the accuracy of machine learning methods, avoids the emergence of large-scale customer concentration and exceptions, and facilitates adjustments based on business experience.
Smart Images

Figure CN114254697B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a customer grouping method and system based on decision tree and binary K-means clustering. Background Art
[0002] my country's economy has shifted from a high-speed growth stage to a high-quality development stage. Against this backdrop, many industries have entered an era of stock management from an era of incremental management. Refined management and refined operations based on big data are an inevitable trend in the development of enterprises. Accurate customer segmentation is the basis of refined operations, which allows us to better understand our customers. Good segmentation can not only provide support for precision marketing, but also make product design more targeted and enhance customer experience. In actual customer management, the customer life cycle can be divided into several stages: beginning, growth, stability, decline, and leaving. Customer segmentation can be used throughout the entire life cycle. For example, traffic diversion and acquisition in the beginning stage, product recommendation and habit cultivation in the growth stage, new product design in the stability stage, early warning and promotion in the decline stage, and retention in the leaving stage. Accurate customer segmentation can help companies design and market products that better meet customer expectations, and when customers have negative behaviors, early warnings can be issued more promptly.
[0003] The current mainstream customer clustering method is mainly based on rules extracted from business experience. Business experience rule clustering relies on the experience of business experts. It has certain barriers when used in new scenarios and cannot quickly implement business. In addition, business rules are generally composed of a small number of simple rule reviews, and the degree of refinement is low. Customer clustering based on machine learning algorithms is mainly based on unsupervised learning clustering algorithms such as KMeans algorithm and hierarchical clustering algorithm; and the clustering method based on unsupervised learning clustering has the characteristics of high computational efficiency and good accuracy, but the interpretability of the algorithm results is poor, and the boundaries of the clustering results are unclear, which is not conducive to actual business operations. The clustering of these clustering algorithms tends to concentrate customers into a large category, which is easy to produce some abnormal categories with a small number of customers. Summary of the invention
[0004] In order to solve the deficiencies of the prior art, the present invention proposes a customer grouping method and system based on decision tree and binary K-means clustering, which groups customers by their characteristics, and each customer group can output feature rules for characterization. The feature rules have good interpretability and can be adjusted in combination with business experience to form a high-precision and interpretable customer grouping rule. At the same time, the accuracy of machine learning methods is retained and two types of training methods, unsupervised learning and supervised learning, can be supported. The customer grouping based on the output of the method of the present invention can be used for customer precision marketing, product design, risk management, etc., to improve the company's refined management level, and can also provide a basis for product design.
[0005] To achieve the above objectives, the technical solutions adopted by the present invention include:
[0006] A customer grouping method based on decision tree and binary K-means clustering, characterized by comprising:
[0007] S1. Customer feature processing;
[0008] S2, clustering algorithm implementation;
[0009] Wherein, step S1 includes the following sub-steps:
[0010] S11. Fill in missing values in customer characteristics;
[0011] S12, converting discrete customer characteristics into continuous ones;
[0012] Step S2 includes the following sub-steps:
[0013] S21, setting a cluster set including several customer grouping initial clusters and a maximum number of clusters;
[0014] S22, using the processed customer features to perform segmentation, to obtain a candidate splitting point set including a number of candidate splitting points corresponding to the customer features;
[0015] S23, judging whether the current algorithm implementation mode is unsupervised learning or supervised learning and selecting a gain calculation basis corresponding to the judgment result, splitting the clusters in the cluster set using the corresponding candidate splitting points and performing gain calculations respectively, and obtaining a gain rate corresponding to each candidate splitting point; the gain rate is the ratio between the loss of the cluster after the split and the loss of the cluster before the split, or the gain rate is the difference between the loss of the cluster before the split and the loss of the cluster after the split; the loss of the cluster includes the sum of the Euclidean distances of each point in the cluster to the center of the cluster;
[0016] S24, pre-pruning each candidate splitting point and the corresponding gain rate according to the preset restriction condition;
[0017] S25, selecting the candidate split point with the largest gain rate after pre-pruning and the corresponding cluster as the split point and object cluster of the current round, and obtaining two new clusters after splitting;
[0018] S26, using the two new clusters obtained to replace the object cluster, to obtain the current round cluster set;
[0019] S27, repeatedly executing sub-steps S22 to S26 for the current round of cluster sets until the number of clusters in the current round of cluster sets reaches the maximum number of clusters, and outputting the clustering result.
[0020] Further, the sub-step S27 includes:
[0021] The sub-steps S22 to S24 are performed on the new cluster in the current round cluster set, and the gain rate of the new cluster is compared with the gain rate of the original cluster in the current round cluster set to select the candidate split point with the largest gain rate.
[0022] Furthermore, filling missing values in customer characteristics includes:
[0023] Fill in missing values based on the business logic corresponding to customer characteristics;
[0024] and / or, fill missing values using the median or mean of existing values;
[0025] And / or, fill missing values with unique values that are significantly different from a threshold of existing values.
[0026] Furthermore, converting discrete customer features into continuous features includes:
[0027] Use one-hot encoding to convert unordered discrete features into continuous customer features in the form of binary vectors;
[0028] Use ordinal encoding mapping to convert ordinal discrete features into continuous customer features in the form of numerical sequence.
[0029] Further, the segmentation using the processed customer features includes:
[0030] Divide or traverse the values of customer characteristics equally and select equal points as candidate split points.
[0031] Furthermore, the preset restriction condition includes one or more combinations of the following:
[0032] The size of the cluster after splitting using the candidate split point is limited to no less than three times the original size of the customer group divided by the maximum number of clusters;
[0033] Limiting the gain rate of the cluster after splitting using the candidate splitting point to be no less than a preset minimum gain rate;
[0034] The number of times the cluster is split after being split using the candidate split point is limited to no more than a preset split number threshold;
[0035] The number of times the candidate splitting points generated by segmentation using a single customer feature is split is limited to no more than a preset splitting number threshold.
[0036] Furthermore, the sub-step S27 further includes:
[0037] Before the number of clusters in the current round of cluster sets reaches the maximum number of clusters, if there are no candidate split points that meet the constraints after pre-pruning, the splitting is stopped and the clustering results are output.
[0038] The present invention also relates to a customer grouping system based on decision tree and binary K-means clustering, characterized in that it comprises:
[0039] The customer feature processing module, which is composed of a feature value filling submodule and a discrete feature conversion submodule, is used to fill in missing values in customer features and convert discrete customer features into continuous ones;
[0040] The clustering algorithm implementation module clusters customers according to the customer characteristics processed by the customer characteristic processing module and outputs the clustering results.
[0041] The present invention also relates to a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and the computer program implements the above method when executed by a processor.
[0042] The present invention also relates to an electronic device, characterized in that it comprises a processor and a memory;
[0043] The memory is used to store customer characteristics;
[0044] The processor is used to execute the above method by calling the client feature.
[0045] The beneficial effects of the present invention are:
[0046] The customer clustering method and system based on decision tree and binary K-means clustering described in the present invention is an improved method on the original machine learning clustering method, supports supervised learning and unsupervised learning training, and the obtained clustering results have strong interpretability, conform to the general business rule logic, and are easy to understand. At the same time, they still have the accuracy advantages of conventional machine learning methods. On the whole, it is not easy to have abnormal classifications with a large concentration of customers and a very small number of customers, which is convenient for users to make targeted adjustments based on business experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 The figure is a flow chart of the customer grouping method based on decision tree and binary K-means clustering according to the present invention.
[0048] Figure 2 It is a schematic diagram of the structure of the customer grouping system based on decision tree and binary K-means clustering described in the present invention. DETAILED DESCRIPTION
[0049] In order to more clearly understand the content of the present invention, it will be described in detail with reference to the drawings and embodiments.
[0050] A first aspect of the present invention relates to a Figure 1The customer clustering method based on decision tree and binary K-means clustering in the process shown mainly includes two steps: S1, customer feature processing and S2, clustering algorithm implementation. Among them, S1, customer feature processing requires preprocessing of special customer features that cannot directly execute the clustering algorithm, mainly including S11, filling missing values in customer features and S12, converting discrete customer features into continuous types. In the scenario of customer clustering, there are often basic customer attributes such as gender, age, and education, as well as behavioral features such as customer transactions and click trajectories. In general, these features can be divided into three categories: continuous features, discrete ordered features, and discrete unordered features. It is necessary to fill missing values for customer features, and after completing the filling of missing values, continuous features can be used directly without processing, while ordered discrete features need to be converted into ordered continuous variables, and unordered discrete features need to be converted into one-hot encoding so that the algorithm can calculate the splitting point of the features.
[0051] Specifically, when filling missing values in customer characteristics, you can choose to fill missing values according to the business logic corresponding to the customer characteristics based on the missing situation; for randomly distributed missing content, you can use the median or mean of existing values to fill missing values; if the business logic and distribution type of the missing values cannot be determined and the proportion of missing values is large, you can use specific values that are significantly different from the threshold of existing values to fill missing values, such as -99999 as a substitute. Such extremely different values will be individually identified and separated during the clustering process.
[0052] For discrete customer feature conversion, there are disordered discrete features and ordered discrete features. Among them, disordered discrete features such as the city of residence and industry in customer data need to be one-hot encoded and converted into continuous features. One-hot encoding, also known as single-bit effective encoding, can convert categorical variables into multiple binary vectors, each of which represents one of the states of the original categorical variable. As shown in Table 1, city is a typical disordered feature, and cities do not have the concept of priority under most semantics. After one-hot encoding conversion, the feature is converted from a 4x1 vector to 3 4x1 features, namely whether the city value is Shenzhen, whether the city value is Beijing, and whether the city value is Shanghai. The city value of the customer with customer id 1 is Shenzhen, and after one-hot encoding, its value becomes (1,0,0). One-hot encoding can convert discrete features into continuous features.
[0053] Table 1
[0054]
[0055] For ordered discrete features, such as education level, job level and other information with fixed logical order, the corresponding code values need to be mapped to continuous features. Education level, as shown in Table 2, is a typical ordered discrete feature. Code values are encoded from small to large or from large to small according to code value priority. Feature encoding does not need to consider the value interval after encoding.
[0056] Table 2
[0057]
[0058]
[0059] For S2, the implementation of the clustering algorithm mainly includes the following steps:
[0060] S21. Setting a cluster set including several customer grouping initial clusters and a maximum number of clusters.
[0061] S22. Use the processed customer features to perform segmentation, divide or traverse the values of the customer features equally, select equal points as candidate splitting points, and obtain a candidate splitting point set including a number of candidate splitting points corresponding to the customer features.
[0062] S23, judging whether the current algorithm implementation mode is unsupervised learning or supervised learning and selecting a gain calculation basis corresponding to the judgment result, splitting the clusters in the cluster set using the corresponding candidate splitting points and performing gain calculations respectively, and obtaining a gain rate corresponding to each candidate splitting point; the gain rate is the ratio between the loss of the cluster after the split and the loss of the cluster before the split, or the gain rate is the difference between the loss of the cluster before the split and the loss of the cluster after the split; the loss of the cluster includes the sum of the Euclidean distances of each point in the cluster to the center of the cluster;
[0063] S24. Pre-prune each candidate splitting point and the corresponding gain rate according to preset restriction conditions; preferably, the restriction conditions that can be selected for use include: limiting the size of the cluster after splitting using the candidate splitting point to be no less than three times the original size of the customer group divided by the maximum number of clusters, limiting the gain rate of the cluster after splitting using the candidate splitting point to be no less than a preset minimum gain rate, limiting the number of re-splitting times of the cluster after splitting using the candidate splitting point to be no more than a preset splitting number threshold, and limiting the number of re-splitting times of the candidate splitting point generated by segmentation using a single customer feature to be no more than a preset splitting number threshold.
[0064] S25, selecting the candidate split point with the largest gain rate after pre-pruning and the corresponding cluster as the split point and object cluster of the current round, and obtaining two new clusters after splitting;
[0065] S26, using the two new clusters obtained to replace the object cluster, to obtain the current round cluster set;
[0066] S27, repeating sub-steps S22 to S26 for the current round cluster set until the number of clusters in the current round cluster set reaches the maximum number of clusters, or, before the number of clusters in the current round cluster set reaches the maximum number of clusters, if there is no candidate split point that meets the restriction condition after pre-pruning, then stop splitting and output the clustering result. Preferably, performing sub-steps S22 to S24 on the new cluster in the current round cluster set, and comparing the gain rate of the new cluster with the gain rate of the original cluster in the current round cluster set to select the candidate split point with the largest gain rate can significantly reduce the amount of calculation.
[0067] Specifically, as shown in Table 3, in Example 1, the processed customer feature data set D = {X, Y} is taken as an example, where the original customer feature X = {x1, x2...x p}; Grouping based on Y = {y1,y2...y q}; Given the maximum number of clusters K.
[0068] Table 3
[0069]
[0070]
[0071] Among them, the sequence number 06 in Table 3 corresponds to sub-step S22, which traverses or divides the feature values equally. When the amount of data is large, 5 or 10 equal divisions are used, and the equal number points are selected and added to the candidate split point set.
[0072] The sequence number 09 in Table 3 corresponds to step S23. According to the split point, the feature can divide the data set into two parts, which can be divided into groups according to the original data and calculated according to Y. The loss can now be defined:
[0073] loss
[0074] That is, the Euclidean distance from the point in the cluster to the center of the cluster. It should be pointed out that when the training method is unsupervised learning, Y = X, that is, the input features are used to divide the customer groups and measure the degree of aggregation of the points in the cluster; when the training method is supervised learning, X is used to divide the customer groups and Y is used to measure the degree of aggregation of the points in the cluster. When Y collapses to a 1xN vector, the algorithm has the same effect as the regression tree.
[0075] The loss is calculated for the clusters before and after the split, and the absolute gain can be defined as:
[0076] Gain = δ(D 分裂前 )-(δ(D 分裂后簇1 )+δ(D 分裂后簇2 ))Absolute gain
[0077] Absolute gain will make the algorithm tend to choose larger clusters for splitting. To avoid this, you can also use relative gain and define the gain ratio:
[0078] Relative gain.
[0079] Sequence number 12 in Table 3 corresponds to sub-step S25, and preferably also includes a pre-pruning step corresponding to sub-step S24. After completing the gain calculation, the algorithm needs to be pruned to avoid overfitting of the algorithm. Common pre-pruning methods include limiting the minimum split size of child nodes, the minimum gain of splitting, the minimum gain rate of splitting, the maximum depth, the maximum number of times a feature is used, etc. If the number of customers in the customer base scored by the algorithm is too small, the algorithm performance may be overfitted. If the gain rate is used as a screening method for the optimal cluster, the algorithm will be more inclined to a small customer base. From a business operation perspective, a customer base that is too small is not conducive to the implementation of marketing activities or regulatory measures. The algorithm will limit the size of the split child nodes. Based on business experience, the minimum split size of the present invention is set by default to Where N is the size of the original customer group, and K is the maximum number of customer groups. The total error of the grouping will gradually decrease from large to small, and the rate of decrease will become slower and slower. If the maximum number of customer groups is set too large, there will be a situation where the actual error decreases very little each time the split occurs, but the split continues, which will cause the algorithm to overfit and affect the prediction performance. The present invention supports limiting the quality of each split and stopping redundant splits in time. It should be noted that the use of this parameter may cause the algorithm to be unable to split to the maximum number of customer groups. In order to avoid the algorithm repeatedly splitting the customer group of the same branch, resulting in a child node with a depth much greater than other child nodes, and at the same time avoiding overfitting of the algorithm. The algorithm supports limiting the maximum depth of child nodes. If there is a feature with a strong distinguishing ability, it may be repeatedly used by the algorithm as the optimal segmentation feature. The customer groups cut out in this way are poorly interpretable in actual business operations, so the algorithm supports limiting the maximum number of times the feature is used.
[0080] Corresponding to sub-step S27, after completing the feature splitting, gain calculation and pre-pruning of all clusters in the current cluster table, the algorithm selects the splitting method with the largest gain and its corresponding cluster for splitting. At the same time, the optimal cluster is removed from the cluster table, and two new clusters split from the optimal cluster are added. In the next iteration, the algorithm only calculates the splitting features, splitting points and corresponding gains for the newly added clusters. The newly added clusters are then compared with the previously eliminated clusters, and the optimal split is selected again. When the number of clusters in the cluster table reaches the set maximum number of clusters or there are no candidate splitting methods due to pre-pruning, the algorithm automatically terminates. Output the clustering results and clustering rules.
[0081] The second aspect of the present invention relates to a customer grouping system based on decision tree and binary K-means clustering, the structure of which is as follows: Figure 2 As shown, including:
[0082] The customer feature processing module, which is composed of a feature value filling submodule and a discrete feature conversion submodule, is used to fill in missing values in customer features and convert discrete customer features into continuous ones;
[0083] The clustering algorithm implementation module clusters customers according to the customer characteristics processed by the customer characteristic processing module and outputs the clustering results.
[0084] The above method can be implemented by using this system.
[0085] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A customer clustering method based on decision tree and binary K-means clustering, characterized in that: include: S1. Customer feature processing; S2, clustering algorithm implementation; Wherein, step S1 comprises the following sub-steps: S11. Fill in missing values in customer characteristics; S12, converting discrete customer characteristics into continuous ones; Step S2 includes the following sub-steps: S21, setting a cluster set including several customer grouping initial clusters and a maximum number of clusters; S22, using the processed customer features to perform segmentation, to obtain a candidate splitting point set including a number of candidate splitting points corresponding to the customer features; S23, judging whether the current algorithm implementation mode is unsupervised learning or supervised learning and selecting a gain calculation basis corresponding to the judgment result, splitting the clusters in the cluster set using the corresponding candidate splitting points and performing gain calculations respectively, and obtaining a gain rate corresponding to each candidate splitting point; the gain rate is the ratio between the loss of the cluster after the split and the loss of the cluster before the split, or the gain rate is the difference between the loss of the cluster before the split and the loss of the cluster after the split; the loss of the cluster includes the sum of the Euclidean distances of each point in the cluster to the center of the cluster; S24, pre-pruning each candidate splitting point and the corresponding gain rate according to the preset restriction condition; S25, selecting the candidate split point with the largest gain rate after pre-pruning and the corresponding cluster as the split point and object cluster of the current round, and obtaining two new clusters after splitting; S26, using the two new clusters obtained to replace the object cluster, to obtain the current round cluster set; S27, repeatedly executing sub-steps S22 to S26 for the current round of cluster sets until the number of clusters in the current round of cluster sets reaches the maximum number of clusters, and outputting the clustering result; Step S27, after completing the feature splitting, gain calculation and pre-pruning of all clusters in the current cluster table, the algorithm selects the splitting method with the largest gain and its corresponding cluster for splitting; at the same time, the optimal cluster is removed from the cluster table, and two new clusters obtained by splitting from the optimal cluster are added; in the next iteration, the algorithm only calculates the splitting features, splitting points and corresponding gains for the newly added clusters; then the newly added clusters are compared with the previously eliminated clusters, and the optimal split is selected again; when the number of clusters in the cluster table reaches the set maximum number of clusters or there are no candidate splitting methods due to pre-pruning, the algorithm terminates.
2. The method according to claim 1, characterized in that The sub-step S27 comprises: The sub-steps S22 to S24 are performed on the new cluster in the current round cluster set, and the gain rate of the new cluster is compared with the gain rate of the original cluster in the current round cluster set to select the candidate split point with the largest gain rate.
3. The method according to claim 1, characterized in that Filling missing values in customer characteristics includes: Fill in missing values based on the business logic corresponding to customer characteristics; and / or, fill missing values using the median or mean of existing values; And / or, fill missing values with unique values that are significantly different from a threshold of existing values.
4. The method according to claim 1, characterized in that The step of converting discrete customer features into continuous features includes: Use one-hot encoding to convert unordered discrete features into continuous customer features in the form of binary vectors; Use ordinal encoding mapping to convert ordinal discrete features into continuous customer features in the form of numerical sequence.
5. The method according to claim 1, characterized in that The segmentation using the processed customer features includes: Divide or traverse the values of customer characteristics equally and select equal points as candidate split points.
6. The method according to claim 1, characterized in that The preset restriction condition includes one or more combinations of the following: The size of the cluster after splitting using the candidate split point is limited to no less than three times the original size of the customer group divided by the maximum number of clusters; Limiting the gain rate of the cluster after splitting using the candidate splitting point to be no less than a preset minimum gain rate; The number of times the cluster is split after being split using the candidate split point is limited to no more than a preset split number threshold; The number of times the candidate splitting points generated by segmentation using a single customer feature is split is limited to no more than a preset splitting number threshold.
7. The method according to claim 6, characterized in that The sub-step S27 further comprises: Before the number of clusters in the current round of cluster sets reaches the maximum number of clusters, if there are no candidate split points that meet the constraints after pre-pruning, the splitting is stopped and the clustering results are output.
8. A customer grouping system based on decision tree and binary K-means clustering, characterized in that: include: The customer feature processing module, which is composed of a feature value filling submodule and a discrete feature conversion submodule, is used to fill in missing values in customer features and convert discrete customer features into continuous ones; The clustering algorithm implementation module clusters customers according to the customer characteristics processed by the customer characteristic processing module and outputs the clustering results.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: including a processor and a memory; The memory is used to store customer characteristics; The processor is used to execute the method according to any one of claims 1 to 7 by calling a client feature.
Citation Information
Patent Citations
Customer grouping method and device based on improved decision tree
CN111105266A