Water quality monitoring data filling method, device, equipment, storage medium and product

By using an encoder-decoder architecture model based on a long short-term memory network, combined with time coding and flow sequence, the problem of missing total nitrogen concentration data in water quality monitoring was solved, and the accuracy and reliability of data filling were improved.

CN122024920APending Publication Date: 2026-05-12SOUTHERN UNIVERSITY OF SCIENCE AND TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTHERN UNIVERSITY OF SCIENCE AND TECHNOLOGY
Filing Date
2025-12-31
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing water quality monitoring, total nitrogen concentration sequence data is often missing due to factors such as equipment failure, transmission interruption, and harsh environment, resulting in missing values ​​and observation breakpoints. Existing data filling methods are prone to overall trend deviations, affecting the reliability of data analysis.

Method used

An encoder-decoder architecture model based on a long short-term memory network is adopted. By combining time-encoded sequences and flow sequences, a total nitrogen concentration filler value sequence is generated. Then, through linear mapping processing, the filler values ​​are aligned with the real total nitrogen concentration data to form a complete total nitrogen concentration sequence.

Benefits of technology

It improves the accuracy of water quality monitoring data filling, generates filling values ​​that conform to the water body change patterns and have a reasonable numerical range, and enhances the reliability of data analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122024920A_ABST
    Figure CN122024920A_ABST
Patent Text Reader

Abstract

The invention discloses a water quality monitoring data filling method and device, equipment, a storage medium and a product, and relates to the technical field of data processing.The water quality monitoring data filling method comprises the steps that a water quality characteristic data set of a target water body is obtained, the water quality characteristic data set comprises a time coding sequence, a flow sequence and a total nitrogen concentration sequence with missing values; the water quality characteristic data set is input into a pre-trained data filling model, a total nitrogen concentration filling value sequence output by the data filling model is obtained, and the data filling model is a model of an encoder decoder architecture based on a long short-term memory network; performing linear mapping processing on each filling value in the total nitrogen concentration filling value sequence according to a total nitrogen concentration numerical value range in the total nitrogen concentration sequence to obtain a mapping filling value sequence; and combining the mapping filling value sequence and the total nitrogen concentration sequence to obtain a target total nitrogen concentration sequence. The filling accuracy of the water quality monitoring data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to methods, apparatus, equipment, storage media and products for filling water quality monitoring data. Background Technology

[0002] In water quality monitoring, total nitrogen concentration is a key indicator, and its continuous observation data is crucial for water quality assessment.

[0003] However, due to factors such as equipment failure, transmission interruption and harsh environment, the obtained total nitrogen concentration sequence data has missing values ​​and observation breakpoints of varying lengths. To address the problem of missing data, statistical interpolation and deep learning models are commonly used for data filling. However, the filling results are prone to overall trend deviation, resulting in poor data filling effect and affecting the reliability of subsequent data analysis.

[0004] In summary, improving the accuracy of water quality monitoring data filling has become a pressing technical problem that needs to be solved in this field. Summary of the Invention

[0005] The main objective of this application is to provide a method, apparatus, equipment, storage medium, and product for filling water quality monitoring data, with the aim of improving the accuracy of filling water quality monitoring data.

[0006] To achieve the above objectives, this application proposes a water quality monitoring data filling method, which includes: Obtain a water quality feature dataset of the target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow rate sequence, and a total nitrogen concentration sequence with missing values; The water quality feature dataset is input into a pre-trained data imputation model to obtain a sequence of total nitrogen concentration imputation values ​​output by the data imputation model. The data imputation model is a model based on an encoder-decoder architecture of a long short-term memory network. Based on the total nitrogen concentration range in the total nitrogen concentration sequence, each filler value in the total nitrogen concentration filler value sequence is linearly mapped to obtain the mapped filler value sequence. The mapped fill value sequence and the total nitrogen concentration sequence are merged to obtain the target total nitrogen concentration sequence.

[0007] In one embodiment, the step of obtaining the water quality characteristic dataset of the target water body includes: Acquire flow rate data, total nitrogen concentration data, and data acquisition timestamps for the target water body within a preset time window; The flow data, total nitrogen concentration data, and data acquisition timestamps are sorted according to time order to obtain an initial flow sequence, an initial total nitrogen concentration sequence, and a timestamp sequence. Sine coding is performed on each of the timestamps in the timestamp sequence to obtain the timestamp coding sequence; The initial flow sequence is standardized to obtain a standardized flow sequence; Based on the quantile statistics algorithm, outliers in the standardized flow sequence and the initial total nitrogen concentration sequence are truncated to obtain the flow sequence and the total nitrogen concentration sequence, respectively. The time-coded sequence, the flow rate sequence, and the total nitrogen concentration sequence are integrated to obtain a water quality characteristic dataset.

[0008] In one embodiment, before the step of inputting the water quality feature dataset into a pre-trained data imputation model to obtain the total nitrogen concentration imputation value sequence output by the data imputation model, the method further includes: Obtain historical water quality characteristic datasets as training samples; The training samples are input into the initial data filling model to obtain a training total nitrogen concentration filling value sequence; The mixed loss function is calculated based on the training total nitrogen concentration filled value sequence and the real total nitrogen concentration observed value sequence to obtain the mixed loss value. The timestamp of each observation in the real total nitrogen concentration observed value sequence corresponds to the timestamp of each training filled value in the training total nitrogen concentration filled value sequence. The mixed loss function includes a trend loss term function and a fidelity loss term function. The parameters of the initial data imputation model are iteratively updated based on the mixed loss value to obtain the trained data imputation model.

[0009] In one embodiment, the step of calculating a mixed loss function based on the training total nitrogen concentration filler sequence and the actual total nitrogen concentration observation sequence to obtain a mixed loss value includes: Based on the total nitrogen concentration range in the real total nitrogen concentration observation value sequence, each training fill value in the training total nitrogen concentration fill value sequence is linearly mapped to obtain the training mapped fill value sequence. Calculate the first mean square error between the training mapping filled value sequence and the real total nitrogen concentration observation value sequence, and use the first mean square error value as the trend loss value; Calculate the second mean square error between the training mapping filled value sequence and the training total nitrogen concentration filled value sequence, and use the second mean square error as the fidelity loss value; The trend loss value and the fidelity loss value are weighted and summed to obtain the mixed loss value.

[0010] In one embodiment, the data padding model includes an encoder, a decoder, and a fully connected output layer; The step of inputting the water quality feature dataset into a pre-trained data imputation model to obtain the total nitrogen concentration imputation value sequence output by the data imputation model includes: The water quality feature dataset is input into the encoder to extract the temporal correlation features between the flow rate sequence and the total nitrogen concentration sequence. The temporal correlation features are input into the decoder so that the decoder can calculate the hidden state vector of the time step in which the missing value is located based on the temporal correlation features. The hidden state vector is input to the fully connected output layer, so that the hidden state vector is mapped to the total nitrogen concentration filling value through the fully connected output layer, thereby obtaining the total nitrogen concentration filling value sequence.

