A method, system and storage medium for detecting waste oil

Through the combination of Bayesian estimation, Monte Carlo filtering and BP neural network, the conductivity data in gutter oil detection is processed and analyzed, and the noise interference problem is solved, which significantly improves the accuracy of the detection results.

CN118817782BActive Publication Date: 2025-02-25QUANZHOU NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411295380.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-02-25
Estimated Expiration
2044-09-18

AI Technical Summary

Technical Problem

Existing gutter oil detection instruments are susceptible to noise interference when collecting data, which affects the accuracy of the detection results.

Method used

Bayesian estimation and Monte Carlo filtering technology are used to process conductivity data to reduce noise, and feature extraction and analysis of the processed data through BP neural network to improve the accuracy of the detection results.

Benefits of technology

It effectively reduces the noise in the conductivity data, improves the accuracy and reliability of the data, and ultimately improves the accuracy of the gutter oil detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118817782B_ABST
    Figure CN118817782B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of waste cooking oil detection, and in particular to a waste cooking oil detection method, system and storage medium, comprising the following steps performed in sequence: S1: obtaining the original conductivity #imgabs0# of the sample to be tested; S2: using Bayesian estimation to obtain the first conductivity data E 1 , S3: Monte Carlo filtering of the first conductivity data E 1 Processing to obtain the second conductivity E 2 , S4: Use BP neural network to analyze the second conductivity E 2 Train to get the third conductivity E 3 ; Effectively improved the accuracy of waste cooking oil detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of waste cooking oil detection, and in particular to a waste cooking oil detection method, system and storage medium. Background Art

[0002] Gutter oil refers to waste cooking oil produced by the catering industry that is illegally recycled and reused, or directly dumped into sewers, rivers and other surface water bodies, causing environmental pollution and public health safety hazards. The existence of gutter oil has seriously affected the urban environment and the health of residents, so rapid detection and monitoring of gutter oil has become an urgent need.

[0003] Qualified vegetable oil generally has low conductivity and is not a conductive material. However, after washing and cooking, metal ions are often introduced or by-products such as aldehydes and ketones are produced, which eventually increase its conductivity. Based on the abnormal conductivity value, it can be preliminarily determined whether it is gutter oil.

[0004] Since the conductivity method is easy to operate and has a fast analysis speed, there are many conductivity method detection instruments on the market for identifying edible oil adulteration. However, the existing detection instruments are easily interfered by various forms of noise when collecting data, which affects the accuracy of the test results. Summary of the invention

[0005] The object of the present invention is to provide a method, system and storage medium for detecting waste oil, which can improve the accuracy of waste oil detection results.

[0006] In order to achieve the above object, the present invention adopts such technical solution:

[0007] 1. A method for detecting waste cooking oil, characterized in that it comprises the following steps performed in sequence:

[0008] S1: Get the original conductivity of the sample to be tested ;

[0009] S2: Obtaining the first conductivity data using Bayesian estimation E 1 ;

[0010] S3: Monte Carlo filtering of the first conductivity data E 1 Process and output the second conductivity data E of the current state 2 ;

[0011] S4: Using BP neural network to analyze the second conductivity data E 2 After training, the conductivity E is finally obtained. 3 , the specific training steps are as follows:

[0012] S4-1: The structure of BP neural network includes input layer, output layer and multiple hidden layers. Each layer has several nodes. The connection status of nodes between layers is reflected by weights. The number of nodes in the input layer is equal to the dimension of input, and the number of nodes in the output layer is equal to the dimension of output. In BP neural network, each node contains a perceptron, that is, a separate neuron, which contains input items, weights, biases, activation functions and outputs. In the forward propagation process, the input data is calculated by the perceptron node and then processed by the activation function to obtain the output result; in the reverse propagation process, the result is compared with the expected result, and the weights of each node on the network are adjusted continuously through multiple iterations.

[0013] The calculation formula of each layer of the BP neural network is expressed by the following formula (3-1):

[0014] y=T(WE 2 +b)(3-1);

[0015] Among them, b represents temperature, W represents conductivity probability, and T represents activation function;

