Wine consumption prediction method based on random forest

By processing and balancing alcohol consumption data based on random forest methods, it solves the problems of low prediction accuracy and majority category bias in existing technologies, achieves more accurate consumer purchase predictions, and helps companies better understand the market.

CN118735580APending Publication Date: 2024-10-01SHANDONG INSPUR DIGITAL BUSINESS TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410814588.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing alcohol consumer purchase prediction methods are based on simple mathematical models. The preprocessing data is simple and the degree of information mining is low, resulting in low accuracy of prediction results. Moreover, the characteristics of alcohol consumption data are complex and the types are redundant, making the classification model operation complex and prone to errors. Overfitting and majority category bias make it impossible to accurately predict high consumption situations.

Method used

A consumption prediction method based on random forest is adopted to collect consumer attribute data, perform data formatting and normalization processing, calculate the Pearson coefficient between features to remove redundant features, balance the sample set, and train a random forest classification model. , predicting consumers’ future spending power.

Benefits of technology

Effectively eliminate redundant features, reduce data dimensions, avoid majority category bias, improve forecast accuracy, and allow companies to better grasp market conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118735580A_ABST
    Figure CN118735580A_ABST
Patent Text Reader

Abstract

The invention discloses a wine consumption prediction method based on a random forest, and relates to the technical field of big data prediction. Comprising the steps of 1, collecting consumer attribute data as modeling data, 2, screening the consumer attribute data and retaining features with higher correlation with sample labels, 3, balancing a sample set, 4, training a random forest classification model by using data of the sample set, and calculating the model of the consumer according to recent data of the consumer by using the random forest classification model. The consumers are classified, and the consumption ability of the consumers on the wine in the future is predicted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention discloses a method, which relates to the technical field of big data prediction, and specifically to a method for predicting alcohol consumption based on random forests. Background Art

[0002] With the development of information technology, consumer purchase predictions are gaining more and more attention from all kinds of companies. At present, the prediction of alcohol consumer purchases is mainly based on the prediction of simple mathematical models. Through the consumer consumption data, fitting consumption curves, and predicting the consumer consumption trend, the data preprocessing is simple, the information mining level is low, and the prediction result accuracy is low, which cannot provide effective guidance in the alcohol marketing process. At the same time, alcohol consumption data has complex characteristics and redundant types. When the classification model is directly used for calculation, the calculation is complex and the amount of calculation is large, which is prone to overfitting. The alcohol sample set has an uneven distribution, and the samples with high consumption labels are usually small. The classification model is trained with an unbalanced sample set, which is prone to bias towards the majority category, resulting in the model being unable to accurately predict other categories. Summary of the invention

[0003] In view of the problems of the prior art, the present invention provides a wine consumption prediction method based on random forest, extracts consumption characteristics from consumption data, predicts consumer purchases, and enables enterprises to better understand market conditions.

[0004] The specific scheme proposed by the present invention is:

[0005] The present invention provides a method for predicting alcohol consumption based on random forest, comprising:

[0006] Step 1: Collect consumer attribute data as modeling data, format the consumer attribute data, normalize the characteristic values ​​of the consumer attribute data, and unify the magnitudes of different attribute data to the same magnitude. The consumer attribute data includes basic data, purchase data, and behavior data.

[0007] Step 2: Screen consumer attribute data, including:

[0008] Step 21: Calculate the Pearson coefficient between the characteristics of consumer attribute data, remove highly correlated features, and obtain preliminary screening results.

[0009] Step 22: Based on the preliminary screening results, a sample set is constructed. The feature data set of the sample set is X, the number of features is m, the first feature M1 is ignored, and the remaining m-1 features are used for training and verification, and the prediction accuracy is calculated.

[0010] Repeatedly calculate the prediction accuracy of ignoring other features to obtain the influence of each feature on the prediction accuracy of the random forest classification model. According to the prediction accuracy ranking, retain the features with higher correlation with the sample label.

[0011] Step 3: Balance the sample set: Calculate the sample set balancing target value for the number of samples under different sample labels in the sample set. For samples with more than the sample set balancing target value, remove samples until the sample set reaches the sample set balancing target value. For samples with less than the sample set balancing target value, add samples until the sample set reaches the sample set balancing target value.

