A method for identifying abnormal behavior based on kmeans and iForest decision making
Through the identification method based on kmeans and iForest, combined with data preprocessing and model optimization, abnormal business behaviors in the e-commerce platform are identified, the problem of identifying illegal behaviors in e-commerce is solved, and fast and accurate risk warnings and market order maintenance are achieved.
Patent Information
- Application Number
- CN202410878578.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-07-02
AI Technical Summary
There are irregularities in e-commerce and illegal stores defraud consumers of money through false propaganda, fraudulent sales and other means, leading to a crisis of trust and chaos in the market. It is difficult for existing technology to quickly and accurately identify abnormal business behaviors and non-compliant stores.
The decision-making abnormal behavior identification method based on kmeans and iForest is adopted, and the kmeans-iForest identification model is established by obtaining the commodity operation data of the e-commerce platform for preprocessing. It combines the fusion particle swarm algorithm to optimize iForest parameters and K-Means clustering algorithm, and uses Gap The statistic algorithm is adjusted and optimized to identify stores with abnormal business behavior.
It can quickly and accurately identify abnormal business behaviors and non-compliant stores, provide risk warnings, improve the trust of e-commerce platforms and consumers, and ensure the healthy development of market order.
Smart Images

Figure CN118411183B
Abstract
Description
Technical Field
[0001] The invention relates to a method for identifying abnormal behaviors based on kmeans and iForest decisions. Background Art
[0002] The development of e-commerce has not only changed the way people shop, but also promoted the development strategy of informatization driving industrialization and realized a mutually supportive development model among industries. With the popularization of the Internet and the increase in the number of Internet users, the consumer group of e-commerce has continued to expand and the transaction amount has continued to grow.
[0003] In actual applications, when violations occur in e-commerce, trust in e-commerce platforms and stores will decrease, which will trigger a crisis of trust among consumers and in turn affect the healthy development of the entire e-commerce industry. At the same time, some illegal stores will defraud consumers of their money through false propaganda, fraudulent sales and other means, causing economic losses to consumers. They will also engage in unfair competition such as brushing orders and speculation on reputation, leading to chaos in the market order and damaging the legitimate rights and interests of other stores. Summary of the invention
[0004] The embodiment of the present invention provides an identification method for abnormal behavior based on kmeans and iForest decisions. The method is reasonably designed. Based on the collected commodity data and store data disclosed by the e-commerce platform, data governance and cleaning are performed, a kmeans-iForest recognition model is established to perform parameter adjustment optimization and test recognition, and the screening and recognition effects are evaluated and analyzed, so as to quickly and accurately identify abnormal business behaviors and stores with non-compliant business behaviors or violating the platform's e-commerce business regulations, provide potential risk warnings for the platform and consumers, and solve the problems existing in the prior art.
[0005] The technical solution adopted by the present invention to solve the above technical problems is:
[0006] A method for identifying abnormal behavior based on kmeans and iForest decisions, the method comprising the following steps:
[0007] S1, obtaining commodity operation data of the e-commerce platform within a given period, wherein the commodity operation data includes commodity name, commodity sales volume, commodity sales amount, and the correspondence between commodities and stores, and storing the data in a database;
[0008] S2, pre-process the commodity operation data to ensure that the missing rate of data indicators is within a controllable range;
[0009] S3, establish the kmeans-iForest recognition model, and combine it with the preprocessed commodity operation data to identify stores with abnormal operation behaviors.
[0010] Establishing the kmeans-iForest recognition model and combining it with the preprocessed commodity operation data to identify stores with abnormal operation behaviors includes the following steps:
[0011] S3.1, use the fusion particle swarm algorithm to optimize the iForest parameters, use the fitness function to evaluate the key indicators of each particle, determine the accuracy of the iForest model classification prediction, and complete the outlier detection;
[0012] S3.2, clustering normal commodity operation data using K-Means clustering algorithm;
[0013] S3.3, use the Gap statistic algorithm to adjust and optimize to obtain the optimal number of clusters K.
[0014] The iForest parameters include:
[0015] The number of trees, the more trees there are, the more stable and accurate the model will be;
[0016] The number of subsamples. Different numbers of subsamples will affect the training results. The more elements in a subsample, the more overall information it covers.
[0017] The proportion of abnormal points is used to affect the threshold setting of the abnormal score and accurately identify the abnormalities.
[0018] The optimization of iForest parameters using the fusion particle swarm algorithm includes the following steps:
[0019] S3.1.1, find the optimal solution for a single individual;
[0020] S3.1.2, determine the global optimal solution;
[0021] S3.1.3, optimize and adjust iForest parameters according to the individual optimal solution and the global optimal solution.
[0022] The particle update speed calculation formula of the fitness function is:
[0023]
[0024] After calculating the updated velocity, the new position of the particle can be re-derived:
[0025]
[0026] in, Represents the current iteration number, Meaning: The particle No. The speed in the dimensional direction, The meaning is the current position of the particle. It means the global optimal position obtained by all particles. It means the local optimal position reached by the particle. Represents the inertia weight, which can adjust its optimization ability. and Expressed as an acceleration constant, it can adjust the step size of the optimization. and Indicates that two numbers between the interval [0,1] are randomly generated, which can improve the randomness of the optimization process;
[0027] and The value indicates that the acceleration constant will be set between 1 and 2. It represents individual learning, reflecting the particle's ability to learn and remember its own historical optimal position. When it is larger, it is conducive to fine search in local areas. It represents global learning, which reflects the degree of response of particles to the current optimal position in the entire population. When it is larger, particles are more likely to be attracted by the global optimal solution, which is helpful for global search.
[0028] and The update of particle velocity generated and used to calculate it in each iteration introduces a random search direction, which helps to escape the local optimal trap. In addition, each particle uses an independently generated random number when updating its velocity, which will cause differences between individuals and help maintain diversity within the population and prevent the particle group from being too concentrated in a certain area.
[0029] Clustering normal commodity business data using the K-Means clustering algorithm includes the following steps:
[0030] S3.2.1, select the initialization Samples are used as initial cluster centers ;
[0031] S3.2.2, for each sample in the dataset Calculate its distance to the cluster center and divide it into the class corresponding to the cluster center with the smallest distance;
[0032] S3.2.3, for each category , recalculate its cluster center ;
[0033] S3.2.4, repeat the above steps S3.2.2 and S3.2.3 until the termination condition is reached.
[0034] The termination conditions include that the iteration reaches the cluster center and no longer changes and sets the maximum number of iterations.
[0035] The calculation formula of the Gap statistic algorithm is:
[0036]
[0037] in, is the loss function, here refers to expectations.
[0038] The present invention adopts the above method, collects the commodity operation data of the e-commerce platform within a given period and stores it in a database to provide a data basis for the identification process; ensures that the data indicator missing rate is within a controllable range by preprocessing the commodity operation data; identifies stores with abnormal operation behaviors by establishing a kmeans-iForest recognition model combined with the preprocessed commodity operation data; optimizes the iForest parameters by fusing the particle swarm algorithm, and adjusts and optimizes them by the Gapstatistic algorithm to obtain the optimal cluster number K, which has the advantages of high efficiency, accuracy, simplicity and practicality. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a schematic diagram of the process of the present invention.
[0040] Figure 2 It is an iterative effect diagram of the K-Means clustering algorithm of the present invention. DETAILED DESCRIPTION
[0041] In order to clearly illustrate the technical features of the present solution, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings.
[0042] like Figure 1-Figure 2 As shown in, a method for identifying abnormal behavior based on kmeans and iForest decision making, the identification method includes the following steps:
[0043] S1, obtaining commodity operation data of the e-commerce platform within a given period, wherein the commodity operation data includes commodity name, commodity sales volume, commodity sales amount, and the correspondence between commodities and stores, and storing the data in a database;
[0044] S2, pre-process the commodity operation data to ensure that the missing rate of data indicators is within a controllable range;
[0045] S3, establish the kmeans-iForest recognition model, and combine it with the preprocessed commodity operation data to identify stores with abnormal operation behaviors.
[0046] The method is characterized in that establishing a kmeans-iForest recognition model and combining the pre-processed commodity operation data to identify stores with abnormal operation behaviors includes the following steps:
[0047] S3.1, use the fusion particle swarm algorithm to optimize the iForest parameters, use the fitness function to evaluate the key indicators of each particle, determine the accuracy of the iForest model classification prediction, and complete the outlier detection;
[0048] S3.2, clustering normal commodity operation data using K-Means clustering algorithm;
[0049] S3.3, use the Gap statistic algorithm to adjust and optimize to obtain the optimal number of clusters K.
[0050] The iForest parameters include:
[0051] The number of trees, the more trees there are, the more stable and accurate the model will be;
[0052] The number of subsamples. Different numbers of subsamples will affect the training results. The more elements in a subsample, the more overall information it covers.
[0053] The proportion of abnormal points is used to affect the threshold setting of the abnormal score and accurately identify the abnormalities.
[0054] The optimization of iForest parameters using the fusion particle swarm algorithm includes the following steps:
[0055] S3.1.1, find the optimal solution for a single individual;
[0056] S3.1.2, determine the global optimal solution;
[0057] S3.1.3, optimize and adjust iForest parameters according to the individual optimal solution and the global optimal solution.
[0058] The particle update speed calculation formula of the fitness function is:
[0059]
[0060] After calculating the updated velocity, the new position of the particle can be re-derived:
[0061]
[0062] in, Represents the current iteration number, Meaning: The particle No. The speed in the dimensional direction, The meaning is the current position of the particle. It means the global optimal position obtained by all particles. It means the local optimal position reached by the particle. Represents the inertia weight, which can adjust its optimization ability. and Expressed as an acceleration constant, it can adjust the step size of the optimization. and Indicates that two numbers between the interval [0,1] are randomly generated, which can improve the randomness of the optimization process;
[0063] and The value indicates that the acceleration constant will be set between 1 and 2. It represents individual learning, reflecting the particle's ability to learn and remember its own historical optimal position. When it is larger, it is conducive to fine search in local areas. It represents global learning, which reflects the degree of response of particles to the current optimal position in the entire population. When it is larger, particles are more likely to be attracted by the global optimal solution, which is helpful for global search.
[0064] and The update of particle velocity generated and used to calculate it in each iteration introduces a random search direction, which helps to escape the local optimal trap. In addition, each particle uses an independently generated random number when updating its velocity, which will cause differences between individuals and help maintain diversity within the population and prevent the particle group from being too concentrated in a certain area.
[0065] Clustering normal commodity business data using the K-Means clustering algorithm includes the following steps:
[0066] S3.2.1, select the initialization Samples are used as initial cluster centers ;
[0067] S3.2.2, for each sample in the dataset Calculate its distance to the cluster center and divide it into the class corresponding to the cluster center with the smallest distance;
[0068] S3.2.3, for each category , recalculate its cluster center ;
[0069] S3.2.4, repeat the above steps S3.2.2 and S3.2.3 until the termination condition is reached.
[0070] The termination conditions include that the iteration reaches the cluster center and no longer changes and sets the maximum number of iterations.
[0071] The calculation formula of the Gap statistic algorithm is:
[0072]
[0073] in, is the loss function, here refers to expectations.
[0074] The working principle of an abnormal behavior identification method based on kmeans and iForest decision-making in an embodiment of the present invention is: based on the collected commodity data and store data disclosed by the e-commerce platform, data governance and cleaning are performed, a kmeans-iForest recognition model is established to perform parameter adjustment optimization and test recognition, and the screening and recognition effects are evaluated and analyzed, so as to quickly and accurately identify abnormal business behaviors and stores with non-compliant business behaviors or violating the platform's e-commerce business regulations, and provide potential risk warnings for the platform and consumers.
[0075] The kmeans-iForest-based recognition model of the present application can be tested and evaluated to verify the feasibility and reliability of the model method in the abnormal operation identification process, and to propose a tuning solution to establish an abnormal behavior self-identification system with a high accuracy rate.
[0076] Furthermore, the technical problem to be solved by this application is to use the accumulated massive data on product sales and store information of online merchants to quickly identify which merchants have non-compliant business practices or violate the platform's e-commerce business regulations.
[0077] In the overall solution, the identification method includes the following steps: obtaining the commodity operation data of the e-commerce platform within a given period, wherein the commodity operation data includes commodity name, commodity sales volume, commodity sales amount, and the correspondence between commodities and stores, and storing them in a database; preprocessing the commodity operation data to ensure that the missing rate of data indicators is within a controllable range; establishing a kmeans-iForest recognition model, and combining the preprocessed commodity operation data to identify stores with abnormal operating behaviors.
[0078] Preferably, establishing a kmeans-iForest recognition model and combining the preprocessed commodity management data to identify stores with abnormal management behaviors includes the following steps: optimizing iForest parameters using a fusion particle swarm algorithm, evaluating key indicators of each particle's quality using a fitness function, determining the accuracy of the iForest model classification prediction, and completing outlier detection; clustering normal commodity management data using a K-Means clustering algorithm; and adjusting and optimizing using a Gap statistic algorithm to obtain the optimal number of clusters K.
[0079] iForest parameters mainly include the number of trees. The more trees there are, the higher the stability and accuracy of the model. The number of subsamples. Different numbers of subsamples will affect the training results. The more elements there are in the subsamples, the more overall information is covered. The proportion of outliers is used to affect the threshold setting of the anomaly score and accurately identify anomalies.
[0080] In general, the number of trees chosen is mainly affected by the following three factors: the amount of data, the available computing resources, and the accuracy to be achieved in the experiment.
[0081] For subsamples, each tree training requires a training subset. Different numbers of subsamples have a certain impact on the training results. When the number of elements in the training subset is relatively large, the overall information covered is higher, and the model training time is longer and the cost is higher. If there are fewer elements in the training subset, it will lead to a certain degree of lack of overall information, especially for some abnormal monitoring and detection. It is necessary to adjust the range between hundreds and thousands according to the actual situation, so as to find a relatively suitable size.
[0082] The fusion particle swarm algorithm is to find the optimal solution through collaboration and information sharing among individuals in the group, and then adjust it according to the optimal solution for each lesson and the global optimal solution; the specific process is: find the optimal solution for a single individual; determine the global optimal solution; optimize and adjust the iForest parameters according to the individual optimal solution and the global optimal solution.
[0083] The fusion particle swarm algorithm needs to determine the fitness function to evaluate the key indicators of the quality of each particle. The fitness function usually corresponds to the objective function of the optimization problem.
[0084] Specifically, the particle update speed calculation formula of the fitness function is:
[0085]
[0086] After calculating the updated velocity, the new position of the particle can be re-derived:
[0087]
[0088] in, Represents the current iteration number, Meaning: The particle No. The speed in the dimensional direction, The meaning is the current position of the particle. It means the global optimal position obtained by all particles. It means the local optimal position reached by the particle. Represents the inertia weight, which can adjust its optimization ability. and Expressed as an acceleration constant, it can adjust the step size of the optimization. and Indicates that two numbers between the interval [0,1] are randomly generated, which can improve the randomness of the optimization process;
[0089] and The value indicates that the acceleration constant will be set between 1 and 2. It represents individual learning, reflecting the particle's ability to learn and remember its own historical optimal position. When it is larger, it is conducive to fine search in local areas. It represents global learning, which reflects the degree of response of particles to the current optimal position in the entire population. When it is larger, particles are more likely to be attracted by the global optimal solution, which is helpful for global search.
[0090] and The update of particle velocity generated and used to calculate it in each iteration introduces a random search direction, which helps to escape the local optimal trap. In addition, each particle uses an independently generated random number when updating its velocity, which will cause differences between individuals and help maintain diversity within the population and prevent the particle group from being too concentrated in a certain area.
[0091] For the acceleration constant, an acceleration constant that is too large may cause the algorithm to converge to the local optimum too early and lack sufficient global exploration capability; on the contrary, an acceleration constant that is too small may lead to slow convergence and low search efficiency; therefore, this application sets the acceleration constant between 1 and 2, which can meet the actual application needs of a variety of different application scenarios.
[0092] Preferably, clustering normal commodity business data using the K-Means clustering algorithm includes the following steps: selecting an initialized Samples are used as initial cluster centers ; For each sample in the dataset Calculate its distance to the cluster center and divide it into the class corresponding to the cluster center with the smallest distance; for each class , recalculate its cluster center; repeat the above steps S3.2.2 and S3.2.3 to reach the termination condition.
[0093] In actual use, as shown in the instruction manual Figure 2 As shown in , the x-axis is the horizontal coordinate of the cluster center point, and the y-axis is the vertical coordinate of the cluster center point; when k=3, first randomly find three cluster center points, which are the three points with a “+” sign in the “first iteration”; then calculate the distances of all points to these three cluster centers, and mark the closest point with the same color, as shown in the “second iteration”; then calculate the center point of each color point and mark them as the new three cluster centers.
[0094] Repeat the above steps until the specified number of iterations is reached or the positions of the three cluster centers do not change; generally, the number of iterations will not exceed 8 times, with 6 times being the optimal choice.
[0095] The termination conditions include reaching the point where the cluster center does not change after iteration and setting the maximum number of iterations. The first termination condition indicates that the clustering algorithm has reached the optimal clustering. Usually, the amount of point data for this type of clustering algorithm is not large and can be used when the dimension is not high. The second termination condition can be used when the data dimension is high and the data volume is huge to avoid wasting a lot of computing resources and time.
[0096] Furthermore, this application selects the Gap statistic algorithm for adjustment and optimization, which is a statistical method for determining the appropriate number of clusters (K value) in the K-means clustering algorithm. This method aims to provide a more objective and automated K value selection standard compared to the limitations of traditional methods that rely on subjective judgment.
[0097] By comparing the clustering effect of the actual data set with the clustering effect of a random data set of the same size, we can evaluate whether the degree of clustering of the actual data under a given K value is significantly higher than the random noise level; if the clustering compactness of the actual data is significantly higher than that of the randomly generated data, then the corresponding K value is a reasonable candidate value; conversely, if the difference between the two is not large, it means that the clustering under this K value may only capture random fluctuations rather than the real structure.
[0098] The calculation formula of the Gap statistic algorithm is:
[0099]
[0100] in, is the loss function, here refers to expectations.
[0101] It should be noted that this application is for e-commerce platforms or consumers to alert the store of the risks of abnormal business practices when shopping in an online store based on its business practices, to avoid consumers from having a bad shopping experience caused by fraudulent business practices, and to provide risk warnings to the platform so that stores with abnormal business practices can be controlled as soon as possible.
[0102] On the other hand, the identification of abnormal behavior in online retail studied in this application is based on experimental analysis of the Kmeans-iForest model. The recognition model is established through actual network business data, and the relevant parameters are adjusted and optimized to achieve rapid identification of abnormal business behavior through business data.
[0103] In summary, a method for identifying abnormal behaviors based on kmeans and iForest decisions in an embodiment of the present invention can collect and obtain commodity data and store data publicly available on an e-commerce platform, perform data governance and cleaning, establish a kmeans-iForest recognition model for parameter adjustment optimization and test recognition, and evaluate and analyze the screening and recognition effects, thereby quickly and accurately identifying abnormal business behaviors and stores with non-compliant business behaviors or violating the platform's e-commerce business regulations, and providing potential risk warnings for the platform and consumers.
[0104] The above specific implementation manner cannot be used as a limitation on the protection scope of the present invention. For those skilled in the art, any substitution, improvement or change made to the implementation manner of the present invention falls within the protection scope of the present invention.
[0105] The matters not described in detail in the present invention are all known technologies to those skilled in the art.
Claims
1. A method for identifying abnormal behavior based on kmeans and iForest decision making, It is characterized in that The identification method comprises the following steps: S1, obtaining commodity operation data of the e-commerce platform within a given period, wherein the commodity operation data includes commodity name, commodity sales volume, commodity sales amount, and the correspondence between commodities and stores, and storing the data in a database; S2, pre-process the commodity operation data to ensure that the missing rate of data indicators is within a controllable range; S3, establish the kmeans-iForest recognition model and combine it with the preprocessed commodity operation data to identify stores with abnormal operation behaviors; Establishing the kmeans-iForest recognition model and combining it with the preprocessed commodity operation data to identify stores with abnormal operation behaviors includes the following steps: S3.1, use the fusion particle swarm algorithm to optimize the iForest parameters, use the fitness function to evaluate the key indicators of each particle, determine the accuracy of the iForest model classification prediction, and complete the outlier detection; S3.2, clustering normal commodity operation data using K-Means clustering algorithm; S3.3, use the Gap statistic algorithm to adjust and optimize to obtain the optimal number of clusters K; The particle update speed calculation formula of the fitness function is: ; After calculating the updated velocity, the new position of the particle can be re-derived: ; in, Represents the current iteration number, Meaning: The particle No. The speed in the dimensional direction, It means the current position of the particle. It means the global optimal position obtained by all particles. It means the local optimal position reached by the particle. Represents the inertia weight, which can adjust its optimization ability. and Expressed as an acceleration constant, it can adjust the step size of the optimization. and Indicates that two numbers between the interval [0,1] are randomly generated, which can improve the randomness of the optimization process; and The value indicates that the acceleration constant will be set between 1 and 2. It represents individual learning, reflecting the particle's ability to learn and remember its own historical optimal position. When it is larger, it is conducive to fine search in local areas. It represents global learning, which reflects the degree of response of particles to the current optimal position in the entire population. When it is larger, particles are more likely to be attracted by the global optimal solution, which is helpful for global search. and In each iteration, the update of particle speed is generated and used to calculate the update of particle speed. The introduction of random search direction helps to escape the local optimal trap. In addition, each particle uses an independently generated random number when updating the speed, which will cause differences between individuals and help maintain the diversity within the population and prevent the particle group from being too concentrated in a certain area. Clustering normal commodity business data using the K-Means clustering algorithm includes the following steps: S3.2.1, select the initialization Samples are used as initial cluster centers ; S3.2.2, for each sample in the dataset Calculate its distance to the cluster center and divide it into the class corresponding to the cluster center with the smallest distance; S3.2.3, for each category , recalculate its cluster center ; S3.2.4, repeat the above steps S3.2.2 and S3.2.3 until the termination condition is reached; The termination conditions include that the iteration reaches the cluster center and no longer changes and sets the maximum number of iterations.
2. According to the method for identifying abnormal behavior based on kmeans and iForest decision making according to claim 1, the iForest parameter include: The number of trees, the more trees there are, the more stable and accurate the model will be; The number of subsamples. Different numbers of subsamples will affect the training results. The more elements in a subsample, the more overall information it covers. The proportion of abnormal points is used to affect the threshold setting of the abnormal score and accurately identify the abnormalities.
3. According to the method for identifying abnormal behavior based on kmeans and iForest decision-making according to claim 1, iForest parameters are optimized using a fusion particle swarm algorithm The following steps are involved: S3.1.1, find the optimal solution for a single individual; S3.1.2, determine the global optimal solution; S3.1.3, optimize and adjust iForest parameters according to the individual optimal solution and the global optimal solution.
4. According to the method for identifying abnormal behavior based on kmeans and iForest decision making according to claim 1, the calculation formula of the Gap statistic algorithm is: ; in, is the loss function, here refers to expectations.
