Pollution discharge prediction method based on k-nearest neighbor regression algorithm and electricity consumption data

Through the prediction method based on k-nearest neighbor regression algorithm and electricity consumption data, the data deviation and high cost in pollutant emission monitoring are solved, real-time and accurate pollutant emission prediction are achieved, and the cost of pollutant emission control in enterprises is reduced.

CN114169424BActive Publication Date: 2025-09-02STATE GRID ZHEJIANG ELECTRIC POWER CO LTD HANGZHOU POWER SUPPLY CO +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111464116.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-03
Publication Date
2025-09-02
Estimated Expiration
2041-12-03

AI Technical Summary

Technical Problem

Among the existing pollutant emission monitoring methods, some enterprises upload pollutant emission data themselves may have data deviations and tampering, which affects the accuracy and timeliness of monitoring, and the equipment costs are high, resulting in difficulty and high cost of pollutant emission control.

Method used

By collecting historical electricity consumption data and historical pollution discharge data of pollutant discharge units, performing data preprocessing and dividing the training set and test set, generating parameter combinations of k-nearest neighbor regression algorithms, building a prediction model, using k-nearest neighbor regression algorithm to predict pollution discharge based on electricity consumption data, and optimizing the model to improve accuracy.

Benefits of technology

Real-time pollutant emission prediction based on electricity consumption data is realized, the cost of pollutant emission monitoring is reduced, the real-time and accuracy of monitoring is improved, and the problem of corporate pollutant emission control is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114169424B_ABST
    Figure CN114169424B_ABST
Patent Text Reader

Abstract

The present invention proposes a method for predicting pollutant emissions based on a k-nearest neighbor regression algorithm and electricity consumption data, comprising: collecting historical electricity consumption data and historical pollutant emission data of pollutant emission units and performing data preprocessing, dividing the data into a training set and a test set; generating a parameter combination of the k-nearest neighbor regression algorithm, determining the optimal parameters in the parameter combination by analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, and constructing a prediction model based on the optimal parameters and the k-nearest neighbor regression algorithm; testing the accuracy of the prediction model based on the test set, optimizing the prediction model based on the test results, inputting the real-time electricity consumption data of the pollutant emission units into the optimized prediction model, and obtaining a real-time prediction result of pollutant emissions. The present invention utilizes the influence relationship between electricity consumption and pollutant emission conditions, and realizes the prediction of pollutant emissions based on the k-nearest neighbor regression algorithm, solving the problem of difficult and high control costs of pollutant emissions in some enterprises.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of pollution discharge monitoring, and in particular relates to a pollution discharge prediction method based on a k-nearest neighbor regression algorithm and electricity consumption data. Background Art

[0002] As people pay more attention to environmental pollution, the supervision and control of pollution sources by polluting units have become a key part of ecological and environmental protection, and pollution source emission data has gradually received attention. Therefore, big data technology and the Internet of Things have more application scenarios. They can collect pollutant emission data from enterprises, monitor and issue early warnings for excessive pollutant concentrations, send warning messages of excessive concentrations to polluting units, and notify them to increase pollution control efforts. They can also be used to determine whether an enterprise's pollutant discharge permit exceeds the standard, providing technical support for the ecological and environmental authorities' post-regulation of pollutant discharge permits and supervision and inspection of polluting units, and providing a certain calculation reference basis for the collection and review of corporate environmental protection taxes.

[0003] Current pollution monitoring methods typically involve installing sensors, meters, and other automated monitoring equipment at pollutant-discharging units to collect pollutant emission data and transmit it in real time to relevant authorities for analysis and early warning. However, due to equipment cost constraints, some companies upload their own pollutant emission data, which can lead to data bias, tampering, and falsification, compromising the accuracy and timeliness of pollution monitoring. Summary of the Invention

[0004] In order to address the shortcomings and deficiencies in the prior art, the present invention proposes a method for predicting pollutant discharge based on a k-nearest neighbor regression algorithm and electricity consumption data, including:

[0005] Collect historical electricity consumption data and historical pollution discharge data of pollutant discharge units and perform data preprocessing, and divide the preprocessed historical electricity consumption data and historical pollution discharge data into training sets and test sets;