[0012] Step 4: Use the data from the sample set to train a random forest classification model, and use the random forest classification model to classify consumers based on their recent data to predict their future alcohol consumption capacity.

[0013] Furthermore, the basic data involved in step 1 of the alcohol consumption prediction method based on random forest includes the consumer's registration time, region of origin and store information, and the basic data is collected through the consumer profile table, consumer registration table and store-consumer relationship table.

[0014] The purchase data involved includes the purchase amount, quantity, product, purchase time, payment time, pickup time, receipt time and purchase store information. The purchase data is collected through the payment order table, purchase order table and product order table.

[0015] The behavioral data involved include purchase method, pickup method, payment method, activity participation, purchase qualification abandonment rate and number of refunds. The behavioral data are collected through purchase order form, activity information form, winning order form and after-sales order form.

[0016] Furthermore, in the alcohol consumption prediction method based on random forest, the expression of the Pearson coefficient r is used in step 21:

[0017]

[0018] Calculate the correlation between feature x and feature y, where when |r|≥0.8, x and y are highly correlated; when 0.5≤|r|<0.8, x and y are moderately correlated; when 0.3≤|r|<0.5, x and y are slightly correlated; when |r|<0.3, x and y are considered uncorrelated.

[0019] Furthermore, the training verification in step 22 of the alcohol consumption prediction method based on random forest includes:

[0020] First, the feature set of the remaining m-1 features is randomly divided into k parts, the first sample is selected as the validation set, and the remaining k-1 samples are selected as the training set to train the random forest classification model, and the random forest classification model is used to predict the sample category of the validation set and calculate the prediction accuracy; then, the second sample is selected as the validation set and the remaining k-1 samples are selected as the training set, and the model training and prediction accuracy calculation process is repeated until each sample verifies the prediction accuracy of the random forest classification model; finally, the average of the prediction accuracy calculated each time is taken as the prediction accuracy of the model that ignores feature M1.

[0021] Furthermore, in the alcohol consumption prediction method based on random forest, the formula used in step 3 is:

[0022]

[0023] Calculate the sample set balancing target value N target , n is the number of labels, Y i is the number of samples under the i-th label.

[0024] Furthermore, in the alcohol consumption prediction method based on random forest, removing samples in step 3 until the number of sample sets reaches the sample set balance target value includes:

[0025] The features and sample labels retained in step 2 are constructed into a dataset of M+1 dimensions, and the minimum spatial distance of the dataset is calculated:

[0026]

[0027] x1, x2 are two samples in the data set, D(x1, x2) represents the distance between the two samples, M+1 is the dimension of the sample, x 1,j represents the j-th dimension of sample 1, x 2,j represents the j-th dimension of sample 2,

[0028] Remove the data with the smallest D(x1, x2) value until the number of sample sets reaches the balanced target value N target .

[0029] Furthermore, in the alcohol consumption prediction method based on random forest, adding samples in step 3 until the number of sample sets reaches the target value of sample set balance includes:

[0030] The features retained in step 2 are constructed into a data set of M+1 dimensions, and the nearest data point x2 is obtained. x1 is allowed to spread and grow toward x2, using the following formula:

[0031]

[0032] Generate a new data point x3 near x1, where x3 is the newly generated sample point, (x2-x1) is the vector difference between the two sample points, indicating the growth direction of the sample point. is the unit distance between two sample points, δ is the density coefficient of the generated cluster,

[0033] Add the grown x3 to the data set until the number of sample sets reaches the balanced target value N target .

[0034] Furthermore, in the alcohol consumption prediction method based on random forest, before using the sample set data to train the random forest classification model in step 4, the number of decision trees of the random forest classification model is set to 300, and the number of random features selected is set to m is the number of sample features. The growth depth of the decision tree is not limited. The decision tree is split only when the Gini index of the node cannot be reduced. The random forest classification model is trained using the balanced sample set data.

[0035] The present invention also provides a wine consumption prediction device based on random forest, comprising a collection module, a screening module, a sample balancing module and a model prediction module.

