Prediction method for potential food safety risk of retail baked food
Through comprehensive system analysis and machine learning technology, combined with coefficient of variation-entropy weight method and five-scale method, the random forest model improved by the cuckoo search algorithm is solved, and the accuracy of food safety risk prediction of retail baked food is provided scientific Prevention and control suggestions have improved the effectiveness of food safety management.
Patent Information
- Application Number
- CN202411403164.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-10
AI Technical Summary
The existing technology cannot effectively and accurately predict and prevent food safety risks of retail baked goods. Traditional methods are highly subjective and poorly objective. The existing data mining and machine learning methods ignore the complexity of food safety risks, resulting in accurate prediction results. Not very sexual.
Using comprehensive system analysis and machine learning technology, the random forest model improved by collecting safety data of retail baked goods, using the coefficient of variation-entropy weight method to allocate risk factors, combining the five-scale method to determine the risk level, and improving the Cuckoo search algorithm Conduct risk prediction and ultimately provide targeted food safety prevention and control suggestions.
It improves the comprehensiveness and accuracy of food safety risk prediction, provides scientific and effective decision-making basis for food safety management, effectively prevents food safety accidents, and ensures food safety quality.
Smart Images

Figure CN119294595A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of retail baked food safety risk prediction, and more specifically relates to a method for predicting potential food safety risks of retail baked food. Background Art
[0002] Food safety has always been a global concern. Especially for baked goods, due to its complex production process, a wide variety of raw materials, and the great impact of storage conditions on its quality, food safety issues are particularly prominent. In recent years, due to food safety issues, the continuous outbreak of food safety accidents has posed a threat to people's lives and safety, seriously damaged consumer confidence, and also brought many negative impacts to society.
[0003] In this context, how to correctly and effectively predict and prevent food safety risks that may exist in baked goods and prevent food safety accidents has become an urgent problem that needs to be solved in the current food science and food industry. However, there is no corresponding methodological theory to provide safety risk prediction for retail baked goods.
[0004] Traditional food safety risk assessment methods are generally conducted by experts through experience and qualitative analysis, which is highly subjective, poorly objective, and inaccurate. In the face of large-scale and complex food safety issues, this method cannot provide clear and accurate solutions.
[0005] The development of computer technology has provided new possibilities for food safety risk assessment. For example, some researchers have begun to try to use data mining, machine learning and other technologies to predict food safety risks. However, these existing methods often ignore the complexity of food safety risks, resulting in low accuracy of prediction results and failure to meet practical application needs. Summary of the invention
[0006] This paper adopts comprehensive system analysis and machine learning technology to propose a new method for predicting potential food safety risks of retail baked goods. This method can not only comprehensively and accurately assess potential food safety risks, but also provide a scientific and effective basis for subsequent food safety management decisions.
[0007] In order to achieve the above object, the present invention adopts the following technical solution: the prediction method comprises:
[0008] Collect retail bakery food safety data, including raw materials, production and storage information;
[0009] The coefficient of variation-entropy weight method is used to assign weights to the factors affecting the safety risk of baked food and obtain the comprehensive risk value;
[0010] Use the five-scale method to determine the current food safety risk level of retail bakery products;
[0011] Risk prediction using a random forest model improved by the cuckoo search algorithm;
[0012] Based on the early warning results, food safety prevention and control recommendations for retail baked goods are provided.
[0013] In one embodiment, the collection of retail bakery food safety data includes:
[0014] Aggregate product information of retail bakery products, including bread, cakes, donuts and related product details;
[0015] Collect raw material information for each product, including raw material name, quality, source, storage conditions, and supplier information;
[0016] Collect production information for each product, including production process, production equipment, production date, production personnel, and safety measures;
[0017] Collect storage information for each product, including temperature, humidity, light, air circulation, and how the goods are stacked.
[0018] In one solution, the specific process of weight allocation is as follows:
[0019] Marked with X according to the quality of collected raw materials, production process control and storage conditions ij (i=1,2,...,m;j=1,2,...,n), where m is the total number of samples and n is the total number of influencing factors;
[0020] Each influencing factor is normalized to eliminate the impact of the dimension and value of the data on the results;
[0021] Calculate the coefficient of variation of each evaluation factor. The coefficient of variation is used to evaluate the degree of dispersion of the data. The calculation formula is as follows:
[0022]
[0023] In this formula, C j represents the coefficient of variation of the jth evaluation factor, S j is the standard deviation of the j-th evaluation factor data, μ j is the average value of the jth evaluation factor data;
[0024] Calculate the entropy value of each evaluation factor. The entropy value is used to measure the complexity of random variables. The calculation formula is as follows:
[0025] E j =k*Σ(P ij *ln(Pij ))
[0026] Among them, E j is the entropy value of the jth evaluation factor, i is the i-th evaluation object, P ij is the proportion of the jth evaluation factor in the ith evaluation object, is a constant of the entropy index;
[0027] The coefficient of variation-entropy weight method is used to calculate the weight of each factor. The formula is as follows:
[0028]
[0029] W j represents the weight of the jth evaluation factor;
[0030] According to the weight and normalized value of each factor, the comprehensive risk value R of baked goods is calculated as follows:
[0031] R=Σ(W j *X ij '), (j=1,2,…n)
[0032] R represents the comprehensive food safety risk value of baked goods, X ij ' is the normalized score of each influencing factor.
[0033] In one embodiment, the five-scale method for determining the food safety risk level of retail baked goods is as follows:
[0034] According to the preset five risk levels, the food safety risk level is determined according to the risk value R. The specific steps are as follows:
[0035] Five risk levels are set: Level 1 safe, Level 2 basic safe, Level 3 mild risk, Level 4 medium risk, and Level 5 high risk;
[0036] Set the range of risk value R corresponding to each risk level. When R is less than 0.2, it is level 1; when R is between 0.2 and 0.4, it is level 2; when R is between 0.4 and 0.6, it is level 3; when R is between 0.6 and 0.8, it is level 4; when R is greater than 0.8, it is level 5;
[0037] Determine the corresponding risk level based on the size of R and the set range.
[0038] In one embodiment, the risk prediction process of the random forest model improved by the cuckoo search algorithm is as follows:
[0039] (1) Select the current food safety risk level of retail bakery products and collect food safety data;
[0040] (2) Determine the total number of bird nests n, the number of iterations t, and set the initial solution x0 as the initial parameter value of the RF method x0 = (n_estimators, max_depth);
[0041] (3) Generate a new solution through Levy flight and calculate the fitness function value;
[0042] (4) Determine whether to discard the old solution. If the fitness function value of the new solution is smaller than the old solution, replace it; otherwise, do not replace it.
[0043] (5) Determine the optimal solution x found in the current global best =(n_estimators,max_depth);
[0044] (6) The current optimal solution is passed into the random forest algorithm, and n samples are randomly selected according to certain rules to form each sub-training set to generate F decision trees. The classification results of each tree participate in voting to build the RF risk prediction model, and calculate the AUC value of the RF model at this time;
[0045] (7) Repeat (3)-(6) until the stopping condition is reached. The final solution is the global optimal solution.
[0046] (8) Analyze the prediction results. Use the trained risk prediction model on the original effective food safety risk data to predict and warn of potential risks. Based on the prediction results, explore the risk development trend and analyze the source of risk.
[0047] In one embodiment, the food safety prevention and control recommendations include:
[0048] Determine the type and level of measures to be taken based on the predicted risk level;
[0049] It is necessary to analyze the main factors affecting food safety in detail and then propose specific improvement measures for these factors;
[0050] Based on the previous warning results, formulate a food safety prevention and control plan, and clarify the prevention and control measures, implementation personnel, and time node information.
[0051] Beneficial effects of the present invention:
[0052] The present invention provides a systematic and scientific method for predicting potential food safety risks of retail baked goods. By comprehensively collecting food safety-related data of retail baked goods, combining the coefficient of variation-entropy weight method and the five-scale method to perform weight allocation and risk level determination, and then using the random forest model improved by the cuckoo search algorithm to predict food safety risks, and finally providing targeted food safety prevention and control recommendations based on the early warning results. This method not only improves the comprehensiveness and accuracy of food safety risk prediction, but also provides a scientific and effective basis for food safety prevention and control decision-making, which is of great significance for preventing food safety accidents and ensuring food safety quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is a flow chart of the method of the present invention;
[0054] Figure 2 The present invention is a flow chart of the improved random forest model prediction of the cuckoo search algorithm;
[0055] Figure 3 This is a framework diagram of the random forest model improved by the cuckoo search algorithm of the present invention. DETAILED DESCRIPTION
[0056] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Typical embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described in the present invention. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0057] Unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as those understood by those skilled in the art of the present invention. The terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0058] Embodiment 1:
[0059] like Figure 1 As shown, a method for predicting potential food safety risks of retail baked goods includes:
[0060] S1. Collect retail bakery food safety data, including raw materials, production and storage information.
[0061] Aggregate product information of various retail bakery goods merchants, including but not limited to bread, cakes, donuts, etc., as well as their related product details.
[0062] Collect raw material information for each product, including raw material name, quality, source (how to grow, collect or manufacture), storage conditions (temperature, humidity environment), supplier and other information.
[0063] Collect production information for each product, such as the production process (whether it is baked, fried, etc.), production equipment (oven, blender, etc.), production date, production personnel (whether they have received food safety training), safety measures, etc.
[0064] Collect storage information for each product, such as temperature, humidity, light, air circulation, how the goods are stacked (for example, whether a certain distance is maintained to prevent cross contamination), etc.
[0065] Organize and classify the various information collected, delete redundant information, and create a database, such as an SQL database or Excel spreadsheet.
[0066] The database is updated regularly to ensure that the data is up-to-date and accurate. If new products, supplies, ingredients or guidelines are introduced, they should also be added to the database.
[0067] S2. Apply the coefficient of variation-entropy weight method to assign weights to the factors affecting the safety risk of baked food and obtain the comprehensive risk value.
[0068] The specific process of weight allocation is as follows:
[0069] Marked with X according to the quality of collected raw materials, production process control and storage conditions ij (i=1,2,...,m;j=1,2,...,n), where m is the total number of samples and n is the total number of influencing factors;
[0070] Each influencing factor is normalized to eliminate the impact of the dimension and value of the data on the results;
[0071] Calculate the coefficient of variation of each evaluation factor. The coefficient of variation is used to evaluate the degree of dispersion of the data. The calculation formula is as follows:
[0072]
[0073] In this formula, C j represents the coefficient of variation of the jth evaluation factor, S j is the standard deviation of the j-th evaluation factor data, μ j is the average value of the jth evaluation factor data;
[0074] Calculate the entropy value of each evaluation factor. The entropy value is used to measure the complexity of random variables. The calculation formula is as follows:
[0075] E j =k*Σ(P ij *ln(P ij ))
[0076] Among them, Ej is the entropy value of the jth evaluation factor, i is the i-th evaluation object, P ij is the proportion of the jth evaluation factor in the ith evaluation object, is a constant of the entropy index;
[0077] The coefficient of variation-entropy weight method is used to calculate the weight of each factor. The formula is as follows:
[0078]
[0079] W j represents the weight of the jth evaluation factor;
[0080] According to the weight and normalized value of each factor, the comprehensive risk value R of baked goods is calculated as follows:
[0081] R=Σ(W j *X ij '), (j=1,2,…n)
[0082] R represents the comprehensive food safety risk value of baked goods, X ij ' is the normalized score of each influencing factor.
[0083] In this process, the weight allocation of various factors can reflect their importance to the overall food safety risk. At the same time, the result of the risk value R will serve as the basis for determining the food safety risk level of retail baked goods in the subsequent S3.
[0084] S3. Use the five-scale method to determine the current food safety risk level of retail baked goods.
[0085] The five-scale method is a risk level assessment method, which determines the food safety risk level according to the five preset risk levels and the size of the risk value R. The specific steps are as follows:
[0086] First, five risk levels are set, for example: Level 1 (safe), Level 2 (basic safety), Level 3 (mild risk), Level 4 (moderate risk), and Level 5 (high risk).
[0087] Secondly, set the range of risk values R corresponding to each risk level. For example, you can set R to be level 1 (safe) when it is less than 0.2; level 2 (basic safety) when R is between 0.2 and 0.4; level 3 (mild risk) when R is between 0.4 and 0.6; level 4 (moderate risk) when R is between 0.6 and 0.8; and level 5 (high risk) when R is greater than 0.8.
[0088] The calculated food safety risk value R is used to determine the corresponding risk level according to the value of R and the set range. For example, if R = 0.5, then the food safety risk level corresponding to the baked food is level 3 (mild risk).
[0089] In this process, the five-scale method can convert the continuous risk value R into a discrete risk level, which is easy to understand and operate. The determined risk level will serve as the target result of the model prediction in step S4 and the basis for formulating food safety prevention and control recommendations in step S5.
[0090] like Figure 2 and Figure 3 As described, S4, risk prediction is performed using a random forest model improved by the cuckoo search algorithm.
[0091] S401. Select the food safety risk level of retail bakery products at the current stage and the collected food safety data;
[0092] S402, determine the total number of bird nests n, the number of iterations t, and set the initial solution x0 as the initial parameter value x0 = (n_estimators, max_depth) of the RF method;
[0093] S403, generating a new solution through Levy flight and calculating the adaptation function value;
[0094] S404, determine whether to discard the old solution, if the fitness function value of the new solution is smaller than the old solution, replace it, otherwise do not replace it;
[0095] S405, determine the optimal solution x found in the current global best =(n_estimators,max_depth);
[0096] S406, passing the current optimal solution into the random forest algorithm, continuously randomly extracting n samples according to certain rules to form each sub-training set to generate F decision trees, the classification results of each tree participate in voting, constructing the RF risk prediction model, and calculating the AUC value of the RF model at this time;
[0097] S407, repeat S403-S406 until the stop condition is reached, and the final solution is the global optimal solution;
[0098] S408, analyzing the prediction results. The trained risk prediction model is applied to the original effective food safety risk data to predict and warn of potential risks. Based on the prediction results, the risk development trend is explored and the risk source is analyzed.
[0099] Both S3 and S4 assess food safety risks, but they focus on different aspects. S3 directly calculates the food safety risk level of baked goods based on the collected sample data. The results are relatively intuitive and easy to understand. S4, based on S3, uses the improved random forest model of the cuckoo search algorithm to predict future risks, thereby identifying potential problems in advance and taking timely precautions, which is a supplement and deepening of S3.
[0100] The result of S3, i.e. the food safety risk level of retail baked goods, serves as an important input to step S4. The result of S3 provides an intuitive food safety risk assessment and gives the current safety risk level of retail baked goods.
[0101] When performing step S4, the future risks are predicted by using the improved cuckoo search algorithm random forest model. The goal of the prediction is to predict the future food safety risk level as accurately as possible. Therefore, S3 and S4 are closely related. S3 provides important basic data for S4, while S4 is a prediction and further exploration of S3.
[0102] S5. Provide food safety prevention and control recommendations for retail baked goods based on the early warning results.
[0103] According to the risk level predicted by S4, determine the type and level of measures to be taken. For example, if the prediction result is level 1 (safe), then no special prevention and control measures are required; if the prediction result is level 2 (basic safety), regular inspection and maintenance are required; if the prediction result is level 3 (mild risk) or above, it is necessary to improve the influencing factors such as raw material procurement, production process or storage environment as soon as possible.
[0104] It is necessary to analyze the main factors that affect food safety in detail, and then propose specific improvement measures for these factors. For example, if the prediction results show that there are problems with the quality of raw materials, it can be recommended to review or change suppliers; if it is judged that there are problems with the production process, it can be recommended to improve the production process or strengthen staff training; if it is judged that there are problems with the storage environment, it can be recommended to improve storage conditions, such as temperature and humidity.
[0105] According to the previous warning results, formulate a food safety prevention and control plan, clarify the prevention and control measures, implementation personnel, time nodes and other information, so as to facilitate monitoring and implementation. Summarize and report these prevention and control suggestions to relevant managers or decision makers for reference.
[0106] According to the actual implementation and changes in food safety conditions, the prevention and control recommendations can be adjusted accordingly. For example, if the food safety situation improves after the implementation of prevention and control measures, the prevention and control level may be lowered accordingly; conversely, if the food safety situation does not improve or worsens, it may be necessary to strengthen prevention and control measures or increase the prevention and control level.
[0107] Embodiment 2:
[0108] When a chain bakery is conducting a retail bakery food safety risk prediction, it first collects its food safety related data, such as the raw materials, production and storage information of 10 bakery products such as bread, cakes, donuts, etc.:
[0109] Raw material information, such as the raw material name is wheat flour, the mass is 500g, the source is a local supplier, the storage conditions are cool and dry, and the supplier information is Company A. Production information, such as the production process is baking, the production equipment is an oven, the production date is August 1, 2022, the production personnel is Zhang San, and the safety measures are regular cleaning of equipment. Storage information, such as the temperature is 25℃, the humidity is 60%, the light is dark, the air circulation is good, and the goods are stacked in a single layer horizontally.
[0110] Then, the coefficient of variation-entropy weight method is applied to assign weights. For example, the quality of raw materials is marked as 0.9, the production process control is marked as 0.8, and the storage conditions are marked as 0.7. After calculation, the weight of raw material quality is 0.3, the weight of production process control is 0.4, and the weight of storage conditions is 0.3. According to the weight and normalized value of each factor, the comprehensive food safety risk value R of food is calculated to be 0.35.
[0111] The five-scale method is used to determine the R value and the food safety risk level of baked goods. In this case, the R value is 0.35, which belongs to level 2, that is, basically safe.
[0112] Then, the random forest model improved by the cuckoo search algorithm was used for risk prediction. In this process, food safety data with a food safety risk level of 2 was selected, the total number of bird nests was determined to be 3, the number of iterations was 50, the model was trained and predicted, and the prediction result showed that the food safety risk level may still be 2 in the future.
[0113] Finally, based on the early warning results, food safety prevention and control recommendations for retail baked goods were put forward. For example, since the food safety level is level 2, it is recommended to clean the equipment once a week and clean it every day, check the raw materials regularly, and strengthen food safety training for employees.
[0114] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0115] It should be understood that the detailed description of the technical solutions of the present invention by means of the preferred embodiments is illustrative rather than restrictive. A person skilled in the art may modify the technical solutions described in the embodiments, or replace some of the technical features by equivalents, based on reading the specification of the present invention; and these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for predicting potential food safety risks of retail baked goods, characterized by: The prediction method includes: Collect retail bakery food safety data, including raw materials, production and storage information; The coefficient of variation-entropy weight method is used to assign weights to the factors affecting the safety risk of baked food and obtain the comprehensive risk value; Use the five-scale method to determine the current food safety risk level of retail bakery products; Risk prediction using a random forest model improved by the cuckoo search algorithm; Based on the early warning results, food safety prevention and control recommendations for retail baked goods are provided.
2. The method for predicting potential food safety risks of retail baked food according to claim 1, characterized in that: The collection of retail bakery food safety data includes: Aggregate product information of retail bakery products, including bread, cakes, donuts and related product details; Collect raw material information for each product, including raw material name, quality, source, storage conditions, and supplier information; Collect production information for each product, including production process, production equipment, production date, production personnel, and safety measures; Collect storage information for each product, including temperature, humidity, light, air circulation, and how the goods are stacked.
3. The method for predicting potential food safety risks of retail baked food according to claim 1, characterized in that: The specific process of weight allocation is as follows: Marked with X according to the quality of collected raw materials, production process control and storage conditions ij (i=1,2,...,m;j=1,2,...,n), where m is the total number of samples and n is the total number of influencing factors; Each influencing factor is normalized to eliminate the impact of the dimension and value of the data on the results; Calculate the coefficient of variation of each evaluation factor. The coefficient of variation is used to evaluate the degree of dispersion of the data. The calculation formula is as follows: In this formula, C j represents the coefficient of variation of the jth evaluation factor, S j is the standard deviation of the j-th evaluation factor data, μ j is the average value of the jth evaluation factor data; Calculate the entropy value of each evaluation factor. The entropy value is used to measure the complexity of random variables. The calculation formula is as follows: E j nk*Σ(P ij *ln(P ij )) Among them, E j is the entropy value of the jth evaluation factor, i is the i-th evaluation object, P ij is the proportion of the jth evaluation factor in the ith evaluation object, is a constant of the entropy index; The coefficient of variation-entropy weight method is used to calculate the weight of each factor. The formula is as follows: W j represents the weight of the jth evaluation factor; According to the weight and normalized value of each factor, the comprehensive risk value R of baked goods is calculated as follows: R=Σ(W j *X ij '),(j=1,2,...n) R represents the comprehensive food safety risk value of baked goods, X ij ' is the normalized score of each influencing factor.
4. The method for predicting potential food safety risks of retail baked food according to claim 1, characterized in that: The five-scale method for determining the food safety risk level of retail baked goods is as follows: According to the preset five risk levels, the food safety risk level is determined according to the risk value R. The specific steps are as follows: Five risk levels are set: Level 1 safe, Level 2 basic safe, Level 3 mild risk, Level 4 medium risk, and Level 5 high risk; Set the range of risk value R corresponding to each risk level. When R is less than 0.2, it is level 1; when R is between 0.2 and 0.4, it is level 2; when R is between 0.4 and 0.6, it is level 3; when R is between 0.6 and 0.8, it is level 4; when R is greater than 0.8, it is level 5; Determine the corresponding risk level based on the size of R and the set range.
5. The method for predicting potential food safety risks of retail baked food according to claim 1, characterized in that: The risk prediction process of the random forest model improved by the cuckoo search algorithm is as follows: (1) Select the current food safety risk level of retail bakery products and collect food safety data; (2) Determine the total number of bird nests n, the number of iterations t, and set the initial solution x0 as the initial parameter value of the RF method x0 = (n_estimators, max_depth); (3) Generate a new solution through Levy flight and calculate the fitness function value; (4) Determine whether to discard the old solution. If the fitness function value of the new solution is smaller than the old solution, replace it; otherwise, do not replace it. (5) Determine the optimal solution x found in the current global best =(n_estimators,max_depth); (6) The current optimal solution is passed into the random forest algorithm, and n samples are randomly selected according to certain rules to form each sub-training set to generate F decision trees. The classification results of each tree participate in voting to build the RF risk prediction model, and calculate the AUC value of the RF model at this time; (7) Repeat (3)-(6) until the stopping condition is reached. The final solution is the global optimal solution. (8) Analyze the prediction results, apply the trained risk prediction model to the original effective food safety risk data, predict and warn of its potential risks, and explore its risk development trend based on the prediction results. Analyze the sources of risks.
6. The method for predicting potential food safety risks of retail baked food according to claim 1, characterized in that: The food safety prevention and control recommendations include: Determine the type and level of measures to be taken based on the predicted risk level; It is necessary to analyze the main factors affecting food safety in detail and then propose specific improvement measures for these factors; Based on the previous warning results, formulate a food safety prevention and control plan, and clarify the prevention and control measures, implementation personnel, and time node information.