[0011] In one embodiment, the step of performing linear mapping processing on each filler value in the total nitrogen concentration filler value sequence according to the total nitrogen concentration numerical range in the total nitrogen concentration sequence to obtain a mapped filler value sequence includes: Determine the range of total nitrogen concentration values ​​in the total nitrogen concentration sequence and the range of filler values ​​in the total nitrogen concentration filler value sequence; Based on the total nitrogen concentration range and the filler value range, a linear mapping process is performed on each filler value in the total nitrogen concentration filler value sequence so that each filler value and the observed value in the total nitrogen concentration sequence are in the same numerical range, thus obtaining a mapped filler value sequence.

[0012] Furthermore, to achieve the above objectives, this application also proposes a water quality monitoring data filling device, which includes: The dataset acquisition module is used to acquire the water quality feature dataset of the target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow sequence, and a total nitrogen concentration sequence with missing values; The data filling module is used to input the water quality feature dataset into a pre-trained data filling model to obtain a sequence of total nitrogen concentration filling values ​​output by the data filling model. The data filling model is a model based on an encoder-decoder architecture of a long short-term memory network. The filling value mapping module is used to perform linear mapping processing on each filling value in the total nitrogen concentration filling value sequence according to the total nitrogen concentration numerical range in the total nitrogen concentration sequence, so as to obtain a mapped filling value sequence. The sequence merging module is used to merge the mapped fill value sequence and the total nitrogen concentration sequence to obtain the target total nitrogen concentration sequence.

[0013] In addition, to achieve the above objectives, this application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the water quality monitoring data filling method described above.

[0014] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the water quality monitoring data filling method described above.

[0015] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the water quality monitoring data filling method described above.

[0016] This application proposes a water quality monitoring data imputation method. The method involves acquiring a water quality characteristic dataset of a target water body, which includes a time-coded sequence, a flow rate sequence, and a total nitrogen concentration sequence with missing values. The water quality characteristic dataset is then input into a pre-trained data imputation model to obtain a total nitrogen concentration imputation value sequence output by the model. The data imputation model is a model based on a long short-term memory network encoder-decoder architecture. Each imputation value in the total nitrogen concentration sequence is linearly mapped according to the range of total nitrogen concentration values ​​in the total nitrogen concentration sequence to obtain a mapped imputation value sequence. Finally, the mapped imputation value sequence and the total nitrogen concentration sequence are merged to obtain the target total nitrogen concentration sequence.

[0017] In summary, this application obtains a feature dataset integrating time-coded sequences, flow sequences, and total nitrogen concentration sequences, inputs it into an encoder-decoder architecture model based on a long short-term memory network, and directly outputs a sequence of total nitrogen concentration filler values ​​corresponding to the missing total nitrogen concentration observations. Furthermore, by performing a linear mapping process on this total nitrogen concentration filler value sequence based on the actual numerical range of the total nitrogen concentration sequence, the filler values ​​are aligned with the known true total nitrogen concentration data in terms of magnitude distribution. Finally, the mapped filler value sequence is merged with the total nitrogen concentration sequence to form a complete total nitrogen concentration sequence. Therefore, by introducing the flow sequence as part of the input data for the data filling model, it can leverage the mapping relationship between water flow and total nitrogen concentration to generate filler values ​​that conform to the water body's variation patterns and have a reasonable numerical range at nodes where total nitrogen concentration data is missing, thus improving the accuracy of the filled data. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the water quality monitoring data filling method in Embodiment 1 of this application. Figure 2 A simplified flowchart illustrating the data filling process provided in Embodiment 2 of the water quality monitoring data filling method of this application; Figure 3 A schematic diagram of the model training process provided in Embodiment 2 of the water quality monitoring data filling method of this application; Figure 4 A visual representation of the data filling effect provided in Embodiment 2 of the water quality monitoring data filling method of this application; Figure 5 This is a schematic diagram of the module structure of the water quality monitoring data filling device according to an embodiment of this application; Figure 6 This is a schematic diagram of the equipment structure of the hardware operating environment involved in the water quality monitoring data filling method in this application embodiment.

[0021] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0022] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0023] In water quality monitoring, total nitrogen concentration is a key indicator, and its continuous observation data is crucial for water quality assessment.

[0024] However, due to factors such as equipment failure, transmission interruption and harsh environment, the obtained total nitrogen concentration sequence data has missing values ​​and observation breakpoints of varying lengths. To address the problem of missing data, statistical interpolation and deep learning models are commonly used for data filling. However, the filling results are prone to overall trend deviation, resulting in poor data filling effect and affecting the reliability of subsequent data analysis.

[0025] In summary, improving the accuracy of water quality monitoring data filling has become a pressing technical problem that needs to be solved in this field.

[0026] It is worth noting that existing methods often treat total nitrogen concentration as a single time series for learning, with models primarily extracting statistical patterns from historical concentration values. This fails to adequately consider the mechanistic characteristics of pollutant transport and diffusion processes in water bodies, which are dominated by hydrodynamic conditions (especially flow rate changes). In real-world aquatic environments, flow rate fluctuations are often a significant driver of concentration changes, such as scouring and dilution effects. If prior hydrodynamic information, such as flow rate, is not effectively incorporated during the reconstruction of missing data, the model is prone to producing inaccurate values ​​that deviate from the actual mechanisms when hydrological conditions change drastically, resulting in insufficient reliability.

[0027] This application provides a solution that acquires a feature dataset integrating time-coded sequences, flow sequences, and total nitrogen concentration sequences, inputs it into an encoder-decoder architecture model based on a long short-term memory network, and directly outputs a sequence of total nitrogen concentration filler values ​​corresponding to the missing total nitrogen concentration observations. Furthermore, by performing a linear mapping process on this total nitrogen concentration filler value sequence based on the actual numerical range of the total nitrogen concentration sequence, the filler values ​​are aligned with the known true total nitrogen concentration data in terms of magnitude distribution. Finally, the mapped filler value sequence is merged with the total nitrogen concentration sequence to form a complete total nitrogen concentration sequence. Therefore, by introducing the flow sequence as part of the input data for the data filling model, the mapping relationship between water flow and total nitrogen concentration can be utilized to generate filler values ​​that conform to the water body's variation patterns and have a reasonable numerical range at nodes where total nitrogen concentration data is missing, thus improving the accuracy of the filled data.

[0028] It should be noted that the executing entity in this embodiment can be an electronic device with data processing, network communication and program execution functions, such as a computer, host computer, controller, server, etc., or an electronic device capable of realizing the above functions.

[0029] Based on this, the embodiments of this application provide a method for filling water quality monitoring data, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the water quality monitoring data filling method of this application.