[0016] S4-2: The training of BP neural network adopts the back propagation algorithm. The back propagation algorithm calculates the state and activation value of each layer, advances the calculation error from the last layer, and updates the parameters to minimize the error function between the predicted output and the actual output of the network. This process is iterated continuously until the preset stopping criteria are met, where the error function is the mean square error function as shown in the following formula (3-3):

[0017] (3-3);

[0018] in, is the connection weight, i.e., the conductivity probability, is the bias, i.e., temperature, is the number of training samples, is the number of outputs, For the Sample No. The predicted value of the output, is the corresponding true value, that is, the final conductivity E 3 .

[0019] Preferably, the specific operation steps of step S2 are as follows:

[0020] S2-1: The dynamic time-varying system model used in Bayesian estimation is expressed by the state equation and the observation equation. The following formula (1-1) is the state equation, and formula (1-2) is the observation equation:

[0021] (1-1);

[0022] (1-2);

[0023] Among them, the function Represents the state transition function, describing the system from Time transfer to The process of time, express The system state at time The conductivity at the time, express The process noise at the moment, represents a certain observation function, is the original conductivity, that is The system status at the moment, is the part of the true transfer function that is not modeled, express The observed value at time;

[0024] If the probability density is initially Then, using the system model information, the Chapman-Kolmogorov equation can be obtained: k The prior probability density of the state at a certain moment is shown in the following formula (1-3):

[0025] (1-3);

[0026] in, Indicates temperature t Under the observation sequence e The probability density of is the original conductivity, Indicates time, express The conductivity at the moment;

[0027] When a new measurement is obtained After that, the prior probability density is corrected by the Bayesian formula to obtain the posterior probability density as shown in the following formula (1-4):

[0028] (1-4);

[0029] in, is the normalization constant, express The observed value at time, i.e., temperature, , which means from time 1 to The observed value at time;

[0030] S2-2: Sequential Monte Carlo filtering to achieve Bayesian estimation, that is, to achieve Bayesian estimation through non-parametric Monte Carlo simulation, let To find the posterior probability density A random observation of is a support point set, and its corresponding weight is , Indicates 0 to k The state set at the moment, normalized weight ,then k The posterior probability density at time can be expressed as the following formula (1-5):

[0031] (1-5);

[0032] in, Indicates temperature t Under the observation sequence e The probability density of k Indicates k time, e represents the conductivity, δ() is the Dirac function,

[0033] Monte Carlo simulation based on random sampling operation can transform the integral operation into the summation operation of finite sample points, that is, the state probability density distribution can be expressed by the empirical probability distribution of the following formula (1-6):

[0034] (1-6);

[0035] in, From time 0 to All conductivity at time, N represents the total number of samples;

[0036] S2-3: The core of Monte Carlo simulation is to transform the integral in formula (1-3) into the probability transfer accumulation of finite sample points, but in reality It is a multivariate, non-standard probability distribution, and requires the use of the Sequence Importance Sampling (SIS) algorithm to complete the SMC filtering. The importance function is the probability distribution and The same, known and easy to sample distribution function,

[0037] The importance function Written in the form of continuous product of the following formula (1-7):

[0038] (1-7);

[0039] in, Representation variables The probability distribution of It means The conductivity at the time, From time 0 to The state sequence at each moment, From time 1 to time The observed value of

[0040] Assuming that the state conforms to the Markov process, under a given state, the observations are conditionally independent, then the weight recursive formula is as shown in the following formula (1-8):

[0041] ;

[0042] in, express The weight of the moment, express The weight of the moment,

[0043] According to the probability density get N Sample points , then the probability density function can be expressed as the following formula (1-9):

[0044] (1-9);

[0045] in, Indicates Samples in The weight at the moment reflects the contribution of the sample to the state estimation;

[0046] The updated probability density function is as follows (1-10):

[0047] (1-10);

[0048] in As shown in the following formula (1-11):

[0049] (1-11);

[0050] Sample points can be k -1 sample at time Obtained through the equation of state;