[0006] Generate a parameter combination for the k-nearest neighbor regression algorithm, determine the optimal parameters in the parameter combination by analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, and build a prediction model based on the optimal parameters and the k-nearest neighbor regression algorithm;

[0007] Test the accuracy of the prediction model based on the test set and optimize the prediction model based on the test results;

[0008] The real-time electricity consumption data of the pollutant discharge units are input into the optimized prediction model, and the real-time prediction results of the pollutant discharge amount are obtained by combining the historical electricity consumption data and the historical pollutant discharge data.

[0009] Optionally, collecting historical electricity consumption data and historical pollution discharge data of pollution discharge units and performing data preprocessing, and dividing the preprocessed historical electricity consumption data and historical pollution discharge data into a training set and a test set, includes:

[0010] Collect historical electricity consumption data and historical pollution data of each production equipment in the pollution-discharging unit based on the preset frequency;

[0011] Eliminate abnormal data from historical electricity consumption data and historical pollution discharge data, and determine whether there are missing fields in the historical electricity consumption data and historical pollution discharge data. If so, calculate the average value of the two adjacent data before and after the missing field to fill in the missing field;

[0012] The historical electricity consumption data and historical pollution discharge data are integrated into a data group based on the relationship between sampling times. After the order of each data group is disrupted, the data group is randomly divided into training sets and test sets based on a preset ratio.

[0013] Optionally, the parameters of the k-nearest neighbor regression algorithm include the number of neighbors k and a weight hyperparameter.

[0014] Optionally, the weight hyperparameter is a parameter representing the weight influence type of the neighboring points on the predicted points, and the weight influence type includes that the neighboring points have the same weight influence on the predicted points, the neighboring points have an influence on the predicted points based on the distance, and the neighboring points have an influence on the predicted points based on the inverse of the distance.

[0015] Optionally, generating a parameter combination for a k-nearest neighbor regression algorithm, determining optimal parameters in the parameter combination by analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, and constructing a prediction model based on the optimal parameters and the k-nearest neighbor regression algorithm, includes:

[0016] Determine the number of nearest neighbors k and weight hyperparameters, set k weights w according to the weight hyperparameters, and generate parameter combinations consisting of different numbers of nearest neighbors k and weights w;

[0017] Randomly select a historical sewage discharge data in the training set as a prediction point, and input the historical electricity consumption data in the training set except the prediction point into the k-nearest neighbor regression algorithm;

[0018] Different parameter combinations are imported into the k-nearest neighbor regression algorithm to calculate the regression value, the parameter combination corresponding to the regression value closest to the predicted point is determined as the optimal parameter, and the prediction model is constructed based on the optimal parameters.

[0019] Optionally, the step of importing different parameter combinations into a k-nearest neighbor regression algorithm to calculate regression values, determining the parameter combination corresponding to the regression value closest to the predicted point as the optimal parameter, and constructing a prediction model based on the optimal parameter includes:

[0020] Calculate the Euclidean distance between the historical electricity consumption data and the predicted point, select the k historical electricity consumption data with the smallest Euclidean distance as the nearest neighbor points, and calculate the first regression value based on the weight hyperparameter.

[0021] Calculate the Manhattan distance between the electricity consumption data and the prediction point except the prediction point, select the k historical electricity consumption data with the smallest Manhattan distance as the nearest neighbor points, and calculate the second regression value based on the weight hyperparameter;

[0022] Calculating a first difference between the first regression value and the historical pollution discharge data at the prediction point, calculating a second difference between the second regression value and the historical pollution discharge data at the prediction point, and taking the parameter combination with the smallest sum of the first difference and the second difference as the optimal parameter;

[0023] A prediction model is constructed based on the k-nearest neighbor regression algorithm under optimal parameters.

[0024] Optionally, the calculation formulas for the first regression value and the second regression value are both:

[0025]

[0026] in, represents the first regression value or the second regression value, A i is the relative weight of the i-th neighbor point to the predicted point determined by the weight hyperparameter, x in It represents the nth eigenvalue of the selected ith neighbor point, where i and n are both positive integers, i = {1, 2, ..., k}, n = {1, 2, ..., n}.

[0027] Optionally, the relative weight of the i-th neighbor point to the predicted point determined according to the weight hyperparameter includes:

[0028] When the weight hyperparameter is that the neighboring points have the same influence on the weight of the predicted point, A i It is an artificially set value;

[0029] When the weight hyperparameter is the influence of the neighboring points on the predicted points based on the distance, A i =d i / (d1+d2+...+d i +...+d k ), d i is the Euclidean distance or Manhattan distance between the i-th neighbor point and the predicted point;

[0030] When the weight hyperparameter is the influence of the neighboring points on the predicted points based on the inverse of the distance,

[0031] Optionally, testing the accuracy of the prediction model based on the test set and optimizing the prediction model based on the test results include:

[0032] Step 1: Input the historical electricity consumption data in the test set into the prediction model;

[0033] Step 2: Determine whether the error between the calculation results based on the optimal parameters and the historical pollution data in the test set meets the preset conditions;

[0034] Step 3: If not, adjust the optimal parameters and repeat steps 1 to 2 until the optimization is completed when the preset conditions are met.

[0035] Optionally, the preset condition is a similarity calculation function, and the expression of the similarity calculation function is:

[0036]

[0037] Among them, score represents the similarity, represents the calculation result obtained in step 1, and X is the historical pollution data in the test set;

[0038] The value range of score is (-∞,1]. When the score reaches the preset limit, the error is judged to meet the preset conditions.

[0039] The beneficial effects brought about by the technical solution provided by the present invention are:

[0040] The present invention collects electricity consumption data of pollutant-discharging units in real time, utilizes the influence relationship between electricity consumption and pollution discharge of pollutant-discharging units, and realizes the prediction of pollution discharge based on the k-nearest neighbor regression algorithm. Compared with traditional pollutant emission monitoring methods, the emission data of pollutants that are difficult to control in real time and have high acquisition costs are converted into electricity consumption data that can be provided in real time and easily obtained for auxiliary management, which to a certain extent solves the problem of difficult and high control costs of pollutant emissions in some enterprises. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0042] Figure 1 This is a flow chart of a method for predicting pollutant discharge based on a k-nearest neighbor regression algorithm and electricity consumption data, as proposed in an embodiment of the present invention. DETAILED DESCRIPTION

[0043] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0044] The terms "first," "second," "third," "fourth," and so forth (if any) in the description and claims of the present invention and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in sequences other than those illustrated or described herein.

[0045] It should be understood that in various embodiments of the present invention, the size of the sequence number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0046] It should be understood that in the present invention, "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.

[0047] It should be understood that in the present invention, "multiple" refers to two or more. "And / or" is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "Contains A, B and C", "Contains A, B, C" means that A, B, and C are all included, "Contains A, B or C" means that one of A, B, and C is included, and "Contains A, B and / or C" means that any one, any two, or any three of A, B, and C are included.

[0048] It should be understood that, in the present invention, "B corresponding to A," "B corresponding to A," "A corresponds to B," or "B corresponds to A" means that B is associated with A and B can be determined based on A. Determining B based on A does not mean determining B based solely on A; B can also be determined based on A and / or other information. A and B match when the similarity between A and B is greater than or equal to a preset threshold.

[0049] Depending on the context, "if" as used herein may be interpreted as "when" or "when" or "in response to determining" or "in response to detecting."

[0050] The following specific embodiments are used to describe the technical solution of the present invention in detail. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0051] Example 1

[0052] like Figure 1 As shown, this embodiment proposes a method for predicting pollutant discharge based on a k-nearest neighbor regression algorithm and electricity consumption data, including:

[0053] S1: Collect historical electricity consumption data and historical pollution discharge data of pollutant discharge units and perform data preprocessing, and divide the preprocessed historical electricity consumption data and historical pollution discharge data into training set and test set;

[0054] S2: Generate a parameter combination for the k-nearest neighbor regression algorithm, determine the optimal parameters in the parameter combination by analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, and build a prediction model based on the optimal parameters and the k-nearest neighbor regression algorithm;

[0055] S3: Test the accuracy of the prediction model based on the test set and optimize the prediction model based on the test results;

[0056] S4: Input the real-time electricity consumption data of the pollutant discharge unit into the optimized prediction model, and combine the historical electricity consumption data and historical pollutant discharge data to obtain the real-time prediction results of the pollutant discharge amount.