[0030] In this embodiment, the water quality monitoring data filling method includes steps S10~S40: Step S10: Obtain the water quality feature dataset of the target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow sequence, and a total nitrogen concentration sequence with missing values; The target water body can be a specific river, lake, reservoir, or section of waterway. The goal is to obtain a water quality characteristic dataset for this target water body. This dataset contains key features reflecting the water body's temporal attributes, hydrodynamic conditions, and pollution status. Specifically, it may include time-coded sequences, flow sequences, and total nitrogen concentration sequences with missing values. Each sequence corresponds precisely to a specific time dimension. The time-coded sequence is a periodic feature sequence obtained by encoding the data acquisition timestamps. The flow sequence is a water body flow data sequence after standardization and outlier removal. The total nitrogen concentration sequence is a total nitrogen concentration data sequence containing some missing values ​​after outlier removal.

[0031] Step S20: Input the water quality feature dataset into the pre-trained data filling model to obtain the total nitrogen concentration filling value sequence output by the data filling model. The data filling model is a model based on an encoder-decoder architecture of a long short-term memory network. The water quality feature dataset is input into a pre-trained data imputation model to obtain the total nitrogen concentration imputation value sequence output by the data imputation model. The data imputation model is an encoder-decoder architecture model based on Long Short-Term Memory (LSTM) network, which is used to capture the temporal correlation between water flow and total nitrogen concentration. The encoder extracts the features of the input data, and the decoder generates the target output based on the features. The data in the output total nitrogen concentration imputation value sequence is used to fill the missing values ​​in the total nitrogen concentration sequence, so as to complete the total nitrogen concentration observation data of the target water body.

[0032] Step S30: Based on the range of total nitrogen concentration values ​​in the total nitrogen concentration sequence, perform linear mapping processing on each fill value in the total nitrogen concentration fill value sequence to obtain the mapped fill value sequence. Based on the numerical range of the effective observations in the total nitrogen concentration sequence, each filler value in the total nitrogen concentration filler value sequence is linearly mapped to obtain the mapped filler value sequence. The linear mapping process refers to adjusting the scale of the filler values ​​based on the numerical range of the total nitrogen concentration sequence through a specific linear transformation formula, so that the filler values ​​are in the same numerical distribution range as the true observations in the total nitrogen concentration sequence, thus eliminating distribution offset.

[0033] Step S40: Merge the mapped fill value sequence and the total nitrogen concentration sequence to obtain the target total nitrogen concentration sequence.

[0034] The mapped fill value sequence and the total nitrogen concentration sequence are matched and merged according to timestamps. The missing positions in the total nitrogen concentration sequence are replaced with the mapped fill values, while the original data of the true observation values ​​are retained to form a continuous and complete target total nitrogen concentration sequence.

[0035] Therefore, by introducing flow sequence as part of the input data of the data filling model, the mapping relationship between water flow and total nitrogen concentration can be used to generate filling values ​​that conform to the water body change pattern and have a reasonable numerical range at nodes where total nitrogen concentration data is missing, thereby improving the accuracy of the filling data.

[0036] In one feasible embodiment, step S10 may include steps S101 to S106: Step S101: Obtain the flow rate data, total nitrogen concentration data, and data acquisition timestamp of the target water body within a preset time window; The system acquires continuous flow rate data, total nitrogen concentration data, and corresponding data acquisition timestamps for the target water body within a preset time window. The data acquisition process must ensure that the flow rate data, total nitrogen concentration data, and timestamps correspond one-to-one. The length of the preset time window is reasonably set based on the response lag characteristics of water body flow rate to changes in total nitrogen concentration, such as 5 hours, to ensure that the correlation between the two can be fully captured.

[0037] Step S102: Sort the flow data, total nitrogen concentration data and data acquisition timestamps according to time order to obtain the initial flow sequence, initial total nitrogen concentration sequence and timestamp sequence; Based on the order of data collection timestamps, the collected flow data, total nitrogen concentration data, and data collection timestamps are uniformly sorted to align the three in the time dimension, forming an initial flow sequence, an initial total nitrogen concentration sequence, and a timestamp sequence, thus avoiding the impact of time sequence disorder on subsequent processing results.

[0038] Step S103: Perform sine coding on each timestamp in the timestamp sequence to obtain a time-coded sequence; Each timestamp in the timestamp sequence is sinusoidally encoded. Sine coding is a method of transforming linear time data into periodic features through a specific mathematical mapping, thereby characterizing the periodic changes in water quality caused by natural factors such as seasons and tides. In one feasible implementation, a sine function is used to normalize the timestamp data to... Within the range, its encoding formula is: ;in, Represents any timestamp, This represents the periodic time characteristic corresponding to the timestamp. As a time period parameter, in this embodiment, considering that the change in total nitrogen concentration has obvious annual seasonal characteristics, it can be... Set for one year.

[0039] Step S104: Standardize the initial flow sequence to obtain a standardized flow sequence; The initial flow sequence is standardized to transform each flow data point in the sequence into a standard distribution with a mean of 0 and a standard deviation of 1. The specific steps include: First, calculating the sample mean of the flow data. and sample standard deviation The calculation formulas are as follows: ; ; in, The sample mean. The standard deviation of the sample is 1. The total number of samples, For the first Flow observation values ​​at each time point.

[0040] Based on this, the traffic data is standardized to obtain standardized traffic data. The calculation formula is as follows: ; in, This represents the traffic data after standardization. A standardized traffic sequence is obtained by sequentially standardizing each data point in the initial traffic sequence.

[0041] Step S105: Based on the quantile statistics algorithm, outliers in the standardized flow rate sequence and the initial total nitrogen concentration sequence are truncated to obtain the flow rate sequence and the total nitrogen concentration sequence. To eliminate extreme outliers in total nitrogen concentration and flow rate data that may be caused by sensor malfunctions, data acquisition errors, or sudden environmental changes, and to construct stable statistical boundaries, it is necessary to truncate and compress outliers in the standardized flow rate sequence and the initial total nitrogen concentration sequence. The specific steps are as follows: First, the effective statistical interval of the data distribution is determined using the quantile method (e.g., 1%–99%), and its upper and lower boundaries are represented as follows: ; in, and These represent the lower and upper boundaries of the data distribution, respectively.

[0042] Subsequently, according to the following segmentation rules, the segments exceeding the lower boundary are... and upper boundary The data within the defined range is compressed and truncated. ; in, This represents the traffic data after standardization. Or the original total nitrogen concentration data, This represents the data after truncation. This processing method prevents extreme values ​​from being amplified during subsequent special linear mapping processes, while suppressing abnormal spikes while preserving the main fluctuation characteristics, thus providing a noise-resistant data foundation for the model to capture evolutionary trends.