[0036] The collection module collects consumer attribute data as modeling data, formats the consumer attribute data, normalizes the characteristic values ​​of the consumer attribute data, and unifies the magnitudes of different attribute data to the same magnitude. The consumer attribute data includes basic data, purchase data, and behavior data.

[0037] The screening module screens consumer attribute data, including:

[0038] Step 21: Calculate the Pearson coefficient between the characteristics of consumer attribute data, remove highly correlated features, and obtain preliminary screening results.

[0039] Step 22: Based on the preliminary screening results, a sample set is constructed. The feature data set of the sample set is X, the number of features is m, the first feature M1 is ignored, and the remaining m-1 features are used for training and verification, and the prediction accuracy is calculated.

[0040] Repeatedly calculate the prediction accuracy of ignoring other features to obtain the influence of each feature on the prediction accuracy of the random forest classification model. According to the prediction accuracy ranking, retain the features with higher correlation with the sample label.

[0041] The sample balancing module balances the sample set: the sample set balancing target value is calculated for the number of samples under different sample labels in the sample set. For samples with more than the sample set balancing target value, samples are removed until the sample set reaches the sample set balancing target value. For samples with less than the sample set balancing target value, samples are added until the sample set reaches the sample set balancing target value.

[0042] The model prediction module uses the data from the sample set to train the random forest classification model, and uses the random forest classification model to classify consumers based on their recent data to predict their future alcohol consumption capacity.

[0043] The benefits of the present invention are:

[0044] By selecting consumer basic data, consumption data, and behavioral data as feature data, and using correlation deduplication and cross-validation ideas to optimize sample attributes, it is possible to effectively eliminate redundant features, select the optimal feature combination, and reduce the dimension of input data; combining the methods of eliminating high aggregation and synthesizing minority classes to balance the sample set so that the number of minority class samples and the number of majority class samples are balanced, avoiding the bias of the random forest classification model trained with unbalanced sample sets towards the majority class; setting reasonable random forest classification model parameters and training a prediction model can efficiently and accurately predict consumer purchases, allowing companies to better grasp market conditions. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0046] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.

[0047] Example 1

[0048] The present invention provides a method for predicting alcohol consumption based on random forest, comprising:

[0049] Step 1: Collect consumer attribute data as modeling data, format the consumer attribute data, and normalize the characteristic values ​​of the consumer attribute data to unify the orders of magnitude of different attribute data to the same order of magnitude. The consumer attribute data includes basic data, purchase data, and behavior data.

[0050] The basic data involved includes the consumer's registration time, region of origin and store information. The basic data is collected through the consumer profile table, consumer registration table and store-consumer relationship table.

[0051] The purchase data involved includes the purchase amount, quantity, product, purchase time, payment time, pickup time, receipt time and purchase store information. The purchase data is collected through the payment order table, purchase order table and product order table.

[0052] The behavioral data involved include purchase method, pickup method, payment method, activity participation, purchase qualification abandonment rate and number of refunds. The behavioral data are collected through purchase order form, activity information form, winning order form and after-sales order form.

[0053] Step 2: Screen consumer attribute data, including:

[0054] Step 21: Calculate the Pearson coefficient between the characteristics of consumer attribute data, remove highly correlated features, and obtain preliminary screening results.

[0055] Step 22: Based on the preliminary screening results, a sample set is constructed. The feature data set of the sample set is X, the number of features is m, the first feature M1 is ignored, and the remaining m-1 features are used for training and verification, and the prediction accuracy is calculated.

[0056] Repeatedly calculate the prediction accuracy of ignoring other features to obtain the influence of each feature on the prediction accuracy of the random forest classification model. According to the prediction accuracy ranking, retain the features with higher correlation with the sample label.

[0057] Step 3: Balance the sample set: Calculate the sample set balancing target value for the number of samples under different sample labels in the sample set. For samples with more than the sample set balancing target value, remove samples until the sample set reaches the sample set balancing target value. For samples with less than the sample set balancing target value, add samples until the sample set reaches the sample set balancing target value.