[0051] S2-4: Sequence importance sampling algorithm starts with Randomly select a sample from the , and then calculate the corresponding point by point and , then use formula (1-5) to calculate the importance weight coefficient of the corresponding sample, and then normalize the weight, that is, , and finally use formula (1-5) to Estimation to obtain the first conductivity data E 1 .

[0052] Preferably, the specific processing steps of step S3 are as follows:

[0053] S3-1: Based on the known prior probability density distribution, that is, the conductivity probability distribution of the state estimate at time t-1, a set of conductivity samples of waste oil is generated, each conductivity sample represents a possible state in the state space, and an initial weight is preset for each conductivity sample;

[0054] S3-2: According to the state transition model, predict each sample and generate the sample state at the next moment. The specific operation steps of the state transition model are as follows:

[0055] The first conductivity data E 1 Converted into standard score, the standard score formula is as shown in the following formula (2-1):

[0056] (2-1);

[0057] In the formula, z is the standard score, is the average, is the standard deviation,

[0058] S3-3: Calculate the average value of the standard score difference of each group of state transitions in the conductivity sample, and construct the state transition standard score average function , the conductivity standard score of the predicted state is estimated by the average value , the average value function of the standard deviation of state transition can be used to establish the conductivity calculation formula z' for the predicted state:

[0059] ;

[0060] Where: The conductivity is determined by the state i Transfer to status j When , the average of the standard score differences is is the standard score of conductivity of the predicted state, Initial state i The standard score of Transfer status j The standard score of For status i Transfer to status j The frequency of occurrence, △ zIndicates the standard deviation of state transition; it indicates the transition from state i To status j Changes in standard scores;

[0061] S3-4: when new conductivity data is obtained, the weight of the sample is updated using the new conductivity data;

[0062] S3-5: If the variance of the sample weight is greater than the preset value, resampling is performed. The purpose of resampling is to discard samples with smaller weights and copy samples with larger weights to maintain the diversity of the sample set while ensuring that high-weight areas are adequately represented. Otherwise, the next step is executed.

[0063] S3-6: Based on the samples and their weights, the posterior distribution of the current state can be estimated to obtain the second conductivity data E 2 ;

[0064] S3-7: Repeat steps S3-2 to S3-6, and use the new conductivity data to update the sample set in each iteration, and output the second conductivity data E of the current state 2 .

[0065] Preferably, in step S3-4, the weight of the sample is updated by calculating the likelihood function value of each sample, that is, the matching degree between the conductivity data and the sample state, and then the weight is normalized so that the sum of the weights of all samples is 1.

[0066] Preferably, in step S3-5, the preset value of the variance of the sample weight is 0.05.

[0067] Preferably, in step S3-6, the posterior distribution of the current state is estimated by calculating the average value or mode of the weighted sample states.

[0068] Preferably, in step S4-1, the activation function represented by T is a Sigmoid function, and the Sigmoid function is shown by the following formula (3-2):

[0069] (3-2).

[0070] A waste cooking oil detection system comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, any of the above methods is implemented.

[0071] A storage medium stores a computer program, which, when executed by a processor, implements any of the methods described above.

[0072] By adopting the above-mentioned design scheme, the beneficial effects of the present invention are as follows: after the present invention adopts Monte Carlo filtering, the noise in the conductivity data is reduced, the accuracy and reliability of the conductivity data are improved, and finally a local optimal conductivity specific value is obtained through feature extraction and analysis of the neural network, thereby improving the accuracy of the waste oil detection results. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] Attached Figure 1 is the original signal waveform of the present invention;

[0074] Attached Figure 2 are the original and noise signal waveforms of the present invention;

[0075] Attached Figure 3 is the filtered signal waveform of the present invention;

[0076] Attached Figure 4 A schematic diagram of the structure of a multi-layer BP neural network model of the present invention;

[0077] Attached Figure 5 This is the timing flow chart of the BP neural network operation of the present invention. DETAILED DESCRIPTION

[0078] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only partial embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0079] A method for detecting waste cooking oil comprises the following steps performed in sequence:

[0080] S1: Get the original conductivity of the sample to be tested ;

[0081] S2: Obtaining the first conductivity data using Bayesian estimation E 1 , the specific steps are as follows:

[0082] S2-1: Figure 1-Figure 3 As shown, the dynamic time-varying system model used in Bayesian estimation is expressed by state equations and observation equations. The following formula (1-1) is the state equation, and formula (1-2) is the observation equation:

[0083] (1-1);

[0084] (1-2);

[0085] function Represents the state transition function, describing the system from Time transfer to The process of time, express The system state at time The conductivity at the time, express The process noise at the moment, represents a certain observation function, is the original conductivity, that is The system status at the moment, is the part of the true transfer function that is not modeled, express The observed value at time;

[0086] If the probability density is initially Then, using the system model information, the prior probability density of the state at time k can be obtained through the Chapman-Kolmogorov equation as shown in the following formula (1-3):

[0087] (1-3);

[0088] in, Indicates temperature t Under the observation sequence e The probability density of is the original conductivity, Indicates time, express The conductivity at the moment;

[0089] When a new measurement is obtained After that, the prior probability density is corrected by the Bayesian formula to obtain the posterior probability density as shown in the following formula (1-4):

[0090] (1-4);

[0091] in is a normalization constant that depends on the likelihood function and the statistical characteristics of the measurement noise, express The observed value at time, i.e., temperature, , which means from time 1 to The observed value at time;

[0092] When using recursive Bayes to estimate the posterior probability density of the state, an exact analytical solution can only be obtained in certain special cases (such as when the system noise is Gaussian distributed). In most cases, various sub-optimal estimates are required.

[0093] S2-2: Sequential Monte Carlo filtering implements Bayesian estimation through non-parametric Monte Carlo simulation, describing the probability density with samples rather than functions. Its basic idea is to use the weighted sum of a series of random samples to represent the required posterior probability density and obtain the estimated value of the state. When the number of sample points increases to infinity, the Monte Carlo simulation characteristics are equivalent to the posterior probability density function representation, so that the filtering accuracy approaches the optimal estimate. Its mathematical understanding: Let To find the posterior probability density A random observation of is a support point set, and its corresponding weight is . Indicates 0 to k The state set at the moment, normalized weight .then k The posterior probability density at time can be expressed as the following formula (1-5):

[0094] (1-5);

[0095] in, Indicates temperature t Under the observation sequence e The probability density of k Indicates k time, e represents conductivity, δ() is the Dirac function, also known as the unit pulse function or unit impulse function. Its characteristic is that it is equal to zero at all points except zero, and its integral in the entire domain is equal to 1. It is used to represent the sample With the conductivity series to be estimated Are they exactly the same? If they are exactly the same, the function value is infinite (but in mathematics this situation is usually handled by integration); if they are not the same, the function value is zero;

[0096] Monte Carlo simulation based on random sampling operation can transform the integral operation into the summation operation of finite sample points, that is, the state probability density distribution can be expressed by the empirical probability distribution of the following formula (1-6):

[0097] (1-6);

[0098] in Indicates temperature t Under the observation sequence e The probability density of kIndicates k The state of the moment, e represents the conductivity, From time 0 to All conductivity at time, N represents the total number of samples;

[0099] S2-3: The core of Monte Carlo simulation is to transform the integral in formula (1-3) into the probability transfer accumulation of finite sample points, but in reality It may be multivariate, non-standard probability distribution, and usually requires the use of sampling algorithms. Importance function is the probability distribution and The distribution function is the same, known and easy to sample from. In practice, the sequence importance sampling (SIS) algorithm that can realize recursive estimation is often used to complete SMC filtering. k All observation data before time.

[0100] The importance function Written in the form of continuous product of the following formula (1-7):

[0101] (1-7);

[0102] in, Representation variables The probability distribution of It means The conductivity at the time, From time 0 to The state sequence at each moment, From time 1 to time The observed value of

[0103] Assuming that the state conforms to the Markov process, under a given state, the observations are conditionally independent, then the weight recursive formula is as shown in the following formula (1-8):

[0104] ;

[0105] in, express The weight of the moment, express The weight of the moment,

[0106] According to the probability density get N Sample points , then the probability density function can be expressed as the following formula (1-9):

[0107] (1-9);