[0043] Step S106: Integrate the time-coded sequence, flow rate sequence, and total nitrogen concentration sequence to obtain a water quality characteristic dataset.

[0044] The processed time-coded sequences, flow sequences, and total nitrogen concentration sequences are integrated along the time dimension to ensure that the three types of feature data correspond one-to-one at each time step, forming a water quality feature dataset with a standardized structure and reliable data, which meets the requirements of model input.

[0045] Thus, through a full-process preprocessing process including time alignment, sinusoidal coding, standardization, and outlier truncation, the data possesses noise resistance, temporal consistency, and scale uniformity, effectively avoiding interference from anomalous data and temporal disorder in data filling of the model.

[0046] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter. Furthermore, steps A10 to A40 may be included before step S20: Step A10: Obtain historical water quality characteristic dataset as training samples; The historical water quality feature dataset of the target water body is obtained as a training sample. The acquisition and preprocessing process of this historical water quality feature dataset can be referred to the above embodiment and will not be repeated here. It is worth mentioning that the total nitrogen concentration sequence in this historical water quality feature dataset is a true observation value sequence without missing values, which can be used as a true value reference benchmark for model training. It provides a comparative basis for simulating the scenario of missing total nitrogen concentration data and verifying the filling effect during the model training process, and ensures the reliability of the training effect.

[0047] Among them, for the total nitrogen concentration sequence without missing values ​​in the historical water quality characteristic dataset, missing scenarios in actual monitoring are artificially simulated, such as randomly setting continuous or discrete missing positions, and the missing duration covering short-term missing to long-term continuous missing, to form a training total nitrogen concentration sequence containing simulated missing values.

[0048] Step A20: Input the training samples into the initial data filling model to obtain the training total nitrogen concentration filling value sequence; Training samples containing the training total nitrogen concentration sequence are divided according to a preset batch size and sequence length, and then input into the initial data imputation model. This initial data imputation model is a model of the encoder-decoder architecture based on a long short-term memory network to be trained. Through the forward propagation operation of the model, numerical imputation is performed on the artificially set missing positions in the training total nitrogen concentration sequence to obtain a training total nitrogen concentration imputation value sequence that corresponds one-to-one with the missing positions. The timestamp of each imputation value in this sequence corresponds to the timestamp of the simulated missing position in the training sample.

[0049] Step A30: Calculate the mixed loss function based on the training total nitrogen concentration filled value sequence and the real total nitrogen concentration observed value sequence to obtain the mixed loss value. The timestamp of each observation in the real total nitrogen concentration observed value sequence corresponds to the timestamp of each training filled value in the training total nitrogen concentration filled value sequence. The mixed loss function includes a trend loss term function and a fidelity loss term function. A hybrid loss function is calculated based on the training total nitrogen concentration filler value sequence and the actual total nitrogen concentration observation sequence (i.e., the original total nitrogen concentration sequence in the historical water quality characteristic dataset). The hybrid loss function is an optimization objective composed of a weighted average of a trend loss term and a fidelity loss term. The trend loss term constrains the overall evolution trend of the filler values, while the fidelity loss term preserves local detail features. This function comprehensively measures the model's performance in both trend characterization and detail recovery, yielding a hybrid loss value that reflects the model's prediction error.

[0050] In one feasible embodiment, step A30 may include steps A301 to A304: Step A301: Based on the range of total nitrogen concentration values ​​in the actual total nitrogen concentration observation value sequence, perform linear mapping processing on each training fill value in the training total nitrogen concentration fill value sequence to obtain the training mapped fill value sequence. Based on the numerical range of valid observations in the true total nitrogen concentration observation sequence, each training filler value in the training total nitrogen concentration filler value sequence is linearly mapped to obtain a mapped filler value sequence. The linear mapping process refers to adjusting the scale of the training filler values ​​based on the numerical range of the true total nitrogen concentration observation sequence through a specific linear transformation formula, so that the training filler values ​​and the true observations in the true total nitrogen concentration observation sequence are in the same numerical distribution range, thus eliminating distribution offset.

[0051] Step A302: Calculate the first mean square error between the training mapping filled value sequence and the actual total nitrogen concentration observation value sequence, and use the first mean square error as the trend loss value; The mean square error between the training mapping filled value sequence and the actual total nitrogen concentration observation value sequence is calculated and denoted as the first mean square error value, which is then used as the trend loss value.

[0052] Specifically, trend loss is used to constrain the overall evolution trend of the filled values. It does this by comparing the filled values ​​after a specific linear mapping. Compared with the actual observed value This measures the macroscopic deviation of the model imputation results in the direction of time series evolution. In one feasible implementation, the trend loss is calculated as follows: ; in, The number of samples participating in the current loss calculation. and The first The model fills in the mapped values ​​of each sample and the actual observed values. Trend loss, by penalizing biases at the time series level, ensures that the model fills in the data to better match the actual data at peaks, troughs, and inflection points, thereby suppressing abnormal oscillations that may occur during the reconstruction of long missing segments.

[0053] Step A303: Calculate the second mean square error between the training mapping filled value sequence and the training total nitrogen concentration filled value sequence, and use the second mean square error as the fidelity loss value; The mean square error between the training mapping fill value sequence and the training total nitrogen concentration fill value sequence is calculated and denoted as the second mean square error value. This second mean square error value is then used as the fidelity loss value.

[0054] Specifically, fidelity loss is used to finely constrain the model's ability to recover local details. It compares the difference before and after a specific linear mapping, i.e. and The distance between these values ​​limits the model from over-compressing its detailed structure while aligning with the true value range. In one feasible implementation, the fidelity loss can be calculated as the mean squared error: ; in, For the first The initial imputed values ​​for each sample correspond to the model. The fidelity loss only focuses on the magnitude of the numerical change before and after the special linear mapping. By constraining this difference, an "internal consistency" constraint is introduced: on the one hand, it ensures that the range of imputed values ​​is dynamically scaled to the target true range; on the other hand, it preserves the ability of the original model output to characterize local fluctuations and avoids over-smoothing.

[0055] Step A304: The trend loss value and the fidelity loss value are weighted and summed to obtain the mixed loss value.

[0056] The trend loss value and the fidelity loss value are weighted and summed to obtain the mixed loss value. The weight coefficients of the trend loss term and the fidelity loss term can be set according to the actual application scenario to balance the optimization goals of the model in terms of trend alignment and detail recovery.

[0057] Therefore, by weighting the trend loss function term and the fidelity loss function term, the resulting combined optimization objective can reduce the distributional offset of the model's filled values ​​relative to the true filled values, and establish a balance between trend characterization and detail fidelity, thereby improving the overall stability and local accuracy of long-term missing reconstruction.

[0058] Step A40: Iteratively update the parameters of the initial data imputation model based on the mixed loss value to obtain the trained data imputation model.