[0058] Step 4: Use the data from the sample set to train a random forest classification model, and use the random forest classification model to classify consumers based on their recent data to predict their future alcohol consumption capacity.

[0059] Example 2

[0060] Based on Example 1, the method of the present invention can further use the expression of the Pearson coefficient r in step 21:

[0061]

[0062] Calculate the correlation between feature x and feature y, where when |r|≥0.8, x and y are highly correlated; when 0.5≤|r|<0.8, x and y are moderately correlated; when 0.3≤|r|<0.5, x and y are weakly correlated; when |r|<0.3, x and y are considered uncorrelated. Remove highly correlated features to obtain preliminary screening results.

[0063] In step 22, further training verification is performed, including:

[0064] First, the feature set of the remaining m-1 features is randomly divided into k parts, the first sample is selected as the validation set, and the remaining k-1 samples are selected as the training set to train the random forest classification model, and the random forest classification model is used to predict the sample category of the validation set and calculate the prediction accuracy; then, the second sample is selected as the validation set and the remaining k-1 samples are selected as the training set, and the model training and prediction accuracy calculation process is repeated until each sample verifies the prediction accuracy of the random forest classification model; finally, the average of the prediction accuracy calculated each time is taken as the prediction accuracy of the model that ignores feature M1.

[0065] Similarly, the prediction results ignoring other features are repeatedly calculated to obtain the influence of each feature on the prediction accuracy of the random forest classification model. The features with higher correlation with the label can be retained according to the accuracy ranking.

[0066] In step 3, the formula can be further used:

[0067]

[0068] Calculate the sample set balancing target value N target , n is the number of labels, Y i is the number of samples under the i-th label.

[0069] For the number of samples that exceeds the sample set balancing target value, remove the samples until the number of sample sets reaches the sample set balancing target value, including:

[0070] The features and sample labels retained in step 2 are constructed into a dataset of M+1 dimensions, and the minimum spatial distance of the dataset is calculated:

[0071]

[0072] x1, x2 are two samples in the data set, D(x1, x2) represents the distance between the two samples, M+1 is the dimension of the sample, x 1,j represents the j-th dimension of sample 1, x 2,j represents the j-th dimension of sample 2,

[0073] Remove the data with the smallest D(x1, x2) value until the number of sample sets reaches the balanced target value N target .

[0074] For the number of samples that is less than the target value for sample set balancing, increase the number of samples until the number of sample sets reaches the target value for sample set balancing, including:

[0075] The features retained in step 2 are constructed into a data set of M+1 dimensions, and the nearest data point x2 is obtained. x1 is allowed to spread and grow toward x2, using the following formula:

[0076]

[0077] Generate a new data point x3 near x1, where x3 is the newly generated sample point, (x2-x1) is the vector difference between the two sample points, indicating the growth direction of the sample point. is the unit distance between two sample points, δ is the density coefficient of the generated cluster,

[0078] Add the grown x3 to the data set until the number of sample sets reaches the balanced target value N target .

[0079] In step 4, before using the sample set data to train the random forest classification model, set the number of decision trees of the random forest classification model to 300 and the number of random features selected to m is the number of sample features. The growth depth of the decision tree is not limited. The decision tree is split only when the Gini index of the node cannot be reduced. The random forest classification model is trained using the balanced sample set data.

[0080] Example 3

[0081] The present invention also provides a wine consumption prediction device based on random forest, comprising a collection module, a screening module, a sample balancing module and a model prediction module.

[0082] The collection module collects consumer attribute data as modeling data, formats the consumer attribute data, normalizes the characteristic values ​​of the consumer attribute data, and unifies the magnitudes of different attribute data to the same magnitude. The consumer attribute data includes basic data, purchase data, and behavior data.

[0083] The screening module screens consumer attribute data, including:

[0084] Step 21: Calculate the Pearson coefficient between the characteristics of consumer attribute data, remove highly correlated features, and obtain preliminary screening results.

[0085] Step 22: Based on the preliminary screening results, a sample set is constructed. The feature data set of the sample set is X, the number of features is m, the first feature M1 is ignored, and the remaining m-1 features are used for training and verification, and the prediction accuracy is calculated.