[0108] in, Indicates Samples in The weight at the moment reflects the contribution of the sample to the state estimation;

[0109] The updated probability density function is as follows (1-10):

[0110] (1-10);

[0111] in As shown in the following formula (1-11):

[0112] (1-11);

[0113] Sample points can be k -1 sample at time Obtained through the equation of state.

[0114] S2-4: Sequence importance sampling algorithm starts with Randomly select a sample from the , and then calculate the corresponding point by point and , then use formula (1-5) to calculate the importance weight coefficient of the corresponding sample, and then normalize the weight, that is, , and finally use formula (1-5) to Estimation to obtain the first conductivity data E 1 .

[0115] S3: Monte Carlo filtering of the first conductivity data E 1 The specific processing steps are as follows:

[0116] S3-1: Based on the known prior probability density distribution, that is, the conductivity probability distribution of the state estimate at time t-1, a set of conductivity samples of waste oil is generated, each conductivity sample represents a possible state in the state space, and an initial weight is preset for each conductivity sample;

[0117] S3-2: According to the state transition model, predict each sample and generate the sample state at the next moment. The specific operation steps of the state transition model are as follows:

[0118] The first conductivity data E 1 Converting it into a standard score can intuitively reflect the degree to which the sample is above or below the average level. The standard score formula is shown in the following formula (2-1):

[0119] (2-1);

[0120] In the formula, z is the standard score, is the average, is the standard deviation.

[0121] S3-3: Calculate the average value of the standard score difference of each group of state transitions in the conductivity sample, and construct the state transition standard score average function , the conductivity standard score of the predicted state is estimated by the average value , the average value function of the standard difference of state transition. The conductivity calculation formula z' of the predicted state can be established:

[0122] ;

[0123] Where: The conductivity is determined by the state i Transfer to status j When , the average of the standard score differences is is the standard score of conductivity of the predicted state, Initial state i The standard score of Transfer status j The standard score of For status i Transfer to status j The frequency of occurrence, △ z Indicates the standard deviation of state transition; it indicates the transition from state i To status j Changes in standard scores;

[0124] The average value of state transition reflects the degree of conductivity change between different states in the sample group, and is an explanation for the change in standard score when the state transitions in the sample group. Under the condition that the previous state is known, the standard score of the next state can be inferred based on this, which conforms to the principle of statistical inference.

[0125] S3-4: When new conductivity data is obtained, the new conductivity data is used to update the weight of the sample; in this embodiment, the weight of the sample is updated by calculating the likelihood function value of each sample, that is, the degree of matching between the conductivity data and the sample state, and then the weight is normalized so that the sum of the weights of all samples is 1.

[0126] S3-5: If the distribution of sample weights becomes very uneven, that is, the variance of sample weights is greater than 0.05, resampling is performed. The purpose of resampling is to discard samples with smaller weights and copy samples with larger weights to maintain the diversity of the sample set while ensuring that high-weight areas are adequately represented. If there is no unevenness in sample weights, this step is skipped directly.

[0127] S3-6: Based on the samples and their weights, the posterior distribution of the current state can be estimated to obtain the second conductivity data E 2 In this embodiment, the posterior distribution of the current state is estimated by calculating the average or mode of the weighted sample states.

[0128] S3-7: Repeat steps S3-2 to S3-6, use new conductivity data to update the sample set in each iteration, and output the second conductivity data E2 of the current state.

[0129] S4: Figure 4-5 As shown, the BP (back propagation) neural network is used to analyze the second conductivity data E 2 Conduct training. The specific training steps are as follows:

[0130] S4-1: The structure of BP neural network includes input layer, output layer and multiple hidden layers. Each layer has several nodes. The connection status of nodes between layers is reflected by weights. The number of nodes in the input layer is equal to the dimension of input, the number of nodes in the output layer is equal to the dimension of output, and the number of nodes in the hidden layer can be set according to actual conditions. In BP neural network, each node contains a perceptron, that is, a separate neuron, which contains input items, weights, biases, activation functions and outputs. In the forward propagation process, the input data is calculated by the perceptron node and the output result is obtained through the activation function. In the reverse propagation process, the result is compared with the expected result, and the weights of each node on the network are continuously adjusted through multiple iterations.