[0059] The backpropagation algorithm is used to solve for the gradients of each learnable parameter of the model based on the calculated mixed loss value. The learnable parameters include various weight matrices in the model (such as LSTM gate weight matrix, fully connected layer weight matrix) and bias terms. The parameters are iteratively adjusted according to the gradient descent direction until the mixed loss value tends to stabilize, that is, the model converges. At this point, a trained data imputation model with high-fidelity imputation capability is obtained.

[0060] Therefore, through iterative training based on complete historical data, the model can fully learn the temporal correlation between flow rate and total nitrogen concentration. Combined with the constraints of the hybrid loss function, the trained model has strong anti-interference ability and high accuracy, which can meet the filling needs of missing total nitrogen concentration data.

[0061] In one feasible embodiment, the data padding model includes an encoder, a decoder, and a fully connected output layer; step S20 may include steps S201-S203: Step S201: Input the water quality feature dataset into the encoder to extract the temporal correlation features between the flow rate sequence and the total nitrogen concentration sequence through the encoder; It should be noted that the temporal correlation between the flow rate sequence and the total nitrogen concentration sequence refers to their inherent coupling relationship over time. Examples include the delayed response of a sudden increase in flow rate to total nitrogen concentration; the slow, periodic fluctuations in total nitrogen concentration during periods of stable flow rate in the dry season; the positive / negative correlation between flow rate and total nitrogen concentration during flood season (scouring effect vs. dilution effect); and the differences in the strength of the correlation between flow rate and total nitrogen concentration across different seasons. This temporal correlation is abstract, while the encoder processes the input sequence step-by-step through the gating mechanism of LSTM, outputting the final hidden state. and memory unit This transforms the aforementioned abstract temporal correlation features into a quantization result in the form of a high-dimensional tensor, which is equivalent to translating the law of flow affecting the change of total nitrogen concentration into a digital language that the model can recognize and the decoder can reuse.

[0062] The water quality feature dataset is input into the encoder, which is a flow-to-total nitrogen time-series co-encoder composed of several LSTM units, specifically designed to jointly extract the correlation features between the flow sequence and the total nitrogen concentration sequence over time. The input feature tensor of the encoder is denoted as... The dimensions are, in order, batch size. Sequence length and input feature dimensions Among them, batch size Indicates the number of samples processed in a single parallel operation; sequence length. Set the pre-designed time window length (e.g., 5 hours), representing the number of time steps included in each sample. This time window is used to cover the lag interval of flow rate response to water quality changes; input feature dimensions. This represents the number of features contained in each time step. The input features specifically include the time-coded sequence, the flow rate sequence, and the total nitrogen concentration sequence. The encoder processes the input data step-by-step using an LSTM gating mechanism, ultimately outputting the encoder's final hidden state. and memory unit And use both as the initial state of the decoder.

[0063] In one feasible implementation, the process of the encoder extracting temporal correlation features includes: ① Forget Gate Calculation: Using the sigmoid activation function to access the memory units from the previous time step The elements in the dataset are weighted to determine their retention level at the current time step. The formula for this calculation is as follows: ; in, Output for the forget gate. Here is the weight matrix for the forget gate. For the bias term of the forget gate, This is the hidden state from the previous moment. The input features at the current time, It is the sigmoid activation function.

[0064] ② Input gate calculation: The input gate is used to determine the new information that needs to be written to the memory cell. It consists of two parts: the input gate activation value and the candidate state.

[0065] The formula for calculating the input gate activation value is: ; in, The input gate activation value, Here is the weight matrix of the input gate. This is the bias term for the input gate.

[0066] The formula for calculating the candidate state is: ; in, Candidate memory states, Here is the weight matrix for the candidate states. For the bias term of the candidate state, It is the hyperbolic tangent activation function.

[0067] ③ Memory cell update and output gate calculation: First, the memory units at the current time step are updated based on the forget gate and the input gate. : ; in, For the memory unit at the current time step, the historical information retained by the forget gate and the new information received by the input gate are multiplied element-wise. It was obtained through fusion.

[0068] Subsequently, the output gate is based on the hidden state of the previous time step. With current input features The gating coefficient was calculated. Combined with memory units Together determine the hidden state at the current time step This is used to capture the flow guidance features of the current time step and provide input for the next time step. The formula for calculating the output gate activation value is: ; in, For output gate output, Here is the weight matrix of the output gate. This is the bias term for the output gate. The hidden state at the current time step. Output gate output and memory unit The formula for its calculation is jointly determined as follows: ; in, This indicates element-wise multiplication.

[0069] Step S202: Input the temporal correlation features into the decoder so that the decoder can calculate the hidden state vector of the time step where the missing value is located based on the temporal correlation features; The temporal correlation features output by the encoder (i.e., the final hidden state) and memory unit The input is fed into the decoder, which is in the final hidden state. and memory unit As the initial state, the process iterates step by step, combining the current flow characteristics input and the hidden state of the previous time step, and sequentially calculates the input gate, forget gate, candidate memory unit and current memory unit state, finally obtaining the hidden state of the time step where the missing value is located.

[0070] In one feasible implementation, the process by which the decoder calculates the hidden state vector at the time step where the missing value is located includes: The final hidden state and memory unit As the initial state of the decoder, its relationship can be expressed as: ; in, Indicates the final hidden state. Represents a memory unit. Let X represent the Long Short-Term Memory network, and let X be the input feature tensor of the aforementioned encoder.

[0071] The decoder fills in the time step iteratively, by receiving the hidden state and memory unit from the previous time step and combining it with the current time step's traffic feature input to calculate the fill value for the current time step. Specifically, for each time step... Based on the input features at the current time (Including traffic data) and the hidden state of the previous moment First calculate the input gate activation value. Its expression is: ; in, and These are the weight matrices of the input gate, respectively. For the bias term of the input gate, This is the Sigmoid activation function. The input gate is used to determine what proportion of new information at the current time needs to be written into the memory cells.

[0072] Subsequently, based on the current input features and the hidden state of the previous moment Calculate the activation value of the forget gate Its expression is: ; in, and These are the weight matrices for the forget gate. This is the bias term for the forget gate. The forget gate is used to control the retention or discarding of historical information to optimize the storage and updating of time series information.

[0073] Next, calculate the candidate memory unit information at the current time. Its expression is: ; in, and This is the weight matrix for candidate memory units. Bias terms for candidate memory units, This is the hyperbolic tangent activation function. Candidate memory cells provide new information (including flow-driven features) that needs to be written at the current time step, used to update the memory cell state at the current time step.

[0074] Based on this, the state of the memory units at the current time step is updated by integrating the input gate, forget gate, and candidate memory units. Its expression is: ; in, This represents element-wise multiplication, used to introduce new information at the current moment while preserving important historical information.