[0086] Repeatedly calculate the prediction accuracy of ignoring other features to obtain the influence of each feature on the prediction accuracy of the random forest classification model. According to the prediction accuracy ranking, retain the features with higher correlation with the sample label.

[0087] The sample balancing module balances the sample set: the sample set balancing target value is calculated for the number of samples under different sample labels in the sample set. For samples with more than the sample set balancing target value, samples are removed until the sample set reaches the sample set balancing target value. For samples with less than the sample set balancing target value, samples are added until the sample set reaches the sample set balancing target value.

[0088] The model prediction module uses the data from the sample set to train the random forest classification model, and uses the random forest classification model to classify consumers based on their recent data to predict their future alcohol consumption capacity.

[0089] As the information interaction and execution process between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention, the specific contents can be found in the description of the embodiment of the method of the present invention and will not be repeated here.

[0090] Similarly, the device of the present invention can select consumer basic data, consumption data, and behavior data as feature data, and use correlation deduplication and cross-validation ideas to optimize sample attributes, which can effectively eliminate redundant features, select the optimal feature combination, and reduce the dimension of input data; combine the method of eliminating high aggregation and synthesizing minority classes to balance the sample set, so that the number of minority class samples and the number of majority class samples are balanced, avoiding the bias of the unbalanced sample set training random forest classification model towards the majority class; set reasonable random forest classification model parameters, and train a prediction model, which can efficiently and accurately predict consumer purchases, allowing companies to better grasp market conditions.

[0091] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.

Claims

1. Alcohol consumption prediction method based on random forest, Its characteristics are include: Step 1: Collect consumer attribute data as modeling data, format the consumer attribute data, normalize the characteristic values ​​of the consumer attribute data, and unify the magnitudes of different attribute data to the same magnitude. The consumer attribute data includes basic data, purchase data, and behavior data. Step 2: Screen consumer attribute data, including: Step 21: Calculate the Pearson coefficient between the characteristics of consumer attribute data, remove highly correlated features, and obtain preliminary screening results. Step 22: Based on the preliminary screening results, a sample set is formed. The feature data set of the sample set is X, the number of features is m, and the first feature M is ignored. 1 , use the remaining m-1 features for training verification and calculate the prediction accuracy, Repeatedly calculate the prediction accuracy of ignoring other features to obtain the influence of each feature on the prediction accuracy of the random forest classification model. According to the prediction accuracy ranking, retain the features with higher correlation with the sample label. Step 3: Balance the sample set: Calculate the sample set balancing target value for the number of samples under different sample labels in the sample set. For samples with more than the sample set balancing target value, remove samples until the sample set reaches the sample set balancing target value. For samples with less than the sample set balancing target value, add samples until the sample set reaches the sample set balancing target value. Step 4: Use the data from the sample set to train a random forest classification model, and use the random forest classification model to classify consumers based on their recent data to predict their future alcohol consumption capacity.

2. The alcohol consumption prediction method based on random forest according to claim 1, Its characteristics are The basic data involved in step 1 includes the consumer's registration time, region of origin, and store information. The basic data is collected through the consumer profile table, consumer registration table, and store-consumer relationship table. The purchase data involved includes the purchase amount, quantity, product, purchase time, payment time, pickup time, receipt time and purchase store information. The purchase data is collected through the payment order table, purchase order table and product order table. The behavioral data involved include purchase method, pickup method, payment method, activity participation, purchase qualification abandonment rate and number of refunds. The behavioral data are collected through purchase order form, activity information form, winning order form and after-sales order form.

3. The alcohol consumption prediction method based on random forest according to claim 1, Its characteristics are The expression for the Pearson coefficient r used in step 21 is: Calculate the correlation between feature x and feature y, where when |r|≥0.8, x and y are highly correlated; when 0.5≤|r|<0.8, x and y are moderately correlated; when 0.3≤|r|<0.5, x and y are weakly correlated; when |r|<0.3, x and y are considered uncorrelated.