[0057] This embodiment collects electricity consumption data of pollutant-emitting units in real time, utilizes the influence relationship between electricity consumption and pollution discharge of pollutant-emitting units, and realizes the prediction of pollutant emissions based on the k-nearest neighbor regression algorithm. Compared with traditional pollutant emission monitoring methods, the emission data of pollutants that are difficult to control in real time and have high acquisition costs are converted into electricity consumption data that can be provided in real time and is easy to obtain for auxiliary management. To a certain extent, it solves the problem of difficult and high control costs of pollutant emissions in some enterprises.

[0058] First, in order to analyze the relationship between the electricity consumption and pollution discharge of pollutant discharge units, this embodiment collects historical electricity consumption data and historical pollution discharge data of the pollutant discharge units and performs data preprocessing. The preprocessed historical electricity consumption data and historical pollution discharge data are divided into a training set and a test set, specifically including:

[0059] The historical electricity consumption data and historical pollution discharge data of each production equipment in the pollution discharge unit are collected based on the preset frequency. For example, in this embodiment, the collection frequency of historical electricity consumption data is 15 minutes, and the sampling frequency of historical pollution discharge data is 1 day. The collection of historical electricity consumption data is shown in Table 1, and the collection of historical pollution discharge data is shown in Table 2.

[0060] Table 1

[0061] Company ID Historical electricity consumption (unit: kw) Sampling time 13******65 134.88 2020-11-19 00:00:00 13******65 116.88 2020-11-19 00:15:00 …… …… ……

[0062] Table 2

[0063] Company ID Historical sewage discharge (unit: kg) Sampling time 13******65 11503.84 2020-11-19 13******65 15718.23 2020-11-20 …… …… ……

[0064] Eliminate abnormal data from historical electricity consumption data and historical pollution data. Consider electricity consumption data or pollution data that is less than or equal to 0 and clearly inconsistent with reality as abnormal data. Eliminate abnormal data and leave data suitable for analysis.

[0065] Due to uncontrollable factors such as the ineffectiveness of the online detection system, the failure of the online detection system, and the loss of control of the online detection system, some field values ​​of a record may be missing or completely missing. Therefore, it is also necessary to determine whether there are missing values ​​in the historical electricity consumption data and the historical pollution discharge data. If so, the average value of the two adjacent data before and after the missing value is calculated to fill in the missing value and replace the original missing data.

[0066] In this embodiment, historical electricity consumption data and historical pollution discharge data are integrated into a data group based on the relationship between sampling times, as shown in Table 3. This embodiment takes the sampling frequency of electricity consumption data and pollution discharge data, whichever has a larger sampling frequency, as the basis, and integrates the historical electricity loads of different production equipment of the same enterprise ID in one day to form an integrated data group.

[0067] Table 3

[0068]

[0069] After shuffling the order of each data group, the data group is randomly divided into training set and test set based on a preset ratio. Usually, the division is performed in such a way that the amount of data in the training set is approximately 10 times the amount of data in the test set. In this embodiment, 99% of the data is randomly selected as the training set for fitting data, and the remaining 1% of the data is used as the test set to test the generalization ability of the model.

[0070] This embodiment adopts the k-nearest neighbor regression algorithm and uses the electricity consumption data of the polluting enterprises to fit and regress the pollution data. The basic idea of ​​the k-nearest neighbor regression algorithm is to find the k sample points closest to the prediction point, and obtain the fitting value of the prediction point based on the characteristics of the sample points.

[0071] In this embodiment, the parameters of the k-nearest neighbor regression algorithm include the number of neighbors, k, and a weight hyperparameter. The weight hyperparameter represents the type of weight influence of neighboring points on the predicted point. These weight influence types include: equal weight influence of neighboring points on the predicted point; weight influence of neighboring points on the predicted point based on distance; and weight influence of neighboring points on the predicted point based on the inverse of distance. This indicates that different weight hyperparameters can affect the calculation results of the k-nearest neighbor regression algorithm.