[0075] The hidden state at the current time step updated by the above gating mechanism This can be understood as a high-dimensional dense feature vector formed by the model after comprehensively refining historical time series patterns and current traffic guidance information at this time step, which is used to establish a connection between the complex state inside the model and the final clear output.

[0076] Step S203: Input the hidden state vector into the fully connected output layer so that the hidden state vector is mapped to the total nitrogen concentration filling value through the fully connected output layer, thereby obtaining the total nitrogen concentration filling value sequence.

[0077] The hidden state vector output from the decoder is input into the fully connected output layer. This fully connected output layer performs a linear transformation on the hidden state vector, mapping the high-dimensional feature space to a one-dimensional filled value space. The expression for the linear transformation is: ; in, For the decoder at time step Output total nitrogen concentration fill value, and These represent the weight matrix and bias term of the fully connected output layer, respectively. The padding values ​​for all time steps are combined in chronological order to obtain the total nitrogen concentration padding value sequence. .

[0078] Thus, through the long-term memory capability of the LSTM gating mechanism, the model can generate filler values ​​that are consistent with the trend of real data and have complete details step by step.

[0079] In one feasible embodiment, step S30 may include steps S301 to S302: Step S301: Determine the range of total nitrogen concentration values ​​in the total nitrogen concentration sequence and the range of filler values ​​in the total nitrogen concentration filler value sequence; First, determine the numerical range of total nitrogen concentration in the total nitrogen concentration sequence and the numerical range of filler values ​​in the total nitrogen concentration filler value sequence. Specifically, iterate through all valid observations in the total nitrogen concentration sequence and select the smallest observation. and maximum observation This forms a range of total nitrogen concentration values. Iterate through all the filled values ​​in the total nitrogen concentration filled value sequence and filter out the smallest filled value. and maximum fill value This forms the range of fill values. This ensures that the determination of the numerical range covers all valid data, providing an accurate scale basis for linear mapping.

[0080] Step S302: Based on the numerical range of total nitrogen concentration and the numerical range of filler values, perform linear mapping processing on each filler value in the total nitrogen concentration filler value sequence so that each filler value and the observed value in the total nitrogen concentration sequence are in the same numerical range, thus obtaining the mapped filler value sequence.

[0081] Based on the determined range of total nitrogen concentration values ​​and the range of filled values, a linear mapping process is performed on each filled value in the total nitrogen concentration filled value sequence. The formula for the linear mapping is: ; in, and These are the minimum and maximum values ​​of the actual observations within the current window, respectively. and These are the minimum and maximum values ​​of the initial fill value of the model within this window, respectively. This represents the initial fill value of the model. This represents the filled value after a special linear mapping. This mapping aligns the model output to the statistical range of the real data, providing a unified scale basis for subsequent trend characterization and detail constraints.

[0082] Thus, the linear mapping process aligns the numerical range of the filled values ​​with that of the actual observed values, ensuring the rationality of the filled value distribution while fully preserving the details of local fluctuations in the filled value sequence. This effectively avoids filling errors caused by differences in numerical scales and improves the reliability of the filling results.

[0083] For example, to help understand the implementation process of the water quality monitoring data filling method obtained in this embodiment combined with the above embodiment one, please refer to... Figure 2 and Figure 3 , Figure 2 A simplified flowchart illustrating the water quality monitoring data entry method is provided. Figure 3 A schematic diagram of the training process for the data imputation model is provided, specifically: like Figure 2 As shown, firstly, the input sequence of the target water body is obtained, which includes flow rate, data acquisition time, and initial total nitrogen concentration data within a preset time window. Then, noise-reducing preprocessing is performed on the input sequence. The preprocessing operations may include sinusoidal time encoding, flow rate data standardization, and outlier truncation. After the above noise-reducing preprocessing, the preprocessed sequence (i.e., water quality characteristic dataset) is obtained. This sequence includes a time-coded sequence, a processed flow rate sequence, and a total nitrogen concentration sequence with missing values, and the three are aligned by timestamps.

[0084] Then, the preprocessed sequence is input into a total nitrogen concentration missing data imputation model based on flow-guided and trend-fidelity dual-path loss. First, it enters the flow-total nitrogen temporal co-encoder within the model, where the encoder encodes the temporal correlation features between the flow sequence and the total nitrogen concentration sequence. After encoding, the encoder outputs the final hidden state. and memory unit The input trend-fidelity driven filler decoder takes the encoder output state as its initial state and, combining the flow characteristics of the current time step with the hidden state of the previous time step, calculates the hidden state of the time step where the missing value is located step by step. Then hide the state. Input to a fully connected output layer to hide the state. The total nitrogen concentration is mapped to the total nitrogen concentration fill value at the corresponding time step. The fill values ​​of all time steps are combined in chronological order to obtain the initial total nitrogen concentration fill value sequence of the model.

[0085] Then, a special linear mapping is performed on each filler value in the initial total nitrogen concentration filler value sequence of the model to map the numerical range of the model filler values ​​to a reasonable range consistent with the numerical range of the actual observed values, resulting in a filler value sequence with aligned numerical ranges, i.e., a mapped filler value sequence. Finally, this filler value sequence is merged with the original actual total nitrogen concentration observation value sequence to obtain a target total nitrogen concentration sequence without missing values.

[0086] like Figure 3 As shown, firstly, the training samples are subjected to noise-reducing preprocessing to obtain the preprocessed sequence (i.e., historical water quality characteristic dataset). The total nitrogen concentration in this sequence is the true observation value without missing values. Subsequently, continuous or discrete missing segments need to be manually set in it to simulate the data missing scenario in actual monitoring.

[0087] The preprocessed sequence undergoes forward propagation and linear mapping. Specifically, firstly, a model for filling missing total nitrogen concentration data based on flow-guided and trend-fidelity dual-path loss is used. Through the forward propagation operation of the model (i.e., the encoder extracts temporal correlation features, the decoder calculates the hidden state vector, and the fully connected output layer generates filling values), the initial total nitrogen concentration filling value sequence (i.e., the training total nitrogen concentration filling value sequence) is obtained. This sequence is the initial filling result output by the model for the simulated missing segment. Then, each training filling value in this sequence is subjected to a special linear mapping to map the numerical range of the model filling values ​​to a reasonable range consistent with the numerical range of the actual observed values, resulting in a filling value sequence with aligned numerical ranges, i.e., the training mapped filling value sequence.

[0088] Then, the filling model is iteratively trained using a combined optimization objective consisting of a trend loss term and a fidelity loss term until the model converges. Specifically, the trend loss term is calculated based on the filled value sequence aligned with the numerical range and the actual total nitrogen concentration observation sequence. This loss value is used to constrain the overall evolution trend of the filled values. The loss value of the fidelity loss term is calculated based on the filled value sequence after numerical range alignment and the initial total nitrogen concentration filled sequence of the model. This loss value is used to constrain the model's ability to recover local details. Then, the two loss values ​​are weighted and summed to obtain the total loss. Then, based on this total loss, backpropagation and parameter updates are performed to update the learnable parameters of the model until the total loss is reached. To ensure stability, the model training process is completed.