[0131] The calculation formula of each layer of the BP neural network is expressed by the following formula (3-1):

[0132] y=T(WE 2 +b)(3-1);

[0133] Among them, b represents temperature, W represents conductivity probability, and T represents activation function.

[0134] In this embodiment, the activation function represented by T is the Sigmoid function, which is shown by the following formula (3-2):

[0135] (3-2);

[0136] S4-2: The training of BP neural network adopts the back propagation algorithm. Back propagation is an optimization algorithm that enables the neural network to learn the mapping relationship between input and output by continuously adjusting the connection weights between each neuron in the network. Specifically, the back propagation algorithm calculates the state and activation value of each layer, advances the calculation error from the last layer forward, and updates the parameters to minimize the error function between the predicted output and the actual output of the network. This process will be iterated continuously until the preset stopping criteria are met, such as the difference between the errors of two adjacent iterations is very small, where the error function is the mean square error function as shown in the following formula (3-3):

[0137] (3-3);

[0138] in, is the number of training samples, is the number of outputs, For the Sample No. The predicted value of the output, is the corresponding true value, that is, the final conductivity E 3 .

[0139] In general, each iteration step reduces the error by a small amount, and finally a local optimal weight and threshold are obtained.

[0140] In this embodiment, when designing the accelerator of the BP neural network, the resource consumption and power consumption must be carefully considered. Since completing all operations at one time may cause a large amount of hardware resource consumption, we need to find a balance between parallelization and pipeline design. To this end, we optimized the operation order of the traditional BP neural network and implemented a serial-parallel-in-one design strategy. This design not only optimizes the computing efficiency, but also significantly reduces the use of hardware resources.

[0141] Specifically, our BP neural network accelerator uses only 6 hardware multipliers, which greatly improves the utilization of hardware resources. To further improve efficiency, we implement a multiplier reuse strategy in the parameter self-calibration module to fully utilize on-chip resources.

[0142] like Figure 5As shown in the figure, our architecture is based on 6 multipliers to build an efficient general arithmetic logic unit. In addition, we also use registers to cache input feature data, including F0 to F3. In the first clock cycle of the first hidden layer, we multiply all neurons on F0 and cache the results. This design not only improves the calculation speed, but also reduces power consumption, which is very suitable for the application of low-power portable devices.

[0143] In the following three clock cycles, we completed the multiplication operations in neurons F1 to F3 in turn. The fifth clock cycle is dedicated to completing the accumulation and activation operations of neurons. In this cycle, we used the ReLU activation function and efficiently implemented related operations through combinational logic selectors.

[0144] When processing the second hidden layer, since the fifth clock cycle is only used for accumulation and activation operations, we can simultaneously perform multiplication operations on the first neuron of the second layer. This parallel processing method not only improves computational efficiency, but also helps to reduce the overall computing time.

[0145] In the 6th clock cycle, we completed the accumulation and activation operation of the first neuron, and then completed the multiplication operation of the second neuron. And so on, by the 10th clock cycle, we have completed the multiplication operation of the 6th neuron.

[0146] In the 11th clock cycle, we completed the accumulation and activation operations of the second hidden layer and the multiplication operation of the output layer. After these 11 clock cycles of efficient operation. This carefully designed operation process ensures efficient use of resources and fast completion of calculations, which is very suitable for application scenarios of low-power portable devices.

[0147] The present invention also provides a system for implementing the above method.

[0148] A waste cooking oil detection system comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, any of the above methods is implemented.

[0149] The present invention also provides a storage medium storing data capable of implementing the above method.

[0150] A storage medium stores a computer program, which, when executed by a processor, implements any of the methods described above.

[0151] In summary, the present invention reduces the noise in the conductivity data and improves the accuracy and reliability of the conductivity data after using Monte Carlo filtering. Finally, a local optimal conductivity value is obtained through feature extraction and analysis of a neural network.

[0152] In summary, the present invention reduces the noise in the conductivity data and improves the accuracy and reliability of the conductivity data after using Monte Carlo filtering. Finally, a local optimal conductivity value is obtained through feature extraction and analysis of the neural network, thereby improving the accuracy of the waste oil detection results.