[0072] This embodiment arranges and combines different values ​​of the number of nearest neighbors k and the weight hyperparameter within a reasonable value range to generate parameter combinations for the k-nearest neighbor regression algorithm. By analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, the optimal parameters in the parameter combination are determined. A prediction model is constructed based on the optimal parameters and the k-nearest neighbor regression algorithm, specifically including:

[0073] Determine the number of nearest neighbors k and the weight hyperparameters, and generate parameter combinations consisting of different nearest neighbor numbers k and weight hyperparameters. Randomly select a historical sewage discharge data point in the training set as the prediction point, and input the historical electricity consumption data in the training set except the prediction point into the k-nearest neighbor regression algorithm.

[0074] For example, the number of nearest neighbors k is selected as all integers in the range of [3, 10], and the weight of the influence of the nearest neighbor points on the predicted point is selected as one of "each nearest neighbor has the same weight influence on the predicted point", "each nearest neighbor has an influence on the predicted point based on the distance", or "each nearest neighbor has an influence on the predicted point based on the inverse of the distance".

[0075] Then, using the training set, we traverse all possible parameter combinations and select the parameter combination with the highest degree of fit. Specifically, we import different parameter combinations into the k-nearest neighbor regression algorithm to calculate the regression value, determine the parameter combination corresponding to the regression value closest to the predicted point as the optimal parameter, and build a prediction model based on the optimal parameters, which includes:

[0076] Calculate the Euclidean distance between the historical electricity consumption data and the forecast point except the forecast point. For example, for A(x1, x2, ..., x n )、B(y1,y2,……,y n ) For two historical electricity consumption data collection points, the calculation formula of the Euclidean distance d1(A,B) is: x1, …, x n and y1, y2, ..., y n These are n eigenvalues ​​of the historical electricity consumption data at the two collection points A and B. In this embodiment, the eigenvalues ​​include the enterprise ID, the collection time, and the historical electricity consumption. The k historical electricity consumption data with the smallest Euclidean distance are selected as the nearest neighbor points, and the first regression value is calculated in combination with the weight hyperparameter.

[0077] Calculate the Manhattan distance between the other electricity consumption data and the prediction point except the prediction point. For example, for A(x1,x2,……,x n )、B(y1,y2,……,y n ) For two historical electricity consumption data collection points, the calculation formula of Manhattan distance d2(A,B) is d2(A,B)=|x1-y1|+|x2-y2|+……+|x n -y n |, select the k historical electricity consumption data with the smallest Manhattan distance as the nearest neighbor points, and calculate the second regression value based on the weight hyperparameter.

[0078] This embodiment combines Euclidean distance and Manhattan distance to determine k nearest neighbor points, which can further improve the rationality of selecting k nearest neighbor points compared to a single distance calculation method.

[0079] Finally, the first difference between the first regression value and the historical pollution data at the prediction point is calculated, and the second difference between the second regression value and the historical pollution data at the prediction point is calculated. The parameter combination that minimizes the sum of the first and second differences is taken as the optimal parameter combination. The prediction model is constructed using the k-nearest neighbor regression algorithm with these optimal parameters. For example, the optimal parameters are: the number of nearest neighbors k is 3; the weight is supersingle, indicating that "each neighbor has an influence on the prediction point based on distance." The k-nearest neighbor regression algorithm based on these parameters is used as the prediction model.

[0080] In this embodiment, the k sample points closest to the predicted point have different distances from the predicted point, and therefore have different impacts on the predicted point. The closer the distance to the predicted point, the greater the impact; the farther the distance from the predicted point, the smaller the impact. Therefore, in this embodiment, weights are added to the traditional regression value calculation, so the calculation formulas for the first regression value and the second regression value are both:

[0081]

[0082]

[0083] in, represents the first regression value or the second regression value, x in It represents the nth eigenvalue of the selected ith neighbor point, where i and n are both positive integers, i = {1, 2, ..., k}, n = {1, 2, ..., n}.

[0084] A i is the relative weight of the i-th neighbor point to the predicted point determined by the weight hyperparameter. When the weight hyperparameter is that the neighbor points have the same influence on the predicted point weight, A i It is a fixed value set by humans; when the weight hyperparameter is the influence of the neighboring points on the predicted points based on the distance, A i =di / (d1+d2+...+d i +...+d k ), d i is the Euclidean distance or Manhattan distance between the i-th neighbor point and the predicted point; when the weight hyperparameter is the influence of the neighbor point on the predicted point based on the inverse of the distance,