[0089] Visual representation of data population results, such as Figure 4 As shown in the figure, the horizontal axis Time represents the time step, the vertical axis Transport of the lower line graph represents the water flow rate, the lower line graph represents the change of flow rate data within the time step range of 0~17500, the vertical axis TN of the upper line graph represents the total nitrogen concentration, RecostructedTN (reconstructed total nitrogen concentration) represents the total nitrogen concentration after data filling, and OriginTN (original total nitrogen concentration) represents the total nitrogen concentration with missing values.

[0090] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the water quality monitoring data filling method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0091] This application also provides a water quality monitoring data filling device. Please refer to... Figure 5 The water quality monitoring data filling device includes: The dataset acquisition module 10 is used to acquire the water quality feature dataset of the target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow sequence, and a total nitrogen concentration sequence with missing values; The data filling module 20 is used to input the water quality characteristic dataset into the pre-trained data filling model to obtain the total nitrogen concentration filling value sequence output by the data filling model. The data filling model is a model based on the encoder-decoder architecture of a long short-term memory network. The filling value mapping module 30 is used to perform linear mapping processing on each filling value in the total nitrogen concentration filling value sequence according to the total nitrogen concentration numerical range in the total nitrogen concentration sequence, so as to obtain the mapped filling value sequence. The sequence merging module 40 is used to merge the mapped fill value sequence and the total nitrogen concentration sequence to obtain the target total nitrogen concentration sequence.

[0092] Optionally, the dataset acquisition module 10 is also used for: Acquire flow rate data, total nitrogen concentration data, and data acquisition timestamps for the target water body within a preset time window; The flow rate data, total nitrogen concentration data, and data acquisition timestamps are sorted according to time order to obtain the initial flow rate sequence, initial total nitrogen concentration sequence, and timestamp sequence. Sine coding is performed on each timestamp in the timestamp sequence to obtain a time-coded sequence; The initial flow sequence is standardized to obtain a standardized flow sequence. Based on the quantile statistical algorithm, outliers in the standardized flow sequence and the initial total nitrogen concentration sequence are truncated to obtain the flow sequence and the total nitrogen concentration sequence, respectively. By integrating the time-coded sequence, flow rate sequence, and total nitrogen concentration sequence, a water quality characteristic dataset is obtained.

[0093] Optionally, the water quality monitoring data filling device also includes a model training module (not shown), which is used for: Obtain historical water quality characteristic datasets as training samples; The training samples are input into the initial data filling model to obtain the training total nitrogen concentration filling value sequence; The mixed loss function is calculated based on the training total nitrogen concentration filled value sequence and the real total nitrogen concentration observed value sequence to obtain the mixed loss value. The timestamp of each observation in the real total nitrogen concentration observed value sequence corresponds to the timestamp of each training filled value in the training total nitrogen concentration filled value sequence. The mixed loss function includes a trend loss term function and a fidelity loss term function. The parameters of the initial data imputation model are iteratively updated based on the mixed loss value to obtain the trained data imputation model.

[0094] Optionally, the model training module is also used for: Based on the range of total nitrogen concentration values ​​in the actual total nitrogen concentration observation sequence, each training filler value in the training total nitrogen concentration filler value sequence is linearly mapped to obtain the training mapped filler value sequence. Calculate the first mean square error between the training mapping filled value sequence and the actual total nitrogen concentration observation value sequence, and use the first mean square error as the trend loss value; Calculate the second mean square error between the training mapping filled value sequence and the training total nitrogen concentration filled value sequence, and use the second mean square error as the fidelity loss value; The mixed loss value is obtained by weighted summing of the trend loss value and the fidelity loss value.

[0095] Optionally, the data padding model includes an encoder, a decoder, and a fully connected output layer; the data padding module 20 is also used for: The water quality feature dataset is input into the encoder to extract the temporal correlation features between the flow rate sequence and the total nitrogen concentration sequence. The temporal correlation features are input into the decoder so that the decoder can calculate the hidden state vector of the time step where the missing value is located based on the temporal correlation features; The hidden state vector is input to the fully connected output layer, so that the hidden state vector is mapped to the total nitrogen concentration filling value through the fully connected output layer, and the total nitrogen concentration filling value sequence is obtained.

[0096] Optionally, the fill value mapping module 30 is also used for: Determine the range of total nitrogen concentration values ​​in the total nitrogen concentration sequence and the range of filler values ​​in the total nitrogen concentration filler value sequence; Based on the numerical range of total nitrogen concentration and the numerical range of filler values, a linear mapping process is performed on each filler value in the total nitrogen concentration filler value sequence so that each filler value is in the same numerical range as the observed value in the total nitrogen concentration sequence, thus obtaining the mapped filler value sequence.

[0097] The water quality monitoring data filling device provided in this application, employing the water quality monitoring data filling method described in the above embodiments, can improve the accuracy of water quality monitoring data filling. Compared with the prior art, the beneficial effects of the water quality monitoring data filling device provided in this application are the same as those of the water quality monitoring data filling method described in the above embodiments, and other technical features in the water quality monitoring data filling device are the same as those disclosed in the water quality monitoring data filling method described in the above embodiments, and will not be repeated here.

[0098] This application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the water quality monitoring data filling method in the first embodiment described above.

[0099] The following is for reference. Figure 6 The diagram illustrates a structural schematic of an electronic device suitable for implementing embodiments of this application. The electronic devices in these embodiments may include, but are not limited to, mobile terminals such as laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0100] like Figure 6 As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. The communication device 1009 allows the electronic device to exchange data with other devices wirelessly or via wired communication. Although the diagrams show electronic devices with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented alternatively.

[0101] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0102] The electronic device provided in this application, employing the water quality monitoring data filling method described in the above embodiments, can improve the accuracy of water quality monitoring data filling. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the water quality monitoring data filling method described in the above embodiments, and other technical features of the electronic device are the same as those disclosed in the water quality monitoring data filling method of the previous embodiment, and will not be repeated here.

[0103] It should be understood that the various parts disclosed in the embodiments of this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0104] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0105] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the water quality monitoring data filling method described above.

[0106] The computer-readable storage medium provided in this application embodiment may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0107] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.

[0108] The aforementioned computer-readable storage medium carries one or more programs, which, when executed by an electronic device, cause the electronic device to: acquire a water quality feature dataset of a target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow sequence, and a total nitrogen concentration sequence with missing values; input the water quality feature dataset into a pre-trained data imputation model to obtain a total nitrogen concentration imputation value sequence output by the data imputation model, wherein the data imputation model is a model based on an encoder-decoder architecture of a long short-term memory network; perform linear mapping processing on each imputation value in the total nitrogen concentration imputation value sequence according to the total nitrogen concentration value range in the total nitrogen concentration sequence to obtain a mapped imputation value sequence; and merge the mapped imputation value sequence and the total nitrogen concentration sequence to obtain the target total nitrogen concentration sequence.