4. The alcohol consumption prediction method based on random forest according to claim 1, Its characteristics are Step 22 performs training verification, including: First, the feature set of the remaining m-1 features is randomly divided into k parts, the first sample is selected as the validation set, and the remaining k-1 samples are selected as the training set to train the random forest classification model, and the random forest classification model is used to predict the sample category of the validation set and calculate the prediction accuracy; then, the second sample is selected as the validation set, and the remaining k-1 samples are selected as the training set. The model training and prediction accuracy calculation process is repeated until each sample verifies the prediction accuracy of the random forest classification model; finally, the prediction accuracy calculated each time is averaged as the evaluation value ignoring feature M 1 The prediction accuracy of the model.

5. The alcohol consumption prediction method based on random forest according to claim 1, Its characteristics are In step 3, use the formula: Calculate the sample set balancing target value N target , n is the number of labels, Y i is the number of samples under the i-th label.

6. The alcohol consumption prediction method based on random forest according to claim 5, Its characteristics are In step 3, samples are removed until the number of sample sets reaches the target value of sample set balance, including: The features and sample labels retained in step 2 are constructed into a dataset of M+1 dimensions, and the minimum spatial distance of the dataset is calculated: x 1 ,x 2 are two samples in the data set, D(x 1 ,x 2 ) represents the distance between two samples, M+1 is the dimension of the sample, x 1,j represents the j-th dimension of sample 1, x 2,j represents the j-th dimension of sample 2, D(x 1 ,x 2 ) The data with the smallest value is removed until the number of sample sets reaches the balanced target value N target .

7. The alcohol consumption prediction method based on random forest according to claim 5, Its characteristics are In step 3, samples are added until the number of sample sets reaches the target value for sample set balance, including: The features retained in step 2 are constructed into a dataset of M+1 dimensions to obtain the data point x 1 The closest data point x 2 , let x 1 To x 2 Spread growth, using the following formula: In x 1 Generate new data points x nearby 3 , where x 3 is a newly generated sample point, (x 2 -x 1 ) is the vector difference between two sample points, indicating the growth direction of the sample points. is the unit distance between two sample points, δ is the density coefficient of the generated cluster, Will grow x 3 Add data sets until the number of sample sets reaches the balanced target value N target .

8. The alcohol consumption prediction method based on random forest according to claim 1 is characterized in that before using the data of the sample set to train the random forest classification model in step 4, the number of decision trees of the random forest classification model is set to 300, and the number of random features selected is set to m is the number of sample features. The growth depth of the decision tree is not limited. The decision tree is split only when the Gini index of the node cannot be reduced. The random forest classification model is trained using the balanced sample set data.

9. Alcohol consumption prediction device based on random forest, Its characteristics are It includes acquisition module, screening module, sample balancing module and model prediction module. The collection module collects consumer attribute data as modeling data, formats the consumer attribute data, normalizes the characteristic values ​​of the consumer attribute data, and unifies the magnitudes of different attribute data to the same magnitude. The consumer attribute data includes basic data, purchase data, and behavior data. The screening module screens consumer attribute data, including: Step 21: Calculate the Pearson coefficient between the characteristics of consumer attribute data, remove highly correlated features, and obtain preliminary screening results. Step 22: Based on the preliminary screening results, a sample set is formed. The feature data set of the sample set is X, the number of features is m, and the first feature M is ignored. 1 , use the remaining m-1 features for training verification and calculate the prediction accuracy, Repeatedly calculate the prediction accuracy of ignoring other features to obtain the influence of each feature on the prediction accuracy of the random forest classification model. According to the prediction accuracy ranking, retain the features with higher correlation with the sample label. The sample balancing module balances the sample set: the sample set balancing target value is calculated for the number of samples under different sample labels in the sample set. For samples with more than the sample set balancing target value, samples are removed until the sample set reaches the sample set balancing target value. For samples with less than the sample set balancing target value, samples are added until the sample set reaches the sample set balancing target value. The model prediction module uses the data from the sample set to train a random forest classification model, and uses the random forest classification model to classify consumers based on their recent data to predict their future alcohol consumption capacity.

Citation Information

Cited By

  • Wine market demand prediction system based on big data

    CN120338868A