[0085] In order to verify whether the prediction model established through the above process can achieve the expected generalization effect of prediction, after the prediction model is built, this embodiment also needs to test the accuracy of the prediction model based on the test set and optimize the prediction model based on the test results, including:

[0086] Step 1: Input the historical electricity consumption data in the test set into the prediction model to obtain the result of the prediction model based on the optimal parameters. That is, the historical electricity consumption data is processed according to the same process as the above training stage to calculate the regression value.

[0087] Step 2: Determine whether the error between the calculation result and the historical pollution data in the test set meets the preset conditions. In this embodiment, the preset condition is a similarity calculation function, and the expression of the similarity calculation function is:

[0088]

[0089] Among them, score represents the similarity, represents the calculation result obtained in step 1, and X is the historical pollution data in the test set;

[0090] The value range of score is (-∞,1]. The closer the score is to 1, the closer the predicted value is to the true value. Therefore, when the score reaches the preset limit, it is determined that the error meets the preset condition. In this embodiment, the preset limit is 0.8. When the score ≥ 0.8, it indicates that the generalization ability of the prediction model is good; the model has good prediction performance.

[0091] Step 3: If it does not meet the requirements, adjust the optimal parameters. In this embodiment, adjusting the optimal parameters includes adjusting the number of neighbors k and the weight hyperparameter. When the weight hyperparameter before adjustment is "the neighboring points have the same influence on the weight of the predicted point", it also includes adjusting A which is set to a fixed value. i Then, repeat steps 1 and 2 until the optimization is completed when the preset conditions are met, that is, the prediction model achieves the expected generalization effect.

[0092] For example, the performance of the prediction model is tested using the test set. The comparison between the true value and the predicted value is shown in Table 4. The score of the prediction model is calculated to be 0.97, indicating that the model has good generalization ability.

[0093] Table 4

[0094]

[0095] Finally, the prediction model that has achieved the expected generalization effect is put into the real application scenario of real-time pollution discharge prediction. The historical electricity consumption data and historical pollution discharge data collected in S1 are used as control samples and input into the prediction model together with the real-time electricity consumption data. By selecting the control sample closest to the real-time electricity consumption data, the real-time prediction result of pollution discharge is obtained based on the k-nearest neighbor regression algorithm.

[0096] The serial numbers in the above embodiments are for description only and do not represent the order of assembly or use of the components.

[0097] The above descriptions are merely embodiments of the present invention and are not intended to limit 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 predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data, characterized in that: The pollutant discharge prediction method includes: Collect historical electricity consumption data and historical pollution discharge data of pollutant discharge units and perform data preprocessing, and divide the preprocessed historical electricity consumption data and historical pollution discharge data into training sets and test sets; Generate a parameter combination for the k-nearest neighbor regression algorithm, determine the optimal parameters in the parameter combination by analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, and build a prediction model based on the optimal parameters and the k-nearest neighbor regression algorithm; Test the accuracy of the prediction model based on the test set and optimize the prediction model based on the test results; The real-time electricity consumption data of pollutant discharge units is input into the optimized prediction model, and the real-time prediction results of pollutant discharge are obtained by combining the historical electricity consumption data and historical pollutant discharge data; Generating a parameter combination of a k-nearest neighbor regression algorithm, determining the optimal parameters in the parameter combination by analyzing the degree of fit of the k-nearest neighbor regression algorithm to the training set under different parameter combinations, and constructing a prediction model based on the optimal parameters and the k-nearest neighbor regression algorithm, including: Determine the number of nearest neighbors k and weight hyperparameters, and generate parameter combinations consisting of different number of nearest neighbors k and weight hyperparameters; Randomly select a historical sewage discharge data in the training set as a prediction point, and input the historical electricity consumption data in the training set except the prediction point into the k-nearest neighbor regression algorithm; Different parameter combinations are imported into the k-nearest neighbor regression algorithm to calculate the regression value, and the parameter combination corresponding to the regression value closest to the predicted point is determined as the optimal parameter, and a prediction model is constructed based on the optimal parameters; The method of importing different parameter combinations into the k-nearest neighbor regression algorithm to calculate regression values, determining the parameter combination corresponding to the regression value closest to the predicted point as the optimal parameter, and constructing a prediction model based on the optimal parameter includes: Calculate the Euclidean distance between the historical electricity consumption data and the predicted point, select the k historical electricity consumption data with the smallest Euclidean distance as the nearest neighbor points, and calculate the first regression value based on the weight hyperparameter. Calculate the Manhattan distance between the historical electricity consumption data and the prediction point except the prediction point, select the k historical electricity consumption data with the smallest Manhattan distance as the nearest neighbor points, and calculate the second regression value based on the weight hyperparameter; Calculating a first difference between the first regression value and the historical pollution discharge data at the prediction point, calculating a second difference between the second regression value and the historical pollution discharge data at the prediction point, and taking the parameter combination with the smallest sum of the first difference and the second difference as the optimal parameter; A prediction model is constructed based on the k-nearest neighbor regression algorithm under optimal parameters.

2. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 1, characterized in that: The collecting of historical electricity consumption data and historical pollution discharge data of pollution discharge units and performing data preprocessing, and dividing the preprocessed historical electricity consumption data and historical pollution discharge data into a training set and a test set, includes: Collect historical electricity consumption data and historical pollution data of each production equipment in the pollution-discharging unit based on the preset frequency; Eliminate abnormal data from historical electricity consumption data and historical pollution discharge data, and determine whether there are missing fields in the historical electricity consumption data and historical pollution discharge data. If so, calculate the average value of the two adjacent data before and after the missing field to fill in the missing field; The historical electricity consumption data and historical pollution discharge data are integrated into a data group based on the relationship between sampling times. After the order of each data group is disrupted, the data group is randomly divided into training sets and test sets based on a preset ratio.

3. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 1, characterized in that: The parameters of the k-nearest neighbor regression algorithm include the number of neighbors k and a weight hyperparameter.

4. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 3, characterized in that: The weight hyperparameter is a parameter that represents the weight influence type of the neighboring points on the predicted point. The weight influence type includes the neighboring points having the same weight influence on the predicted point, the neighboring points having an influence on the predicted point based on the distance, and the neighboring points having an influence on the predicted point based on the inverse of the distance.

5. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 1, characterized in that: The calculation formulas for the first regression value and the second regression value are both: ; in, represents the first regression value or the second regression value, is the relative weight of the i-th neighbor point to the predicted point determined by the weight hyperparameter, Represents the nth eigenvalue of the selected i-th neighbor point, where i and n are both positive integers, i={1,2,...,k}, n={1,2,...,n}.

6. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 5, characterized in that: The relative weight of the i-th neighbor point to the predicted point determined according to the weight hyperparameter includes: When the weight hyperparameter is that the neighboring points have the same influence on the weight of the predicted point, It is an artificially set value; When the weight hyperparameter is the influence of neighboring points on the predicted points based on distance, , is the Euclidean distance or Manhattan distance between the i-th neighbor point and the predicted point; When the weight hyperparameter is the influence of the neighboring points on the predicted points based on the inverse of the distance, 。 7. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 1, characterized in that: The accuracy of the prediction model is tested based on the test set, and the prediction model is optimized based on the test results, including: Step 1: Input the historical electricity consumption data in the test set into the prediction model to obtain the calculation results of the prediction model based on the optimal parameters; Step 2: Determine whether the error between the calculation result and the historical pollution data in the test set meets the preset conditions; Step 3: If not, adjust the optimal parameters and repeat steps 1 to 2 until the optimization is completed when the preset conditions are met.

8. The method for predicting pollutant discharge based on the k-nearest neighbor regression algorithm and electricity consumption data according to claim 7, characterized in that: The preset condition is a similarity calculation function, and the expression of the similarity calculation function is: ; in, Indicates similarity, represents the calculation result obtained in step 1, This is the historical sewage discharge data in the test set; The value range of score is ,When the score reaches the preset limit, it is judged that the error meets the preset conditions.

Citation Information

Patent Citations

  • Sewage prediction system and sewage prediction method in production

    CN110188945A

  • K-nearest neighbor regression prediction method for steam quantity prediction of boiler special equipment

    CN112417764A