[0153] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for detecting waste cooking oil, characterized in that: The steps include the following steps: S1: Get the original conductivity of the sample to be tested ; S2: Obtaining the first conductivity data using Bayesian estimation E 1; The specific operation steps of step S2 are as follows: S2-1: The dynamic time-varying system model used in Bayesian estimation is expressed by the state equation and the observation equation. The following formula (1-1) is the state equation, and formula (1-2) is the observation equation: (1-1); (1-2); Among them, the function Represents the state transition function, describing the system from Transfer to the moment The process of time, express The system state at time The conductivity at the time, express The process noise at the moment, represents a certain observation function, is the original conductivity, that is The system status at the moment, is the part of the true transfer function that is not modeled, express The observed value at the time, i.e., temperature; If the probability density is initially Then, using the system model information, the Chapman-Kolmogorov equation can be obtained: k The prior probability density of the state at a certain moment is shown in the following formula (1-3): (1-3); in, Indicates temperature t The first moment in the observation sequence arrives time e The probability density of is the original conductivity, Indicates time, express The conductivity at the time, e represents electrical conductivity; When new observations are obtained After that, the prior probability density is corrected by the Bayesian formula to obtain the posterior probability density as shown in the following formula (1-4): (1-4); in, is the normalization constant, express The observed value at time, i.e., temperature, From time 1 to The observed value at time; S2-2: Sequential Monte Carlo filtering to achieve Bayesian estimation, that is, to achieve Bayesian estimation through non-parametric Monte Carlo simulation, let To find the posterior probability density A random observation of is a support point set, and its corresponding weight is , Indicates 0 to k The state set at the moment, normalized weight ,then k The posterior probability density at time can be expressed as the following formula (1-5): (1-5); in, Indicates the time from 0 to Conductivity at time At the first moment The probability density at time, Indicates time, e represents the conductivity, δ() is the Dirac function, Monte Carlo simulation based on random sampling operation can transform the integral operation into the summation operation of finite sample points, that is, the state probability density distribution can be expressed by the empirical probability distribution of the following formula (1-6): (1-6); in, From time 0 to All conductivity at time, N represents the total number of samples; S2-3: The core of Monte Carlo simulation is to convert the integral in formula (1-3) into the probability transfer accumulation of finite sample points. It is a multivariate, non-standard probability distribution, and requires the use of the sequence importance sampling SIS algorithm to complete the Monte Carlo filtering. The importance function is the probability distribution and The same, known and easy to sample distribution function, The importance function Written in the form of continuous product of the following formula (1-7): (1-7); in, Representation variables The probability distribution of It means The conductivity at the time, From time 0 to The state sequence at each moment, From time 1 to time Observed value of Assuming that the state conforms to the Markov process, under a given state, the observations are conditionally independent, then the weight recursive formula is as shown in the following formula (1-8): (1-8); in, express The weight of the moment, express The weight of the moment, According to the probability density get N Sample points , then the probability density function can be expressed as the following formula (1-9): (1-9); in, Indicates Samples in The weight at the moment reflects the contribution of the sample to the state estimation; The updated probability density function is as follows (1-10): (1-10); in As shown in the following formula (1-11): (1-11); Sample points can be Sample of time Obtained through the equation of state; S2-4: Sequence importance sampling algorithm starts with Randomly select a sample from the , and then calculate the corresponding point by point and , then use formula (1-5) to calculate the importance weight coefficient of the corresponding sample, and then normalize the weight, that is, , and finally use formula (1-5) to Estimation to obtain the first conductivity data E 1; S3: Monte Carlo filtering of the first conductivity data E 1 is processed and the second conductivity data E2 of the current state is output; The specific processing steps of step S3 are as follows: S3-1: Based on the known prior probability density distribution, that is, the conductivity probability distribution of the state estimate at time t-1, a set of conductivity samples of waste oil is generated, each conductivity sample represents a possible state in the state space, and an initial weight is preset for each conductivity sample; S3-2: According to the state transition model, predict each sample and generate the sample state at the next moment. The specific operation steps of the state transition model are as follows: The first conductivity data E 1 is converted into a standard score. The standard score formula is as shown in the following formula (2-1): (2-1); In the formula, z is the standard score, is the average, is the standard deviation, S3-3: Calculate the average of the standard deviations of each group of state transitions in the conductivity sample, and construct the average of the standard deviations of state transitions , the conductivity standard score of the predicted state is estimated by the average value , the average value function of the standard deviation of state transition can be used to establish the conductivity calculation formula z' for the predicted state: ; Where: The conductivity is determined by the state i Transfer to status j When , the average of the standard score differences is is the standard score of conductivity of the predicted state, Initial state i The standard score of Transfer status j The standard score of For status i Transfer to status j The frequency of occurrence, △ z Indicates the standard deviation of state transition; it indicates the transition from state i To status j Changes in standard scores; S3-4: when new conductivity data is obtained, the weight of the sample is updated using the new conductivity data; S3-5: If the variance of the sample weight is greater than the preset value, resampling is performed. The purpose of resampling is to discard samples with smaller weights and copy samples with larger weights to maintain the diversity of the sample set while ensuring that high-weight areas are adequately represented. Otherwise, the next step is executed. S3-6: Based on the samples and their weights, the posterior distribution of the current state can be estimated to obtain the second conductivity data E2; S3-7: repeating steps S3-2 to S3-6, using new conductivity data to update the sample set in each iteration, and outputting the second conductivity data E2 of the current state; S4: Use BP neural network to train the second conductivity data E2, and finally obtain conductivity E3. The specific training steps are as follows: S4-1: The structure of BP neural network includes input layer, output layer and multiple hidden layers. Each layer has several nodes. The connection status of nodes between layers is reflected by weights. The number of nodes in the input layer is equal to the dimension of input, and the number of nodes in the output layer is equal to the dimension of output. In BP neural network, each node contains a perceptron, that is, a separate neuron, which contains input items, weights, biases, activation functions and outputs. In the forward propagation process, the input data is calculated by the perceptron node and then processed by the activation function to obtain the output result; in the reverse propagation process, the result is compared with the expected result, and the weights of each node on the network are adjusted continuously through multiple iterations. The calculation formula of each layer of the BP neural network is expressed by the following formula (3-1): y=T(WE2+b)(3-1); Among them, b represents temperature, W represents conductivity probability, and T represents activation function; S4-2: The training of BP neural network adopts the back propagation algorithm. The back propagation algorithm calculates the state and activation value of each layer, advances the calculation error from the last layer, and updates the parameters to minimize the error function between the predicted output and the actual output of the network. This process is iterated continuously until the preset stopping criteria are met, where the error function is the mean square error function as shown in the following formula (3-3): (3-3); in, is the connection weight, i.e., the conductivity probability, is the bias, i.e., temperature, is the number of training samples, is the number of outputs, For the Sample No. The predicted value of the output, is the corresponding true value, that is, the final conductivity E3.

2. The method for detecting waste cooking oil according to claim 1, wherein: In step S3-4, the matching degree between each sample conductivity data and the sample state is calculated by the likelihood function to update the sample weight, and then the weight is normalized so that the sum of the weights of all samples is 1.

3. The method for detecting waste cooking oil according to claim 1, wherein: In step S3-5, the preset value of the variance of the sample weight is 0.

05.

4. The method for detecting waste cooking oil according to claim 1, wherein: In step S3-6, the posterior distribution of the current state is estimated by calculating the average or mode of the weighted sample states.

5. The method for detecting waste cooking oil according to claim 1, wherein: In step S4-1, the activation function represented by T is the Sigmoid function, which is expressed by the following formula (3-2): (3-2)。 6. A waste cooking oil detection system, comprising a memory and a processor, wherein a computer program is stored in the memory, characterized in that: When the computer program is executed by the processor, the method according to any one of claims 1 to 5 is implemented.

7. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Voltage sag probability evaluation method and system based on Hamiltonian Monte Carlo

    CN117972343A

  • Method for estimating hidden channel parameters of a received GNNS navigation signal

    US20090074038A1