[0109] Computer program code for performing the operations of the embodiments of this application can be written in one or more programming languages ​​or a combination thereof. These programming languages ​​include object-oriented programming languages—such as Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0110] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0111] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0112] The readable storage medium provided in this application embodiment is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described water quality monitoring data filling method, which can improve the accuracy of water quality monitoring data filling. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application embodiment are the same as the beneficial effects of the water quality monitoring data filling method provided in the above embodiments, and will not be repeated here.

[0113] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the water quality monitoring data filling method described above.

[0114] The computer program product provided in this application can improve the accuracy of water quality monitoring data filling. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the water quality monitoring data filling method provided in the above embodiments, and will not be repeated here.

[0115] The above are only some embodiments of this application and do not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for filling water quality monitoring data, characterized in that, The water quality monitoring data filling method includes: Obtain a water quality feature dataset of the target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow rate sequence, and a total nitrogen concentration sequence with missing values; The water quality feature dataset is input into a pre-trained data imputation model to obtain a sequence of total nitrogen concentration imputation values ​​output by the data imputation model. The data imputation model is a model based on an encoder-decoder architecture of a long short-term memory network. Based on the total nitrogen concentration range in the total nitrogen concentration sequence, each filler value in the total nitrogen concentration filler value sequence is linearly mapped to obtain the mapped filler value sequence. The mapped fill value sequence and the total nitrogen concentration sequence are merged to obtain the target total nitrogen concentration sequence.

2. The water quality monitoring data filling method as described in claim 1, characterized in that, The step of obtaining the water quality feature dataset of the target water body includes: Acquire flow rate data, total nitrogen concentration data, and data acquisition timestamps for the target water body within a preset time window; The flow data, total nitrogen concentration data, and data acquisition timestamps are sorted according to time order to obtain an initial flow sequence, an initial total nitrogen concentration sequence, and a timestamp sequence. Sine coding is performed on each of the timestamps in the timestamp sequence to obtain the timestamp coding sequence; The initial flow sequence is standardized to obtain a standardized flow sequence; Based on the quantile statistics algorithm, outliers in the standardized flow sequence and the initial total nitrogen concentration sequence are truncated to obtain the flow sequence and the total nitrogen concentration sequence, respectively. The time-coded sequence, the flow rate sequence, and the total nitrogen concentration sequence are integrated to obtain a water quality characteristic dataset.

3. The water quality monitoring data filling method as described in claim 1, characterized in that, Before the step of inputting the water quality feature dataset into a pre-trained data imputation model to obtain the total nitrogen concentration imputation value sequence output by the data imputation model, the method further includes: Obtain historical water quality characteristic datasets as training samples; The training samples are input into the initial data filling model to obtain a training total nitrogen concentration filling value sequence; The mixed loss function is calculated based on the training total nitrogen concentration filled value sequence and the real total nitrogen concentration observed value sequence to obtain the mixed loss value. The timestamp of each observation in the real total nitrogen concentration observed value sequence corresponds to the timestamp of each training filled value in the training total nitrogen concentration filled value sequence. The mixed loss function includes a trend loss term function and a fidelity loss term function. The parameters of the initial data imputation model are iteratively updated based on the mixed loss value to obtain the trained data imputation model.

4. The water quality monitoring data filling method as described in claim 3, characterized in that, The step of calculating the mixed loss function based on the training total nitrogen concentration filled value sequence and the real total nitrogen concentration observation value sequence to obtain the mixed loss value includes: Based on the total nitrogen concentration range in the real total nitrogen concentration observation value sequence, each training fill value in the training total nitrogen concentration fill value sequence is linearly mapped to obtain the training mapped fill value sequence. Calculate the first mean square error between the training mapping filled value sequence and the real total nitrogen concentration observation value sequence, and use the first mean square error value as the trend loss value; Calculate the second mean square error between the training mapping filled value sequence and the training total nitrogen concentration filled value sequence, and use the second mean square error as the fidelity loss value; The trend loss value and the fidelity loss value are weighted and summed to obtain the mixed loss value.

5. The water quality monitoring data filling method as described in claim 1, characterized in that, The data padding model includes an encoder, a decoder, and a fully connected output layer; The step of inputting the water quality feature dataset into a pre-trained data imputation model to obtain the total nitrogen concentration imputation value sequence output by the data imputation model includes: The water quality feature dataset is input into the encoder to extract the temporal correlation features between the flow rate sequence and the total nitrogen concentration sequence. The temporal correlation features are input into the decoder so that the decoder can calculate the hidden state vector of the time step in which the missing value is located based on the temporal correlation features. The hidden state vector is input to the fully connected output layer, so that the hidden state vector is mapped to the total nitrogen concentration filling value through the fully connected output layer, thereby obtaining the total nitrogen concentration filling value sequence.

6. The water quality monitoring data filling method as described in claim 1, characterized in that, The step of performing linear mapping processing on each filler value in the total nitrogen concentration filler value sequence according to the total nitrogen concentration value range in the total nitrogen concentration sequence to obtain the mapped filler value sequence includes: Determine the range of total nitrogen concentration values ​​in the total nitrogen concentration sequence and the range of filler values ​​in the total nitrogen concentration filler value sequence; Based on the total nitrogen concentration range and the filler value range, a linear mapping process is performed on each filler value in the total nitrogen concentration filler value sequence so that each filler value and the observed value in the total nitrogen concentration sequence are in the same numerical range, thus obtaining a mapped filler value sequence.

7. A water quality monitoring data filling device, characterized in that, The water quality monitoring data filling device includes: The dataset acquisition module is used to acquire the water quality feature dataset of the target water body, wherein the water quality feature dataset includes a time-coded sequence, a flow sequence, and a total nitrogen concentration sequence with missing values; The data filling module is used to input the water quality feature dataset into a pre-trained data filling model to obtain a sequence of total nitrogen concentration filling values ​​output by the data filling model. The data filling model is a model based on an encoder-decoder architecture of a long short-term memory network. The filling value mapping module is used to perform linear mapping processing on each filling value in the total nitrogen concentration filling value sequence according to the total nitrogen concentration numerical range in the total nitrogen concentration sequence, so as to obtain a mapped filling value sequence. The sequence merging module is used to merge the mapped fill value sequence and the total nitrogen concentration sequence to obtain the target total nitrogen concentration sequence.

8. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the water quality monitoring data filling method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the water quality monitoring data filling method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the water quality monitoring data filling method as described in any one of claims 1 to 6.