Tap water residual chlorine prediction method and device based on deep learning and storage medium

Through a deep learning-based method, combining time-series data embedding mapping and periodic characterization vectors, the tap water residual chlorine prediction algorithm is optimized, which solves the problem that existing methods are difficult to consider the timing and periodicity of residual chlorine data, and improves the accuracy and reliability of prediction.

CN119539088AInactive Publication Date: 2025-02-28WUXI HUA YAN WATER
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510088856.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-02-28
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing tap water residual chlorine prediction methods are difficult to effectively consider the timing and periodicity of residual chlorine data, resulting in a large deviation from the actual situation.

Method used

Using a deep learning-based method, the mapping operator and prediction analysis operator are embedded in time-series data, combined with the first and second periodic characterization vectors, the basic residual chlorine prediction algorithm is debugged and optimized to generate the target residual chlorine prediction algorithm.

Benefits of technology

The accuracy of the prediction of residual chlorine in tap water is improved, the timing and periodicity of the data are fully taken into account, and the reliability of the prediction results is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119539088A_ABST
    Figure CN119539088A_ABST
Patent Text Reader

Abstract

The invention provides a tap water residual chlorine prediction method and device based on deep learning and a storage medium, and the method comprises the steps: in an algorithm debugging process, obtaining a time sequence representation vector of tap water residual chlorine detection training data for adjusting a basic residual chlorine prediction algorithm, obtaining time sequence reasoning data corresponding to the time sequence representation vector, and carrying out the calculation of the time sequence reasoning data; and generating a first periodic representation vector and a second periodic representation vector according to the time sequence representation vector and the time sequence reasoning data, and determining an overall debugging evaluation index of the basic residual chlorine prediction algorithm through the time sequence representation vector, the time sequence reasoning data, the first periodic representation vector and the second periodic representation vector. Therefore, the basic residual chlorine prediction algorithm is debugged. According to the method, a debugging mode is carried out by adopting a time sequence and periodicity fusion mode, the time sequence and periodicity of tap water residual chlorine detection training data are fully considered, and an overall debugging evaluation index for carrying out comprehensive debugging on a basic residual chlorine prediction algorithm is obtained, so that tap water residual chlorine data in a predefined time period can be accurately obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method, device and storage medium for predicting residual chlorine in tap water based on deep learning. Background Art

[0002] Tap water is an indispensable resource in people's daily life and industrial production. In the monitoring and management of tap water quality, residual chlorine content is a crucial indicator. Accurately predicting the residual chlorine content of tap water is of great significance to the production operation and water quality management of the water plant. By predicting the residual chlorine content of tap water, the water plant can adjust the disinfection process parameters in time to ensure that the residual chlorine content of tap water remains within an appropriate range, thereby ensuring the safety of tap water quality.

[0003] At present, some traditional methods have been widely used in the field of residual chlorine prediction in tap water. For example, based on statistical methods, by statistically analyzing historical residual chlorine detection data, a mathematical model is established to predict future residual chlorine content. However, these traditional methods often have some limitations. They usually only consider the simple statistical characteristics of residual chlorine data, while ignoring the timing and periodicity of residual chlorine data. The residual chlorine content of tap water is affected by many factors, such as water source water quality, disinfection process, water demand, etc. These factors have certain regularity and periodicity in time. If these characteristics are not taken into account, the prediction results may deviate greatly from the actual situation. The existing methods for predicting residual chlorine in tap water have deficiencies in considering data characteristics, processing complex data, and algorithm debugging and evaluation, and it is difficult to meet the needs of water plants for accurate prediction of residual chlorine content. Summary of the invention

[0004] In view of this, the present application provides a method, device and storage medium for predicting residual chlorine in tap water based on deep learning. The technical solution of the present application is implemented as follows: On the one hand, the present application provides a method for predicting residual chlorine in tap water based on deep learning, comprising: obtaining historical detection data of residual chlorine in tap water, predicting the historical detection data of residual chlorine in tap water based on a target residual chlorine prediction algorithm, and obtaining a prediction result of residual chlorine in tap water. The debugging process of the target residual chlorine prediction algorithm comprises: obtaining a basic residual chlorine prediction algorithm and a plurality of tap water residual chlorine detection training data, wherein the plurality of tap water residual chlorine detection training data are initial time series training data obtained by uninterrupted sparse extraction of initial tap water residual chlorine detection data; loading the plurality of tap water residual chlorine detection training data into the time series data embedding mapping operator of the basic residual chlorine prediction algorithm to obtain a plurality of time series representation vectors, wherein the time series representation vectors are used to describe the historical dependency of the tap water residual chlorine detection training data; loading the plurality of time series representation vectors into the prediction vector of the basic residual chlorine prediction algorithm; An analysis operator is used to obtain multiple time series reasoning data, and the prediction analysis operator is used to perform data fitting according to the time series characterization vector; multiple first periodic characterization vectors are generated according to the multiple tap water residual chlorine detection training data, and multiple second periodic characterization vectors are generated according to the multiple time series reasoning data; the overall debugging evaluation index of the basic residual chlorine prediction algorithm is obtained through the multiple time series characterization vectors, the multiple time series reasoning data, the multiple first periodic characterization vectors, and the multiple second periodic characterization vectors; when the overall debugging evaluation index meets the debugging stop requirement, the target residual chlorine prediction algorithm is obtained.

[0005] In a second aspect, the present application provides a tap water residual chlorine prediction device, comprising: A data acquisition module is used to obtain historical detection data of residual chlorine in tap water; The algorithm calling module is used to load the historical detection data of residual chlorine in tap water into the debugged converged target residual chlorine prediction algorithm, predict the historical detection data of residual chlorine in tap water based on the target residual chlorine prediction algorithm, and obtain the prediction result of residual chlorine in tap water.

[0006] The target residual chlorine prediction algorithm is obtained by debugging the basic residual chlorine prediction algorithm, and the debugging process of the basic residual chlorine prediction algorithm includes: obtaining a basic residual chlorine prediction algorithm and a plurality of tap water residual chlorine detection training data, wherein the plurality of tap water residual chlorine detection training data are initial time series training data obtained by uninterrupted sparse extraction of initial tap water residual chlorine detection data, and the basic residual chlorine prediction algorithm is configured to predict the tap water residual chlorine data of a predefined time period based on the tap water residual chlorine historical detection data; loading the plurality of tap water residual chlorine detection training data into the time series data embedding mapping operator of the basic residual chlorine prediction algorithm to obtain a plurality of time series representation vectors, wherein the time series data embedding mapping operator is used to perform data embedding mapping on the tap water residual chlorine detection training data, and the time series representation vector is used to describe the historical dependency of the tap water residual chlorine detection training data; loading the plurality of time series representation vectors into the prediction of the basic residual chlorine prediction algorithm; A prediction analysis operator is used to obtain a plurality of time series reasoning data, wherein the prediction analysis operator is used to perform data fitting according to the time series characterization vector; a plurality of first periodic characterization vectors are generated according to the plurality of tap water residual chlorine detection training data, and a plurality of second periodic characterization vectors are generated according to the plurality of time series reasoning data, wherein the first periodic characterization vector is used to describe the periodic distribution intensity of the tap water residual chlorine detection training data, and the second periodic characterization vector is used to describe the periodic distribution intensity of the time series reasoning data; an overall debugging evaluation index of the basic residual chlorine prediction algorithm is obtained through the plurality of time series characterization vectors, the plurality of time series reasoning data, the plurality of first periodic characterization vectors, and the plurality of second periodic characterization vectors, wherein the overall debugging evaluation index is used to evaluate the debugging status of the basic residual chlorine prediction algorithm; when the overall debugging evaluation index meets the debugging stop requirement, the target residual chlorine prediction algorithm is obtained.

[0007] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above-described method when executed by a processor.

[0008] In the process of algorithm debugging, the present application obtains the time series representation vector of the tap water residual chlorine detection training data for adjusting the basic residual chlorine prediction algorithm through the time series data embedding mapping operator, obtains the time series reasoning data corresponding to the time series representation vector through the prediction analysis operator, and generates the first periodic representation vector and the second periodic representation vector respectively according to the time series representation vector and the time series reasoning data, and then determines the overall debugging evaluation index of the basic residual chlorine prediction algorithm through the time series representation vector, the time series reasoning data, the first periodic representation vector and the second periodic representation vector, so as to debug the basic residual chlorine prediction algorithm. The method of debugging by integrating time series and periodicity fully considers the time series and periodicity of the tap water residual chlorine detection training data, and obtains the overall debugging evaluation index for comprehensive debugging of the basic residual chlorine prediction algorithm. Based on this, the accuracy of the time series reasoning data predicted by the target residual chlorine prediction algorithm is higher, which improves the debugging effect of the basic residual chlorine prediction algorithm, and then accurately obtains the tap water residual chlorine data of the predefined time period. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0010] Figure 1 A schematic diagram of the implementation flow of a method for predicting residual chlorine in tap water based on deep learning provided in an embodiment of the present application; Figure 2 A schematic diagram of the composition structure of a tap water residual chlorine prediction device provided in an embodiment of the present application; Figure 3 A hardware entity diagram of a computer system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0011] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0012] The embodiment of the present application provides a method for predicting residual chlorine in tap water based on deep learning, which can be executed by a processor of a computer system, wherein the computer system can refer to a device with data processing capabilities such as a server, a laptop, a tablet computer, and a desktop computer.

[0013] Figure 1 A schematic diagram of the implementation flow of a method for predicting residual chlorine in tap water based on deep learning provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes: Step S100: Obtain historical detection data of residual chlorine in tap water, and load the historical detection data of residual chlorine in tap water into the debugged converged target residual chlorine prediction algorithm, predict the historical detection data of residual chlorine in tap water based on the target residual chlorine prediction algorithm, and obtain the prediction result of residual chlorine in tap water.

[0014] The historical test data of residual chlorine in tap water is the actual test record of the residual chlorine content in tap water in the past period of time, which is the basis for subsequent predictions. For example, in a tap water supply system, the test personnel may test the residual chlorine content of tap water at regular intervals (such as every hour) and record these test data. Assume that in the past week, there are corresponding residual chlorine content test values ​​at different times such as 8 o'clock, 10 o'clock, and 12 o'clock every day. These test values ​​constitute the historical test data of residual chlorine in tap water. These data can be stored in a database, and the computer system obtains these historical test data from the database through database query statements (such as SQL statements).

[0015] After obtaining the historical test data of residual chlorine in tap water, the computer system loads these data into the debugged converged target residual chlorine prediction algorithm. The target residual chlorine prediction algorithm is an algorithm that has been debugged and optimized. It is obtained by performing a series of debugging operations on the basic residual chlorine prediction algorithm and can more accurately predict the residual chlorine data of tap water.

[0016] Based on the target residual chlorine prediction algorithm, the loaded tap water residual chlorine historical detection data is predicted, which may specifically include: before the data is input into the target residual chlorine prediction algorithm, the data may be preprocessed to ensure that the quality and format of the data meet the requirements of the algorithm. The preprocessing operation may include data cleaning, data normalization, etc. Afterwards, the target residual chlorine prediction algorithm may extract features from the input tap water residual chlorine historical detection data to obtain more representative feature information. These features may include time features, historical residual chlorine content features, etc. For example, the time feature may represent the data collection time, such as year, month, date, hour, etc.; the historical residual chlorine content feature may include statistical information such as the average value and standard deviation of the residual chlorine content over a period of time. The computer system can extract these features by writing code. For example, in Python, the pandas library can be used to process time series data and calculate related statistical features. After preprocessing and feature extraction, the computer system inputs the processed data into the model of the target residual chlorine prediction algorithm for prediction. The model of the target residual chlorine prediction algorithm may be a neural network model based on deep learning, such as a long short-term memory network (LSTM), a gated recurrent unit (GRU), etc. These models have powerful time series processing capabilities and can learn the time series rules of tap water residual chlorine data. Taking the LSTM model as an example, it controls the flow of information through a gating mechanism to effectively process long sequence data. During the prediction process, the LSTM model calculates the predicted value for the next moment based on the input historical data and the current state information. After the model prediction, the computer system obtains the prediction results of tap water residual chlorine. These prediction results represent the residual chlorine content of tap water within a predefined time period. For example, predict the residual chlorine content of tap water every 1 hour in the next 24 hours. The prediction results can be output in the form of numerical values ​​or displayed in the form of charts, so that users can more intuitively understand the changing trend of residual chlorine content.

[0017] As an implementation scheme, the target residual chlorine prediction algorithm described above in the embodiment of the present application is obtained by debugging the basic residual chlorine prediction algorithm. The basic residual chlorine prediction algorithm debugging process includes: Step S10: Obtain a basic residual chlorine prediction algorithm and multiple tap water residual chlorine detection training data, wherein the multiple tap water residual chlorine detection training data are initial time series training data obtained by uninterrupted sparse extraction of initial tap water residual chlorine detection data, and the basic residual chlorine prediction algorithm is configured to predict the tap water residual chlorine data of a predefined time period based on the tap water residual chlorine historical detection data.

[0018] In step S10, the computer system obtains a basic residual chlorine prediction algorithm. The basic residual chlorine prediction algorithm is an algorithm model for predicting tap water residual chlorine data, which is configured to predict tap water residual chlorine data for a predefined time period based on tap water residual chlorine historical detection data. A feasible basic residual chlorine prediction algorithm can be a statistical-based method, such as linear regression, time series analysis, etc., or a machine learning or deep learning-based method, such as a neural network, a support vector machine, etc. For example, in a deep learning-based method, a long short-term memory network (LSTM) can be used as a basic residual chlorine prediction algorithm. LSTM is a special recurrent neural network that can effectively process temporal information in long sequence data, and control the flow and memory of information through a gating mechanism, thereby better capturing the time dependency of tap water residual chlorine data.

[0019] After obtaining the basic residual chlorine prediction algorithm, the computer system obtains a plurality of tap water residual chlorine detection training data, which are initial time series training data obtained by continuously sparsely extracting the initial tap water residual chlorine detection data.

[0020] The initial tap water residual chlorine test data is obtained by actually testing the residual chlorine content of tap water in the tap water supply system through professional testing equipment and methods. These data are usually collected at certain time intervals, such as every 1 hour, 2 hours or other fixed time intervals. For example, in a city's tap water plant, testers will regularly collect water samples from different water supply areas, and use residual chlorine testing instruments to test the residual chlorine content in the water samples, and record the residual chlorine content value at each sampling time. These data constitute the initial tap water residual chlorine test data.

[0021] Continuous sparse extraction is a method of selecting part of the data from the original data. The purpose is to reduce the amount of data and improve the efficiency of data processing while maintaining the main characteristics and laws of the data. When obtaining the training data for residual chlorine detection in tap water, the computer system performs continuous sparse extraction on the initial tap water residual chlorine detection data. Specifically, according to certain rules or algorithms, a part of representative data points are selected from the initial data to form new time series training data. For example, the method of equal interval sampling can be used to select a data point at a certain time interval; or data points can be selected when the change amplitude of the data exceeds a certain threshold according to the change of the data. Assuming that the initial tap water residual chlorine detection data records the residual chlorine content value every 10 minutes, after continuous sparse extraction, the residual chlorine content data every 30 minutes or 1 hour can be obtained as training data.

[0022] In the specific implementation, professional residual chlorine detection equipment can be installed in the tap water supply system to obtain the initial tap water residual chlorine detection data. These devices can monitor the residual chlorine content of tap water in real time and transmit the detection data to the computer system. Viable residual chlorine detection equipment includes residual chlorine analyzers, residual chlorine sensors, etc., which are based on different detection principles (such as colorimetry, electrochemical method, etc.) to accurately measure the residual chlorine content in water.

[0023] The computer system uses data storage and management tools to save the initial tap water residual chlorine test data and the processed training data. You can choose a relational database (such as MySQL, Oracle, etc.) or a non-relational database (such as MongoDB, Redis, etc.) to store data. The database can provide efficient data storage and query functions, making it easier for the computer system to manage and operate data.

[0024] Before performing uninterrupted sparse extraction, the computer system can preprocess the initial tap water residual chlorine test data to remove interference factors such as noise and outliers. When the computer system performs uninterrupted sparse extraction on the initial tap water residual chlorine test data, in addition to the equal-interval sampling method mentioned above, it can also use methods based on information entropy and clustering methods. The information entropy-based method evaluates the importance of data points by calculating their information entropy and selects data points with larger information entropy as training data; the clustering-based method clusters the data points and then selects representative data points from each cluster.

[0025] Step S20: Load multiple tap water residual chlorine detection training data into the time series data embedding mapping operator of the basic residual chlorine prediction algorithm to obtain multiple time series representation vectors, wherein the time series data embedding mapping operator is used to perform data embedding mapping on the tap water residual chlorine detection training data, and the time series representation vector is used to describe the historical dependency of the tap water residual chlorine detection training data.

[0026] After obtaining multiple tap water residual chlorine detection training data, the computer system loads these data into the time series data embedding mapping operator of the basic residual chlorine prediction algorithm. The time series data embedding mapping operator is a component of the basic residual chlorine prediction algorithm. Its main function is to perform data embedding mapping operations on the input tap water residual chlorine detection training data. The purpose of this operation is to convert the original data that may have complex structures and characteristics into a form that is more suitable for algorithm processing and analysis, that is, to obtain a time series representation vector that can effectively describe the data characteristics. Data embedding mapping is to map the data from the original high-dimensional space to a low-dimensional vector space while retaining the important information and characteristics of the data. In the processing of tap water residual chlorine detection training data, the computer system learns the inherent structure and rules in the data through the time series data embedding mapping operator, and encodes the characteristic information of each data point into a low-dimensional vector, which is the time series representation vector. For example, suppose the training data for residual chlorine detection in tap water contains multiple feature dimensions such as residual chlorine content, water temperature, and pH value. After time series data embedding and mapping, these feature information is integrated into a fixed-dimensional time series representation vector, such as a 10-dimensional vector.

[0027] The obtained time series representation vector is used to describe the historical dependency of the tap water residual chlorine detection training data, that is, the degree of correlation between the current value and the past value, that is, the time series characteristics. For example, in the process of changes in the residual chlorine content of tap water, the residual chlorine content at the current moment may be related to factors such as the residual chlorine content, water temperature, and pH value in the past few hours or even days. The time series representation vector can capture this historical dependency information and provide an important basis for subsequent predictive analysis. Specifically, each element in the vector may represent the degree of influence of historical information on different time scales on the current data. For example, the first element in the vector may represent the impact of historical data in the last 1 hour on the current residual chlorine content, the second element may represent the impact of historical data in the last 3 hours, and so on.

[0028] To better understand this process, we can give a simple example. Suppose there is a set of training data for tap water residual chlorine detection, which records the residual chlorine content, water temperature, and pH value every 1 hour for 10 consecutive days. At a certain time t, the residual chlorine content is 0.5 mg / L, the water temperature is 20°C, and the pH value is 7.5. The computer system inputs this data into the time series data embedding mapping operator, which maps this information into a 5-dimensional time series representation vector [0.2, 0.3, 0.1, 0.4, 0.5] by learning the patterns and rules of historical data. Among them, the first element 0.2 may represent the degree of influence of the change in residual chlorine content in the past 1 hour on the current moment, the second element 0.3 may represent the degree of influence of the change in water temperature in the past 3 hours, the third element 0.1 represents the degree of influence of the change in pH value in the past 6 hours, the fourth element 0.4 represents the comprehensive impact of the overall data changes in the past 12 hours, and the fifth element 0.5 represents the long-term trend impact of the data in the past 24 hours.

[0029] In order to implement the data embedding and mapping operation in step S20, the computer system may adopt the following technical means: For example, based on the embedding layer in deep learning. In the field of deep learning, a feasible method is to use the embedding layer to realize the embedding mapping of data. The embedding layer can be regarded as a fully connected layer, which maps the input discrete or continuous data into a low-dimensional vector space. When processing the training data of tap water residual chlorine detection, the computer system can take the residual chlorine content, water temperature, pH value and other features as input, and map them into a time series representation vector through the embedding layer. The parameters of the embedding layer can be learned and optimized through the training process to adapt to the characteristics of the data and task requirements.

[0030] Alternatively, it can be implemented based on an autoencoder. An autoencoder is an unsupervised learning model, which consists of two parts: an encoder and a decoder. The encoder compresses the input data into a low-dimensional representation, namely a coding vector; the decoder restores the coding vector back to the original data. In step S20, the computer system can use an autoencoder to learn the feature representation of the tap water residual chlorine detection training data, and encode the input data into a time series representation vector. The training goal of the autoencoder is to minimize the difference between the input data and the reconstructed data, and by continuously adjusting the model parameters, the encoder can learn the effective feature representation of the data.

[0031] Alternatively, it can be implemented based on a recurrent neural network (RNN). Recurrent neural networks (RNN) and their variants (such as long short-term memory networks LSTM, gated recurrent units GRU, etc.) have the ability to process sequence data and capture the temporal dependencies in the data. Computer systems can use RNN and its variants to construct time series data embedding mapping operators. During the training process, RNN continuously updates the hidden state based on the information of historical data, thereby learning the temporal characteristics of the data and mapping it into a temporal representation vector.

[0032] Step S30: Loading multiple time series characterization vectors into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain multiple time series reasoning data, wherein the prediction analysis operator is used to perform data fitting according to the time series characterization vectors.

[0033] The prediction analysis operator is a key component of the basic residual chlorine prediction algorithm. Its main function is to perform data fitting based on the input time series representation vector. Data fitting is the process of approximating known data by building a mathematical model. In this process, the prediction analysis operator will learn the patterns and rules in the time series representation vector, thereby predicting and inferring future data and obtaining the corresponding time series reasoning data.

[0034] After obtaining multiple time series representation vectors, the computer system loads these vectors one by one or in batches into the prediction analysis operator. The prediction analysis operator will analyze and process these vectors to mine the information contained in them. For example, assuming that the dimension of the time series representation vector is 5, each dimension represents the degree of influence of historical information on different time scales on current data. The prediction analysis operator can build a suitable mathematical model for data fitting by learning the relationship between these dimensions and their changing trends over time.

[0035] Specifically, the predictive analysis operator can be implemented by linear fitting, polynomial fitting, nonlinear fitting, etc. Linear fitting assumes that there is a linear relationship between the data, and finds the best straight line to fit the data through methods such as the least squares method; polynomial fitting uses polynomial functions to approximate the data; nonlinear fitting is suitable for situations where there are complex nonlinear relationships between the data, and usually requires the use of more complex models and optimization algorithms.

[0036] For example, suppose there is a set of simple time series representation vector data. Suppose that within a certain period of time, three time series representation vectors are obtained, namely vector A = [0.2, 0.3, 0.1, 0.4, 0.5], vector B = [0.3, 0.4, 0.2, 0.5, 0.6], and vector C = [0.4, 0.5, 0.3, 0.6, 0.7]. The computer system loads these vectors into the prediction analysis operator.

[0037] The predictive analysis operator first analyzes the characteristics and patterns of these vectors. For example, it may find that the elements in the vector show a certain increasing trend over time, and there is a certain correlation between different dimensions. Then, the predictive analysis operator can choose a suitable fitting method, such as linear fitting. Assume that through linear fitting, the fitting function obtained is y=ax+b, where x represents time, y represents the predicted residual chlorine content, and a and b are parameters obtained by fitting calculation.

[0038] For vector A, the prediction analysis operator takes its elements as input and calculates the corresponding time series reasoning data according to the fitting function. For example, the predicted value of the residual chlorine content at a certain time t1 in the future is calculated to be 0.6 mg / L, which is a time series reasoning data. Similarly, for vectors B and C, the corresponding time series reasoning data are also calculated through the fitting function, such as 0.7 mg / L and 0.8 mg / L at time t1 respectively.

[0039] In order to achieve the functions of data fitting and obtaining time series reasoning data in step S30, as an implementation method, the computer system can use regression analysis, which is a feasible statistical analysis method for studying the relationship between variables. In step S30, the computer system can use regression analysis to establish a relationship model between the time series representation vector and the time series reasoning data. For example, linear regression can determine the best fitting line by minimizing the sum of squared errors between the predicted value and the actual value; multivariate regression can handle the relationship between multiple independent variables (i.e., multiple dimensions of the time series representation vector) and the dependent variable (i.e., the time series reasoning data).

[0040] Alternatively, in addition to traditional regression analysis methods, computer systems can also use various machine learning algorithms to fit and predict data. For example, support vector machines (SVMs) can find an optimal hyperplane to divide data, thereby achieving data classification and regression; decision tree algorithms can build decision tree models based on data characteristics to classify and predict data; neural networks have powerful nonlinear fitting capabilities and can learn complex patterns and rules in data.

[0041] Since the residual chlorine test data of tap water is time series data, the computer system can also use special time series analysis methods to perform data fitting and prediction. For example, the autoregressive moving average model (ARMA) and the autoregressive integrated moving average model (ARIMA) are feasible time series prediction models, which establish prediction models by analyzing the autocorrelation and partial autocorrelation of data; the seasonal autoregressive integrated moving average model (SARIMA) is suitable for time series data with seasonal characteristics.

[0042] Step S40: Generate multiple first periodic characterization vectors based on multiple tap water residual chlorine detection training data, and generate multiple second periodic characterization vectors based on multiple time series reasoning data, wherein the first periodic characterization vector is used to describe the periodic distribution intensity of the tap water residual chlorine detection training data, and the second periodic characterization vector is used to describe the periodic distribution intensity of the time series reasoning data.

[0043] The computer system analyzes a plurality of tap water residual chlorine detection training data to generate a plurality of first periodic characterization vectors. The periodic distribution intensity refers to the degree of periodic change of the data in the time series. For example, the residual chlorine content of tap water can be affected by factors such as season, day and night, and present a certain periodic change pattern.

[0044] In order to generate the first periodic characterization vector, the computer system can use a variety of technical means. One way is to analyze the frequency components of the data through Fourier transform. Fourier transform is a mathematical method that converts time domain signals into frequency domain signals. It can decompose a time series into a superposition of sine and cosine functions of different frequencies. The specific formula is as follows: For a discrete time series x[n], its discrete Fourier transform (DFT) is: ; Where N is the length of the time series, k represents the frequency index, and j is the imaginary unit. By performing Fourier transform on the training data of residual chlorine detection in tap water, the computer system can obtain the amplitude and phase information of the data at different frequencies. Frequency components with larger amplitudes usually correspond to periodic features in the data.

[0045] For example, suppose the training data for residual chlorine detection in tap water records the residual chlorine content for each month of the year. After the computer system performs Fourier transform on these data, it is found that the amplitude of the frequency 1 / 12 (corresponding to a period of 12 months) is large, which indicates that there is an obvious annual periodic change in the residual chlorine content. Based on the information of these frequency components, the computer system can construct a first periodic characterization vector. Each element of the vector can represent the periodicity intensity at different frequencies. For example, the first element in the vector represents the annual periodicity intensity, the second element represents the quarterly periodicity intensity, and so on.

[0046] After acquiring multiple time series reasoning data, the computer system generates multiple second periodic characterization vectors using a similar method. The time series reasoning data is the prediction data obtained by the prediction analysis operator according to the time series characterization vector, and may also contain periodic features.

[0047] Fourier transform can also be used to analyze the periodicity of time series reasoning data. Suppose that after predictive analysis, the time series reasoning data of the residual chlorine content in each month of the next year is obtained. The computer system performs Fourier transform on these data to obtain the amplitude and phase information at different frequencies. If it is found that the amplitude at a frequency of 1 / 6 (corresponding to a period of 6 months) is large, it means that there is a half-year periodic change pattern in the time series reasoning data. Based on this information, the computer system constructs a second periodic characterization vector to describe the periodic distribution intensity of the time series reasoning data.

[0048] For example, to illustrate this process more clearly, assume that there is a set of simple tap water residual chlorine detection training data and corresponding time series reasoning data. The tap water residual chlorine detection training data records the residual chlorine content for 36 consecutive months, and the time series reasoning data is the predicted value of the residual chlorine content in the next 12 months.

[0049] First, the computer system performs Fourier transform on the tap water residual chlorine detection training data. Assuming that the amplitude of the frequency 1 / 12 is large after calculation, it means that the data has annual periodic changes. The computer system constructs the first periodic characterization vector, for example [0.8, 0.2, 0.1], where 0.8 represents the annual periodic intensity, 0.2 represents the semi-annual periodic intensity, and 0.1 represents the quarterly periodic intensity.

[0050] Then, the computer system performs Fourier transform on the time series reasoning data. Assume that the amplitude with a frequency of 1 / 6 is large, indicating that the time series reasoning data has a semi-annual periodic change. The computer system constructs a second periodic characterization vector, such as [0.6, 0.8, 0.1], where 0.6 represents the annual periodicity intensity, 0.8 represents the semi-annual periodicity intensity, and 0.1 represents the quarterly periodicity intensity.

[0051] In addition to Fourier transform, computer systems can also use autocorrelation analysis to generate periodic characterization vectors. Autocorrelation analysis is a method used to analyze the self-correlation of time series data. By calculating the autocorrelation coefficient of the data at different time lags, the periodic characteristics in the data can be found. The calculation formula for the autocorrelation coefficient is: ; Where rk is the autocorrelation coefficient with time lag k, xt is the time series data, is the mean of the data, and n is the length of the data. The computer system can calculate the autocorrelation coefficient at different time lags and find the time lag values ​​with large autocorrelation coefficients, which usually correspond to the periodicity of the data.

[0052] In addition, periodogram analysis can be used to generate periodic characterization vectors. Periodogram is a method for estimating the power spectral density of time series data. It obtains the power spectrum estimate of the data at different frequencies by performing piecewise averaging and Fourier transform on the data. The computer system can determine the periodic characteristics of the data based on the peaks in the periodogram and construct a periodic characterization vector.

[0053] Alternatively, wavelet analysis can be used to generate periodic characterization vectors. Wavelet analysis is a time-frequency analysis method that can analyze signals in both the time and frequency domains. By selecting appropriate wavelet basis functions, the computer system can perform wavelet transforms on tap water residual chlorine detection training data and time series reasoning data to obtain wavelet coefficients of the data at different scales and positions. Based on the distribution of wavelet coefficients, the periodic features in the data can be discovered and periodic characterization vectors can be constructed.

[0054] Step S50: Obtain the overall debugging evaluation index of the basic residual chlorine prediction algorithm through multiple time series characterization vectors, multiple time series reasoning data, multiple first periodic characterization vectors, and multiple second periodic characterization vectors, wherein the overall debugging evaluation index is used to evaluate the debugging status of the basic residual chlorine prediction algorithm.

[0055] The computer system combines multiple time series representation vectors with multiple time series reasoning data to obtain a first debugging evaluation index, which is mainly used to evaluate and correct the time series reasoning data. In this process, a feasible method is to calculate the loss value between the two, such as the Huber loss value. Huber loss is a loss function that is robust to outliers. It combines the advantages of mean square error (MSE) and mean absolute error (MAE). It uses mean square error for smaller errors and mean absolute error for larger errors, which can effectively reduce the impact of outliers on loss calculation. The calculation formula of Huber loss is as follows: ; Among them, y represents the true value (here it can be regarded as the real historical data feature represented by the time series representation vector), f(x) represents the predicted value (time series reasoning data), is a pre-set threshold used to distinguish small errors from large errors.

[0056] Next, the computer system combines the first periodic characterization vectors with the second periodic characterization vectors to obtain a second debugging evaluation index, which is used to evaluate and correct the periodic distribution strength of the temporal reasoning data. This process can be further subdivided into obtaining a first sub-debugging evaluation index and a second sub-debugging evaluation index, and then adding the two to obtain the second debugging evaluation index.

[0057] In order to obtain the first sub-debugging evaluation index, the computer system evaluates and corrects the distribution similarity of the timing reasoning data and the timing characterization vector in each periodic interval. The specific operation is that for the mth periodic interval (m≥1) in each periodic interval, the first periodic probability P1(m) of the first periodic characterization vector and the second periodic probability P2(m) of the second periodic characterization vector corresponding to the periodic interval are obtained. Then, the weight factor w(m) is calculated. The weight factor is usually the result of the first periodic probability being exponentially processed by a set value, such as the logarithm of the first periodic probability with the set value a as the base, that is, Next, the weight factor is multiplied by the first periodic probability to obtain the product w(m)×P1(m), and the product is then multiplied by the second periodic probability to obtain the quotient value , this quotient is the distribution similarity comprehensive value of the mth periodic characterization vector set. Finally, the distribution similarity comprehensive values ​​of each periodic characterization vector set are obtained according to the above calculation method, and they are added together to obtain the first sub-debugging evaluation index.

[0058] For example, suppose there are two periodic intervals. For the first periodic interval, the first periodic probability P1(1)=0.4, the second periodic probability P2(1)=0.3, and the setting value a=2, then the weight factor , the comprehensive value of distribution similarity is For the second period, the distribution similarity comprehensive value is calculated in the same way, and the distribution similarity comprehensive values ​​of the two period intervals are added together to obtain the first sub-debugging evaluation index.

[0059] The purpose of obtaining the second sub-debugging evaluation index is also to evaluate and correct the distribution similarity of the time series reasoning data and the time series representation vector in each period interval. The computer system achieves this by obtaining the JS divergence between the first periodic probability and the second periodic probability. JS divergence (Jensen-Shannon Divergence) is an indicator used to measure the similarity between two probability distributions. The value range is between [0,1]. The smaller the value, the more similar the two distributions are.

[0060] The calculation formula of JS divergence is: ; Where KL represents the Kullback-Leibler divergence, .

[0061] For the mth periodic interval in each periodic interval, the computer system calculates the JS divergence between the corresponding first periodic probability P1(m) and the second periodic probability P2(m), and determines the JS divergence as the distribution similarity value of the mth periodic characterization vector set. Then, the distribution similarity values ​​of each periodic characterization vector set are obtained according to the same calculation method, and they are added together to obtain the second sub-debugging evaluation index.

[0062] After obtaining the first debugging evaluation index and the second debugging evaluation index, the computer system can integrate them in a certain way to obtain the overall debugging evaluation index of the basic residual chlorine prediction algorithm. For example, the two indicators can be weighted and summed, and the weight setting can be adjusted according to specific problems and experience.

[0063] Step S60: When the overall debugging evaluation index meets the debugging stop requirement, a target residual chlorine prediction algorithm is obtained.

[0064] Before executing step S60, the computer system needs to pre-set the debugging stop requirement. The debugging stop requirement is used to determine whether the overall debugging evaluation index meets the expected standard, which is usually related to the performance, convergence and actual application requirements of the algorithm. The feasible debugging stop requirements may include the following situations: Set an acceptable error range. When the overall debugging evaluation index (such as the overall loss function value mentioned above) is less than or equal to the preset error threshold, the prediction accuracy of the algorithm is considered to have met the requirements. For example, in the problem of residual chlorine prediction in tap water, the error threshold of the overall debugging evaluation index is set to 0.05 based on the actual application scenario and relevant standards. If after multiple debugging, the calculated overall debugging evaluation index value is 0.04, which is less than the preset error threshold of 0.05, then this debugging stop requirement is met.

[0065] Alternatively, in order to prevent the algorithm from falling into an infinite loop or over-debugging, a maximum number of iterations is set. When the number of debugging iterations of the algorithm reaches this maximum value, debugging is stopped regardless of whether the overall debugging evaluation index reaches the ideal state. For example, the maximum number of iterations is set to 1000. When the computer system has debugged the basic residual chlorine prediction algorithm for 1000 times, the debugging process will be stopped even if the overall debugging evaluation index has not reached the preset error threshold at this time.

[0066] Alternatively, observe the changes in the overall debugging evaluation index in multiple consecutive iterations. If the change in the index is less than a very small set value, it means that the algorithm has stabilized and no longer has obvious improvements. At this time, it can be considered that the debugging stop requirement is met. For example, set the convergence judgment threshold to 0.001. If the change in the overall debugging evaluation index is less than 0.001 in 10 consecutive iterations, that is, the index value fluctuates within a very small range, then the algorithm is considered to have converged and the debugging stop requirement is met.

[0067] After each calculation of the overall debugging evaluation index, the computer system will compare it with the preset debugging stop requirement. For example, in a certain iteration, the calculated overall debugging evaluation index value is 0.03, the preset error threshold is 0.05, the maximum number of iterations is 1000, the current number of iterations is 800, and the change range of the index in the last 10 iterations is less than 0.001. At this time, since the overall debugging evaluation index value of 0.03 is less than the error threshold of 0.05, and the index has converged, although the number of iterations has not reached the maximum number of iterations of 1000, the computer system will also determine that the overall debugging evaluation index meets the debugging stop requirement.

[0068] When the computer system determines that the overall debugging evaluation index meets the debugging stop requirements, the basic residual chlorine prediction algorithm in the current state will be determined as the target residual chlorine prediction algorithm. The target residual chlorine prediction algorithm is an algorithm model that can accurately predict the residual chlorine data of tap water after debugging and optimization while meeting specific performance requirements. For example, when the debugging stop requirements are met, the various parameters in the basic residual chlorine prediction algorithm (such as weights and biases in the neural network) have been adjusted to a relatively optimal state. At this time, these parameters are fixed, and the resulting algorithm model is the target residual chlorine prediction algorithm.

[0069] As an implementation mode, step S50, through multiple time series characterization vectors, multiple time series reasoning data, multiple first periodic characterization vectors, and multiple second periodic characterization vectors, obtains the overall debugging evaluation index of the basic residual chlorine prediction algorithm, including: Step S51: Acquire a first debugging evaluation index by combining a plurality of time series representation vectors and a plurality of time series reasoning data, wherein the first debugging evaluation index is used to evaluate and correct the time series reasoning data; Step S52: combining the plurality of first periodic characterization vectors and the plurality of second periodic characterization vectors to obtain a second debugging evaluation index, wherein the second debugging evaluation index is used to evaluate and correct the periodic distribution intensity of the time series reasoning data; Step S53: obtaining an overall debugging evaluation index based on the first debugging evaluation index and the second debugging evaluation index.

[0070] Step S51 obtains a first debugging evaluation index that can evaluate and correct the time series reasoning data by analyzing the difference between the time series characterization vector and the time series reasoning data. This index can reflect the degree of deviation between the prediction result and the actual data characteristics, providing an important basis for the adjustment and optimization of the algorithm.

[0071] Specifically, the computer system compares and analyzes each time series representation vector and the corresponding time series reasoning data. For example, suppose there is a set of time series representation vectors ,in Represents the time series representation vector of the i-th moment, whose dimension is d, that is, ; The corresponding temporal reasoning data is ,in represents the temporal reasoning data at the i-th moment, and the dimension is also d, that is, .

[0072] In order to obtain the first debugging evaluation index, the computer system can use a variety of methods to measure the difference between the time series representation vector and the time series reasoning data. One feasible method is to calculate the mean square error (MSE). The mean square error is a statistical indicator that measures the difference between the predicted value and the true value. It calculates the average value of the square of the difference between the predicted value and the true value.

[0073] Step S52 obtains a second debugging evaluation index for evaluating and correcting the periodic distribution strength of the time series reasoning data by analyzing the relationship between the first periodic characterization vector and the second periodic characterization vector. This index can reflect the degree of matching between the prediction result and the actual data in terms of periodic characteristics, and is of great significance for the performance of the optimization algorithm in processing periodic data.

[0074] The computer system obtains the first sub-debugging evaluation index and the second sub-debugging evaluation index, and then adds them together to obtain the second debugging evaluation index.

[0075] For the first sub-debugging evaluation index, it is mainly used to evaluate and correct the distribution similarity of the timing reasoning data and the timing representation vector in each periodic interval. The computer system analyzes the first periodic representation vector and the second periodic representation vector in each periodic interval. For example, assuming there are m periodic intervals, for the kth periodic interval (1≤k≤m), the corresponding first periodic representation vector is p1k, and the second periodic representation vector is p2k.

[0076] One way to measure the similarity of distributions is to calculate cosine similarity. Cosine similarity measures the similarity of two vectors by calculating the cosine value of the angle between them. The value range is between [-1,1]. The closer the value is to 1, the more similar the two vectors are. The calculation formula is as follows: ; in, represents the angle between two periodic characterization vectors in the kth period interval, represents the product of vectors, They represent the magnitude of the vector respectively.

[0077] For example, for the first periodic interval, the first periodic characterization vector p11=[0.3,0.4], and the second periodic characterization vector p21=[0.2,0.5]. Then their cosine similarity is calculated as follows: p11·p21=0.3×0.2+0.4×0.5=0.26; ; ; ; The computer system sums or averages the cosine similarities of all periodic intervals to obtain the first sub-debugging evaluation index L21. For example, for m periodic intervals, the calculation formula of the first sub-debugging evaluation index can be: ; For the second sub-debugging evaluation indicator, it is also used to evaluate and correct the distribution similarity of the timing reasoning data and the timing representation vector in each cycle interval. One feasible method is to calculate the Kullback-Leibler (KL) divergence. KL divergence is used to measure the difference between two probability distributions. The larger the value, the greater the difference between the two distributions.

[0078] For the kth periodic interval, assuming that the first periodic characterization vector p1k and the second periodic characterization vector p2k represent probability distribution, the calculation formula of KL divergence is as follows: ; Where l represents the index of the probability distribution.

[0079] For example, for the second periodic interval, the first periodic characterization vector p12 = [0.2, 0.8], and the second periodic characterization vector p22 = [0.3, 0.7]. Their KL divergence is calculated as follows: ; The computer system sums or averages the KL divergence of all period intervals to obtain the second sub-debugging evaluation index L22. For example, for m period intervals, the calculation formula of the second sub-debugging evaluation index can be: L22 ; Finally, the computer system adds the first sub-debugging evaluation index L21 and the second sub-debugging evaluation index L22 to obtain the second debugging evaluation index L2, that is, L2=L21+L22.

[0080] In step S53, after obtaining the first debugging evaluation index and the second debugging evaluation index, the computer system integrates them to obtain an overall debugging evaluation index that can fully reflect the debugging status of the basic residual chlorine prediction algorithm. A feasible method is to perform weighted summation on the first debugging evaluation index and the second debugging evaluation index. The setting of the weight can be adjusted according to the needs of the actual problem and the data characteristics.

[0081] As an implementation mode, step S51, combining multiple time series representation vectors and multiple time series reasoning data to obtain a first debugging evaluation indicator, includes: Step S511: determine a Huber loss value between each time series representation vector in a plurality of time series representation vectors and each time series reasoning data in a plurality of time series reasoning data, and determine the Huber loss value as a first debugging evaluation indicator.

[0082] Huber loss is a loss function used for regression problems. It combines the advantages of mean square error (MSE) and mean absolute error (MAE) and has good robustness to outliers. When dealing with the problem of residual chlorine in tap water, since there may be some noise or outliers in the data, using Huber loss can reduce the impact of these outliers on the loss calculation to a certain extent, thereby more accurately evaluating the difference between the time series representation vector and the time series reasoning data. The calculation formula of Huber loss can refer to the above description and will not be repeated here.

[0083] To better understand how a computer system calculates the Huber loss value, a simple example is used to illustrate. Assume that there is a set of time series representation vectors {v1, v2, v3} and corresponding time series reasoning data {r1, r2, r3}, where v1=0.8, v2=0.9, v3=1.2, r1=0.7, r2=0.85, r3=1.5, and the threshold is set =0.2.

[0084] For the first data point, the true value y=v1=0.8, the predicted value f(x)=r1=0.7, and the error |yf(x)|=|0.8-0.7|=0.1. 0.2 (i.e. ), according to the Huber loss formula, the loss value at this time is: ; For the second data point, the true value y=v2=0.9, the predicted value f(x)=r2=0.85, the error |yf(x)|=|0.9-0.85|=0.05, and 0.05≤0.2. The loss value is: ; For the third data point, the true value y=v3=1.2, the predicted value f(x)=r3=1.5, and the error |yf(x)|=|1.2-1.5|=0.3, because 0.3>0.2 (that is, |yf(x)|> ), so the loss value is: ; After calculating the Huber loss value between each time series representation vector and the corresponding time series reasoning data, the computer system will combine these loss values ​​to determine the first debugging evaluation index. A feasible comprehensive method is to find the average value, that is, add all Huber loss values ​​and then divide them by the number of data points. In the above example, the calculation of the first debugging evaluation index L1 is as follows: L1 ; As an implementation manner, step S52, combining a plurality of first periodic characterization vectors with a plurality of second periodic characterization vectors to obtain a second debugging evaluation index, includes: Step S521: combining multiple first periodic characterization vectors with multiple second periodic characterization vectors to obtain a first sub-debugging evaluation index, and combining multiple first periodic characterization vectors with multiple second periodic characterization vectors to obtain a second sub-debugging evaluation index, wherein the first sub-debugging evaluation index is used to evaluate and correct the distribution similarity of the temporal reasoning data and the temporal characterization vector in each periodic interval, and the second sub-debugging evaluation index is used to evaluate and correct the distribution similarity of the temporal reasoning data and the temporal characterization vector in each periodic interval; Step S522: taking the sum of the first debugging evaluation index and the second debugging evaluation index as the second debugging evaluation index.

[0085] In step S521, when the computer system obtains the first sub-debugging evaluation index, the main purpose is to evaluate and correct the distribution similarity of the time series reasoning data and the time series representation vector in each period interval. The specific operation process is as follows: First, for the mth periodic interval (m≥1) in each periodic interval, the computer system obtains the first periodic probability P1(m) of the first periodic characterization vector and the second periodic probability P2(m) of the second periodic characterization vector corresponding to the periodic interval. The periodic probability here indicates the possibility that the data will show periodic characteristics within a specific periodic interval. For example, assume that the 24 hours of a day are divided into different periodic intervals, each of which is 4 hours. For a specific periodic interval (such as 8-12 o'clock), the first periodic probability P1(m) corresponding to the first periodic characterization vector may indicate the probability that the tap water residual chlorine detection training data will show periodic changes within this time period, and the second periodic probability P2(m) indicates the probability that the time series reasoning data will show periodic changes within this time period.

[0086] Next, the computer system calculates the weighting factor , the weight factor is the result of the first periodic probability being exponentially processed by the set value, for example, the logarithmic value of the first periodic probability with the set value a as the base, that is, P1(m). The role of this weight factor is to perform a weighted processing on the first periodic probability to highlight the importance of different periodic probabilities. For example, when a=2, P1(m)=0.4, w(m)= .

[0087] Then, the weight factor is multiplied by the first periodic probability to obtain the product w(m)×P1(m), and the product is multiplied by the second periodic probability to obtain the quotient value , this quotient is the distribution similarity comprehensive value of the mth periodic characterization vector set. This distribution similarity comprehensive value reflects the similarity between the first periodic characterization vector and the second periodic characterization vector in the mth periodic interval. For example, assuming that in a certain periodic interval, w(m)=-1, P1(m)=0.4, P2(m)=0.3, then the distribution similarity comprehensive value is .

[0088] Finally, according to the calculation method of the distribution similarity comprehensive value of the mth periodic characterization vector set, the computer system obtains the distribution similarity comprehensive values ​​of each periodic characterization vector set, and adds them together to obtain the first sub-debugging evaluation index. For example, assuming that there are 3 periodic intervals, the corresponding distribution similarity comprehensive values ​​are -1.33, 0.8 and 1.2, respectively, then the first sub-debugging evaluation index is -1.33+0.8+1.2=0.67.

[0089] The second sub-debugging evaluation index is also obtained to evaluate and correct the distribution similarity of the time series reasoning data and the time series representation vector in each period interval. The computer system achieves this by obtaining the JS divergence between the first periodic probability and the second periodic probability.

[0090] The calculation formula of JS divergence can refer to the above description and will not be repeated here.

[0091] The computer system obtains the distribution similarity values ​​of each periodic characterization vector set according to the above calculation method, and adds them together to obtain the second sub-debugging evaluation index. For example, assuming there are 3 periodic intervals, the corresponding distribution similarity values ​​are 0.03, 0.02 and 0.04, respectively, then the second sub-debugging evaluation index is 0.03+0.02+0.04=0.09.

[0092] In step S522, after obtaining the first sub-debugging evaluation index and the second sub-debugging evaluation index, the computer system adds the two indicators to obtain the second debugging evaluation index. For example, assuming that the first sub-debugging evaluation index is 0.67 and the second sub-debugging evaluation index is 0.09, the second debugging evaluation index is 0.67+0.09=0.76.

[0093] The second debugging evaluation index comprehensively considers the distribution similarity information calculated by different methods, and can more comprehensively evaluate the distribution similarity of time series reasoning data and time series representation vectors in each period interval, providing a more accurate basis for subsequent algorithm debugging and optimization.

[0094] In summary, steps S521 to S522 comprehensively evaluate the distribution similarity of the time series reasoning data and the time series representation vector in each period interval by calculating the first sub-debugging evaluation index and the second sub-debugging evaluation index and adding them to obtain the second debugging evaluation index, and provide important reference information for debugging and optimizing the basic residual chlorine prediction algorithm. By using appropriate technical means, the computer system can efficiently and accurately complete these calculation tasks, which helps to improve the accuracy and reliability of tap water residual chlorine prediction.

[0095] As an implementation manner, in step S521, combining a plurality of first periodic characterization vectors with a plurality of second periodic characterization vectors to obtain a first sub-debugging evaluation indicator includes: Step S5211: Obtain a first periodic probability of a first periodic characterization vector corresponding to the mth periodic interval in each periodic interval and a second periodic probability of a second periodic characterization vector corresponding to the mth periodic interval, where m≥1; Step S5212: when the product obtained by multiplying the first periodic probability and the weight factor is obtained, the product is divided by the second periodic probability to obtain a quotient value, and the quotient value is determined as the distribution similarity comprehensive value of the mth periodic characterization vector set, wherein different periodic characterization vector sets correspond to first periodic characterization vectors and second periodic characterization vectors of different periodic intervals, and the weight factor is the result of the first periodic probability being exponentially processed by a set value; Step S5213: When the distribution similarity comprehensive values ​​of each periodic characterization vector set are obtained according to the calculation method of the distribution similarity comprehensive value of the mth periodic characterization vector set, the sum of the distribution similarity comprehensive values ​​of each periodic characterization vector set is used as the first sub-debugging evaluation indicator.

[0096] In step S5211, when processing the residual chlorine data of tap water, the computer system divides the data into different period intervals according to certain rules. For example, according to the 24-hour time period of a day, it is divided into 6 period intervals, each period interval is 4 hours. Here, m represents the serial number of the period interval, m≥1.

[0097] For the mth periodic interval, the computer system obtains the corresponding first periodic characterization vector and second periodic characterization vector. The first periodic characterization vector is generated based on the tap water residual chlorine detection training data, and is used to describe the periodic distribution intensity of the residual chlorine detection training data within the periodic interval; the second periodic characterization vector is generated based on the time series reasoning data, and is used to describe the periodic distribution intensity of the time series reasoning data within the periodic interval.

[0098] The first periodic probability and the second periodic probability respectively represent the probability of the periodic features represented by the first periodic characterization vector and the second periodic characterization vector appearing in the mth periodic interval. For example, assuming that in the second periodic interval (i.e., 4-8 o'clock), the first periodic characterization vector is [0.3, 0.4, 0.3], indicating that in this periodic interval, the residual chlorine detection training data presents the intensity distribution of periodic features in different dimensions; the second periodic characterization vector is [0.2, 0.3, 0.5], indicating the intensity distribution of periodic features of time series reasoning data in the corresponding dimension.

[0099] The first periodic probability and the second periodic probability can be obtained by normalizing the corresponding periodic characterization vector. For example, for the first periodic characterization vector [0.3, 0.4, 0.3], its first periodic probability P1(m) can be calculated as: P1(m) 0.33; Similarly, for the second periodic characterization vector [0.2, 0.3, 0.5], its second periodic probability P2(m) is: P2(m) 0.33. The computer system can use normalization functions in the mathematical calculation library to calculate the first periodic probability and the second periodic probability. These functions can quickly and accurately normalize the vector to obtain the corresponding probability value.

[0100] In step S5212, after obtaining the first periodic probability P1(m), the computer system calculates the weight factor w(m). The weight factor is the result of the first periodic probability being indexed by the set value, for example, the logarithm of the first periodic probability with the set value a as the base, that is, w(m)= P1(m). The setting value a here can be selected according to the specific problem and data characteristics, and is usually a positive number greater than 1.

[0101] Assuming the setting value a=2, for the second period interval in the previous example, the first periodic probability P1(m)=0.33, then the weight factor w(m) is: w(m)= 0.33≈-1.62; Next, the computer system multiplies the weight factor w(m) by the first periodic probability P1(m) to obtain the product w(m)×P1(m), that is: -1.62×0.33≈-0.54. Then, the product is multiplied by the second periodic probability P2(m) to obtain the quotient value, that is: ≈-1.64. This quotient is the comprehensive value of the distribution similarity of the mth periodic characterization vector set. The comprehensive value of the distribution similarity reflects the degree of similarity between the first periodic characterization vector and the second periodic characterization vector in the mth periodic interval. The closer the value is to 1, the higher the distribution similarity of the two periodic characterization vectors; the farther the value is from 1, the lower the distribution similarity. The computer system can use the logarithmic function, multiplication function, and division function in the mathematical calculation library to calculate the weight factor, product, and quotient value. These functions can efficiently complete the corresponding mathematical operations to ensure the accuracy of the calculation results.

[0102] In step S5213, after calculating the distribution similarity comprehensive value of the mth periodic interval, the computer system calculates the distribution similarity comprehensive values ​​of other periodic intervals in turn according to the same calculation method. For example, for the 6 periodic intervals divided previously, the distribution similarity comprehensive values ​​of each periodic interval are calculated respectively, assuming that they are -1.64, 0.8, 1.2, -0.5, 0.9 and 1.1 respectively. Then, the computer system adds the distribution similarity comprehensive values ​​of each periodic characterization vector set to obtain the first sub-debugging evaluation index. That is: -1.64+0.8+1.2-0.5+0.9+1.1=1.86.

[0103] The first sub-debugging evaluation index comprehensively considers the distribution similarity of the first periodic characterization vector and the second periodic characterization vector in all periodic intervals, and can more comprehensively evaluate the overall distribution similarity of the time series reasoning data and the time series characterization vector in each periodic interval. Through this index, the computer system can understand the degree of match between the prediction results and the actual data in terms of periodic distribution, providing an important basis for subsequent algorithm debugging and optimization.

[0104] In summary, steps S5211 to S5213 obtain the first periodic probability and the second periodic probability of each periodic interval, calculate the distribution similarity comprehensive value, and add all the distribution similarity comprehensive values ​​to obtain the first sub-debugging evaluation index, which comprehensively evaluates the distribution similarity of the time series reasoning data and the time series representation vector in each periodic interval. By using appropriate technical means, the computer system can efficiently and accurately complete these calculation tasks, providing strong support for the debugging and optimization of the tap water residual chlorine prediction algorithm.

[0105] As an implementation manner, in step S521, combining a plurality of first periodic characterization vectors with a plurality of second periodic characterization vectors to obtain a second sub-debugging evaluation indicator includes: Step S5214: obtaining a JS divergence between the first periodic probability and the second periodic probability, and determining the JS divergence as a distribution similarity value of the mth periodic characterization vector set; Step S5215: when the distribution similarity values ​​of each periodic characterization vector set are obtained according to the calculation method of the distribution similarity value of the mth periodic characterization vector set, the sum of the distribution similarity values ​​of each periodic characterization vector set is used as the second sub-debugging evaluation indicator.

[0106] In step S5214, when the computer system processes the residual chlorine data of tap water, it is necessary to evaluate the distribution similarity of the first periodic characterization vector and the second periodic characterization vector in each periodic interval. JS divergence (Jensen-Shannon Divergence) is a feasible indicator for measuring the similarity between two probability distributions. The value range is between [0,1]. The smaller the value, the more similar the two distributions are. For the mth periodic interval in each periodic interval, the computer system obtains the corresponding first periodic probability P1(m) and second periodic probability P2(m). For example, assuming that in the third periodic interval, the first periodic probability P1(3)=[0.2,0.3,0.5], indicating that in this periodic interval, the residual chlorine detection training data presents a probability distribution of periodic characteristics in different dimensions; the second periodic probability P2(3)=[0.3,0.2,0.5], indicating the probability distribution of periodic characteristics of time series reasoning data in the corresponding dimension.

[0107] The formula for calculating JS divergence is: ; Where KL represents the Kullback-Leibler divergence, .

[0108] First, calculate M: ; Then, calculate The calculation formula of Kullback-Leibler divergence is: ; for : ; for : ; Finally, substitute the calculated results into the JS divergence formula: ; This value is the distribution similarity value of the mth periodic representation vector set corresponding to the third period interval. It reflects the similarity between the probability distribution represented by the first periodic probability and the second periodic probability in this period interval.

[0109] In step S5215, after calculating the distribution similarity value of the mth period interval, the computer system calculates the distribution similarity values ​​of other period intervals in sequence according to the same calculation method. For example, assuming that a day is divided into 4 period intervals, except that the distribution similarity value of the third period interval calculated above is 0.043, the distribution similarity values ​​of the other period intervals are: the distribution similarity value of the first period interval JS(P1(1)||P2(1))=0.035, the distribution similarity value of the second period interval JS(P1(2)||P2(2))=0.040, and the distribution similarity value of the fourth period interval JS(P1(4)||P2(4))=0.038.

[0110] Then, the computer system adds the distribution similarity values ​​of each set of periodic representation vectors to obtain the second sub-debugging evaluation index. That is: the second sub-debugging evaluation index = JS(P1(1)||P2(1))+JS(P1(2)||P2(2))+JS(P1(3)||P2(3))+JS(P1(4)||P2(4))=0.035+0.040+0.043+0.038=0.156. The second sub-debugging evaluation index comprehensively considers the distribution similarity of the first periodic probability and the second periodic probability in all periodic intervals, and can more comprehensively evaluate the overall distribution similarity of the time series reasoning data and the time series representation vector in each periodic interval. Through this indicator, the computer system can understand the degree of matching between the prediction results and the actual data in the periodic distribution, providing an important basis for subsequent algorithm debugging and optimization.

[0111] In summary, steps S5214 to S5215 calculate the JS divergence between the first periodic probability and the second periodic probability to obtain the distribution similarity values ​​of each periodic characterization vector set, and add these values ​​to obtain the second sub-debugging evaluation index, which comprehensively evaluates the distribution similarity of the time series reasoning data and the time series characterization vector in each period interval. By using appropriate technical means, the computer system can efficiently and accurately complete these calculation tasks, providing strong support for the debugging and optimization of the tap water residual chlorine prediction algorithm.

[0112] As an implementation manner, in step S53, before obtaining the overall debugging evaluation index based on the first debugging evaluation index and the second debugging evaluation index, the method may further obtain a third debugging evaluation index, including: Step S53a: obtaining a third periodic probability of a target periodic characterization vector element corresponding to the nth periodic interval in each periodic interval and a second periodic probability of a second periodic characterization vector corresponding to the nth periodic interval, wherein the first periodic characterization vector includes the target periodic characterization vector element, and n≥1; Step S53b: taking the norm of the difference between the third periodic probability and the second periodic probability as the local periodic intensity value of the nth periodic characterization vector set; Step S53c: when the local periodic strength values ​​of each periodic characterization vector set are obtained according to the calculation method of the local periodic strength value of the nth periodic characterization vector set, the sum of the local periodic strength values ​​of each periodic characterization vector set is used as a third debugging evaluation indicator, wherein the third debugging evaluation indicator is used to evaluate and correct the local periodic strength of the time series reasoning data; Based on this, step S53, based on the first debugging evaluation index and the second debugging evaluation index, obtains the overall debugging evaluation index, including: Step S531: Integrate the first debugging evaluation index, the second debugging evaluation index and the third debugging evaluation index to obtain an overall debugging evaluation index.

[0113] In step S53a, when the computer system processes the tap water residual chlorine data, it needs to perform a detailed analysis of the data in each periodic interval. Here n represents the sequence number of the periodic interval, n≥1. For the nth periodic interval, the computer system focuses on the target periodic characterization vector element and the corresponding second periodic characterization vector.

[0114] The target periodic characterization vector element is a specific element in the first periodic characterization vector, which represents the periodic characteristics of the residual chlorine detection training data in a specific dimension within the periodic interval. For example, suppose that a day is divided into 6 periodic intervals, each of which is 4 hours. In the second periodic interval (4-8 o'clock), the first periodic characterization vector is [0.2, 0.3, 0.5]. Assuming that the target periodic characterization vector element is selected as the second element 0.3, it represents the intensity of the periodic characteristics of the residual chlorine detection training data in a specific dimension (such as the periodicity of the change of residual chlorine content with temperature) within this periodic interval.

[0115] The second periodic characterization vector is generated based on the time series reasoning data and is used to describe the periodic distribution intensity of the time series reasoning data in the periodic interval. For example, in the second periodic interval, the second periodic characterization vector is [0.3, 0.2, 0.5].

[0116] The third periodic probability and the second periodic probability respectively represent the probability of the occurrence of the periodic features represented by the target periodic characterization vector element and the second periodic characterization vector. The method for calculating the third periodic probability and the second periodic probability is similar to the method for calculating the first and second periodic probabilities, which is usually to normalize the corresponding vector elements. For example, for the target periodic characterization vector element 0.3, its third periodic probability P3(n) is: P3(n)=0.3 (here it is assumed that normalization has been performed); For the second periodic characterization vector [0.3, 0.2, 0.5], its second periodic probability P2(n) can be calculated as: P2(n) 0.33.

[0117] In step S53b, after obtaining the third periodic probability P3(n) and the second periodic probability P2(n), the computer system calculates their difference results. For example, in the second period interval, the difference result is: P3(2)-P2(2)=0.3-0.33=-0.03. Then, the norm of this difference result is calculated. The norm is a measure of the size of a vector or a numerical value. The feasible norms include 1-norm, 2-norm, etc. Here, taking the 2-norm as an example, the calculation formula of the 2-norm is: For a numerical value x, its 2-norm is Therefore, for the difference result -0.03, its 2-norm is: .

[0118] This value is the local periodicity strength value of the nth periodicity characterization vector set corresponding to the second periodic interval. The local periodicity strength value reflects the degree of difference in periodicity characteristics between the target periodicity characterization vector element and the second periodicity characterization vector in the nth periodic interval. The smaller the value, the more similar the periodicity characteristics of the two are; the larger the value, the greater the difference.

[0119] In step S53c, after calculating the local periodicity intensity value of the nth periodic interval, the computer system calculates the local periodicity intensity values ​​of other periodic intervals in turn according to the same calculation method. For example, assuming that for the 6 periodic intervals divided above, except that the local periodicity intensity value of the second periodic interval is 0.03, the local periodicity intensity values ​​of the other periodic intervals are: the local periodicity intensity value of the first periodic interval is 0.02, the local periodicity intensity value of the third periodic interval is 0.04, the local periodicity intensity value of the fourth periodic interval is 0.035, the local periodicity intensity value of the fifth periodic interval is 0.025, and the local periodicity intensity value of the sixth periodic interval is 0.032. Then, the computer system adds the local periodicity intensity values ​​of each periodic characterization vector set to obtain the third debugging evaluation index. That is: the third debugging evaluation index = 0.02 + 0.03 + 0.04 + 0.035 + 0.025 + 0.032 = 0.182.

[0120] The third debugging evaluation index comprehensively considers the difference in local periodicity intensity between the target periodicity representation vector elements and the second periodicity representation vector in all periodic intervals. It can more comprehensively evaluate the degree of match between the time series reasoning data and the actual data in terms of local periodicity, and provide an important basis for subsequent algorithm debugging and optimization.

[0121] In step S531, after obtaining the first debugging evaluation index, the second debugging evaluation index and the third debugging evaluation index, the computer system integrates these three indicators to obtain an overall debugging evaluation index that can fully reflect the debugging status of the basic residual chlorine prediction algorithm.

[0122] A feasible integration method is weighted summation. Assume that the first debugging evaluation index is L1, the second debugging evaluation index is L2, and the third debugging evaluation index is L3, and their weights are , and ( + + =1), then the calculation formula of the overall debugging evaluation index L is: L= L1+ L2+ L3; For example, suppose that based on experience and data analysis, the first debugging evaluation indicator (reflecting the overall difference between the time series reasoning data and the actual data) is considered to be more important, the second debugging evaluation indicator (reflecting the degree of matching of the periodic distribution strength) is second, and the third debugging evaluation indicator (reflecting the difference in local periodicity strength) is relatively low, so the weight is set =0.5, =0.3, =0.2. Assuming that in a certain debugging process, the first debugging evaluation index L1=0.05, the second debugging evaluation index L2=0.08, and the third debugging evaluation index L3=0.182 are calculated, then the overall debugging evaluation index L is calculated as follows: L=0.5×0.05+0.3×0.08+0.2×0.182=0.025+0.024+0.0364=0.0854.

[0123] In summary, steps S53a to S53c and step S531 comprehensively evaluate the performance of the basic residual chlorine prediction algorithm in different aspects by obtaining the third debugging evaluation index and integrating it with the first and second debugging evaluation indexes, and provide a more comprehensive and accurate basis for the debugging and optimization of the algorithm. The computer system can efficiently and accurately complete these calculation tasks by using appropriate technical means, thereby improving the accuracy and reliability of tap water residual chlorine prediction.

[0124] As an implementation mode, step S30, multiple time series characterization vectors are loaded into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain multiple time series reasoning data, including: Step S31: Combining multiple time series representation vectors to obtain a target time series representation vector sequence; Step S32: loading each time series representation vector in the target time series representation vector sequence into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain target reasoning data, wherein the target reasoning data includes a plurality of time series reasoning data.

[0125] In step S31, when processing multiple time series representation vectors, the computer system needs to combine them into a target time series representation vector sequence. The time series representation vector is obtained by processing the tap water residual chlorine detection training data through the time series data embedding mapping operator. It contains the historical dependency information of the data, that is, the correlation between the current value and the past value and the time series characteristics.

[0126] The purpose of vector combination is to integrate multiple independent time series representation vectors in a certain order or rule, so as to better utilize the information contained in these vectors for subsequent prediction analysis. For example, suppose there are three time series representation vectors v1, v2 and v3, which represent the historical dependency characteristics of tap water residual chlorine data in different time periods. Among them, v1=[0.2, 0.3, 0.4, 0.5], v2=[0.3, 0.4, 0.5, 0.6], v3=[0.4, 0.5, 0.6, 0.7].

[0127] The computer system can combine these vectors in chronological order, that is, arrange v1, v2 and v3 in sequence, and obtain the target temporal representation vector sequence V=[v1,v2,v3]=[0.2,0.3,0.4,0.5,0.3,0.4,0.5,0.6,0.4,0.5,0.6,0.7].

[0128] In step S32, after obtaining the target time series characterization vector sequence, the computer system loads each time series characterization vector in the sequence into the prediction analysis operator of the basic residual chlorine prediction algorithm. The prediction analysis operator is the core component of the basic residual chlorine prediction algorithm. Its main function is to perform data fitting and prediction based on the input time series characterization vector, so as to obtain the corresponding time series reasoning data.

[0129] Taking the target time series representation vector sequence V=[0.2, 0.3, 0.4, 0.5, 0.3, 0.4, 0.5, 0.6, 0.4, 0.5, 0.6, 0.7] as an example, the computer system loads the time series representation vectors into the prediction analysis operator one by one. Assume that the prediction analysis operator adopts a neural network-based model with multiple neurons and hidden layers, which can automatically learn the characteristics and rules of the input data and make predictions.

[0130] When the computer system loads the first time series representation vector v1=[0.2, 0.3, 0.4, 0.5] into the predictive analysis operator, the neural network model processes the data. First, the neurons in the input layer receive the elements of the vector v1 as input signals. Then, these signals undergo a series of weighted summation and activation function operations in the hidden layer to gradually extract and learn the features of the data. For example, in a hidden layer, the neurons can perform a weighted summation operation on the input signal, and the calculation formula is as follows: ; Where zi represents the weighted sum of the i-th neuron, wij represents the weight connecting the j-th input and the i-th neuron, xj represents the j-th element of the input vector, and bi represents the bias term of the i-th neuron.

[0131] Next, the activation function performs a nonlinear transformation on the weighted summation result to increase the model's expressiveness. Possible activation functions include the sigmoid function and the ReLU function. For example, the calculation formula of the sigmoid function is: ; After being processed by the hidden layer, the final output layer will output a prediction result, that is, a time series reasoning data. Assume that for vector v1, the time series reasoning data output by the prediction analysis operator is r1=0.6.

[0132] Then, the computer system loads the second time series representation vector v2=[0.3, 0.4, 0.5, 0.6] into the prediction analysis operator, and performs calculations and predictions in the same way to obtain the corresponding time series reasoning data r2. This process is repeated until all time series representation vectors in the target time series representation vector sequence are loaded into the prediction analysis operator and the corresponding time series reasoning data are obtained. Finally, these time series reasoning data constitute the target reasoning data.

[0133] In summary, steps S31 to S32 obtain a target time series characterization vector sequence by vector combination of multiple time series characterization vectors, and load each time series characterization vector in the sequence into the prediction analysis operator to obtain target reasoning data, which provides an important basis for the prediction of tap water residual chlorine data. The computer system can complete these operations efficiently and accurately by using appropriate technical means, thereby improving the accuracy and reliability of tap water residual chlorine prediction.

[0134] As an implementation mode, step S100, obtaining the historical detection data of residual chlorine in tap water, and loading the historical detection data of residual chlorine in tap water into the target residual chlorine prediction algorithm of debugging convergence, predicting the historical detection data of residual chlorine in tap water based on the target residual chlorine prediction algorithm, and obtaining the prediction result of residual chlorine in tap water, including: Step S110: when a residual chlorine prediction command generated for the historical detection data of residual chlorine in tap water is received, the historical detection data of residual chlorine in tap water is loaded into the time series data embedding mapping operator of the target basic residual chlorine prediction algorithm to obtain a plurality of data characterization vectors, wherein the data characterization vectors are used for the historical dependency of the historical detection data of residual chlorine in tap water; Step S120: loading multiple data representation vectors into the prediction analysis operator of the target residual chlorine prediction algorithm to obtain multiple data prediction results; Step S130: merging multiple data prediction results to obtain a merged target data prediction result.

[0135] During operation, the computer system will monitor in real time whether it has received a residual chlorine prediction command generated for the historical test data of residual chlorine in tap water. When the command is received, it means that a prediction analysis of the historical test data of residual chlorine in tap water is required.

[0136] The historical test data of residual chlorine in tap water is the data record obtained by testing the residual chlorine content of tap water in the past period of time. These data reflect the change of residual chlorine content over time. For example, suppose there is a week of historical test data of residual chlorine in tap water, and the residual chlorine content at 4 times (8 am, 12 noon, 4 pm, and 8 pm) is recorded every day. The data is as follows (unit: mg / L): Monday: [0.4, 0.3, 0.35, 0.42]; Tuesday: [0.38, 0.32, 0.36, 0.4]; Wednesday: [0.41, 0.33, 0.37, 0.43]; Thursday: [0.39, 0.31, 0.34, 0.41]; Friday: [0.4, 0.32, 0.35, 0.42]; Saturday: [0.38, 0.3, 0.33, 0.4]; Sunday: [0.42, 0.34, 0.38, 0.44]; At this point, the computer system loads these tap water residual chlorine historical detection data into the time series data embedding mapping operator of the target basic residual chlorine prediction algorithm. The function of the time series data embedding mapping operator is to extract and transform the input data and map it into a low-dimensional vector space to better capture the historical dependency and time series characteristics of the data.

[0137] For example, for the above historical detection data, the time series data embedding mapping operator can use a coding method to encode the residual chlorine content data at four times of the day into a data representation vector with a dimension of 4. Specifically, for the Monday data [0.4, 0.3, 0.35, 0.42], after being processed by the time series data embedding mapping operator, a data representation vector v1 = [0.2, 0.15, 0.17, 0.21] may be obtained. Each element in this vector contains some characteristic information of the original data, and through this mapping method, the historical dependency of the data can be better reflected.

[0138] In step S120, after obtaining multiple data characterization vectors, the computer system loads these vectors into the prediction analysis operator of the target residual chlorine prediction algorithm. The prediction analysis operator is the core part of the target residual chlorine prediction algorithm. It performs data fitting and prediction based on the input data characterization vectors and outputs the corresponding data prediction results.

[0139] Continuing with the above example, assuming that the data representation vectors from Monday to Sunday are v1, v2, v3, v4, v5, v6, and v7 respectively obtained after step S110, the computer system sequentially loads these data representation vectors into the prediction analysis operator.

[0140] Predictive analysis operators are built based on various machine learning or deep learning models, such as neural networks, support vector machines, etc. Taking a neural network as an example, when a data representation vector v1 is loaded, the input layer of the neural network receives each element of the vector v1 as an input signal. Then, these signals undergo a series of weighted summation and activation function operations in the hidden layer to gradually extract and learn the features of the data. Assuming that there is a neuron in the hidden layer of the neural network, its weighted summation operation on the input signal can be expressed as: z=w1x1+w2x2+w3x3+w4x4+b; Among them, x1, x2, x3, and x4 are the four elements of the data representation vector v1, w1, w2, w3, and w4 are the corresponding weights, and b is the bias term. After weighted summation, a nonlinear transformation is performed through an activation function (such as the ReLU function): a=max(0,z); after processing through multiple hidden layers, the final output layer will output a prediction result, that is, a data prediction result. Assume that for the data representation vector v1, the data prediction result output by the prediction analysis operator is p1=0.45, indicating that the residual chlorine content of tap water at the next moment is predicted to be 0.45 mg / L.

[0141] Similarly, the computer system loads other data representation vectors v2, v3, v4, v5, v6, and v7 into the prediction analysis operator in sequence to obtain corresponding data prediction results p2, p3, p4, p5, p6, and p7.

[0142] In step S130, after obtaining multiple data prediction results, the computer system merges these results to obtain the final target data prediction result. The purpose of merging is to comprehensively consider multiple prediction results and improve the accuracy and reliability of the prediction.

[0143] For example, for the previously obtained data prediction results p1, p2, p3, p4, p5, p6, and p7, the computer system can use a simple average method to merge them. That is, the average value of these prediction results is calculated as the merged target data prediction result. The calculation formula is as follows: ; Assuming p1=0.45, p2=0.43, p3=0.46, p4=0.44, p5=0.45, p6=0.43, p7=0.47, the prediction result of the merged target data is: 0.446; In addition to the average method, the computer system can also use other merging methods according to specific circumstances, such as the weighted average method, the median method, etc. The weighted average method can assign different weights according to the importance or credibility of different prediction results, and then calculate the weighted average as the target data prediction result; the median method takes the median of multiple prediction results as the target data prediction result. This method has good robustness in the presence of outliers.

[0144] In summary, steps S110 to S130 obtain a data representation vector by loading the historical detection data of residual chlorine in tap water into the time series data embedding mapping operator of the target basic residual chlorine prediction algorithm, and then load the data representation vector into the prediction analysis operator to obtain the data prediction result, and finally merge the multiple data prediction results to obtain the merged target data prediction result. The computer system can effectively process and analyze the historical detection data of residual chlorine in tap water by using appropriate technical means, and provide accurate and reliable results for the prediction of residual chlorine content in tap water.

[0145] As an implementation mode, step S10, obtaining a basic residual chlorine prediction algorithm and a plurality of tap water residual chlorine detection training data, includes: Step S11: obtaining initial tap water residual chlorine detection data of a target monitoring period, wherein the target monitoring period represents a time period from a first moment to a second moment; Step S12: Perform multi-scale data extraction on the initial tap water residual chlorine detection data to obtain multiple periodic data, and use the multiple periodic data as multiple tap water residual chlorine detection training data.

[0146] In step S11, when the computer system performs this step, it is clear that the target monitoring cycle represents the time period from the first moment to the second moment. The determination of this time period is set based on the actual tap water residual chlorine detection demand and the data collection plan. For example, in a tap water supply system in a city, in order to fully understand the change of tap water residual chlorine, one month can be set as the target monitoring cycle, that is, the first moment is 0:0:00 at the beginning of the month, and the second moment is 23:59:59 at the end of the month.

[0147] After determining the target monitoring period, the computer system obtains the initial tap water residual chlorine test data within the time period from the relevant data storage medium or data source. These data are usually collected in real time by residual chlorine detection equipment set up at various monitoring points in the tap water supply system. These detection equipment can be instruments based on chemical colorimetry, electrochemical method or other advanced detection technology, which can measure the residual chlorine content in tap water regularly or in real time, and transmit the detection data to the computer system for storage and processing.

[0148] For example, assuming that residual chlorine detection equipment is installed at the outlet of a water plant, at key nodes in several water supply areas, and at some user terminals, these devices will collect data on the residual chlorine content of tap water at regular intervals (such as every hour) and send the data to the database of the computer system. When the computer system executes step S11, it will query and obtain the residual chlorine detection data collected by all detection equipment within the target monitoring period (such as a certain month) from the database, and these data constitute the initial tap water residual chlorine detection data.

[0149] In step S12, after obtaining the initial tap water residual chlorine detection data, the computer system performs multi-scale data extraction on these data to obtain multiple periodic data as subsequent tap water residual chlorine detection training data. Multi-scale data extraction is a data processing method that can analyze and process data from different time scales to reveal the characteristics and laws of the data at different time scales.

[0150] Specifically, the computer system can determine a set of different time scales, which can be selected according to actual needs and data characteristics. For example, hours, days, weeks, etc. can be selected as different time scales. Assume that the three time scales of hours, days and weeks are selected for multi-scale data extraction.

[0151] For each selected time scale, the computer system performs corresponding aggregation operations on the initial tap water residual chlorine test data. Taking the hourly time scale as an example, the computer system aggregates the residual chlorine test data collected every hour. The specific aggregation method can be to calculate the average value, median, maximum value, minimum value and other statistics. For example, using the average value method, for the residual chlorine test data of the ith hour, (where n represents the number of data points collected in the i-th hour), then the aggregate data yi for that hour can be calculated using the following formula: Similarly, for the daily time scale, the computer system further aggregates the aggregated data of each hour within each day (if hour-scale aggregation has been performed) or the original detection data. Assuming that there are 24 hours in a day, for the residual chlorine detection data of the kth day (If hourly aggregation has been performed), the aggregated data zk for that day can be calculated using the following formula: ; For the weekly time scale, the computer system aggregates the aggregated data for each day of the week (if it has been aggregated on a daily scale). Assuming there are 7 days in a week, for the residual chlorine test data of week m (If daily aggregation has been performed), the aggregated data wm for the week can be calculated using the following formula: .

[0152] By aggregating data at different time scales, the computer system can obtain multiple periodic data. These periodic data reflect the changes in residual chlorine in tap water at different time scales. For example, periodic data at the hourly scale can reflect the fluctuations in residual chlorine in tap water at different time periods within a day; periodic data at the daily scale can reflect the average level of residual chlorine in tap water every day within a week; and periodic data at the weekly scale can reflect the overall trend of residual chlorine in tap water every week within a month.

[0153] To illustrate with a specific example, suppose that in the initial tap water residual chlorine test data of a certain month, the residual chlorine test data collected from 0:00 to 1:00 on January 1 is , after aggregation according to the hourly scale, we get the aggregated data y1 for that hour. Similarly, the data collected from 1:00 to 2:00 on January 1st is aggregated to get y2, and so on, to get the aggregated data for 24 hours on January 1st. Then, the aggregated data of these 24 hours are aggregated on a daily basis to obtain the aggregated data z1 for January 1. Then, the data of January 2, January 3, etc. are processed in the same way to obtain the aggregated data for each day of January. Finally, the aggregated data of these days are aggregated according to the weekly scale to obtain the aggregated data w1, w2, w3, and w4 of each week in January (assuming there are 4 weeks in January). The aggregated data yi, zk, and wm at different time scales constitute multiple periodic data.

[0154] The computer system uses these multiple periodic data as multiple tap water residual chlorine detection training data for subsequent training and debugging of the basic residual chlorine prediction algorithm. Through multi-scale data extraction, we can have a more comprehensive understanding of the changing patterns of tap water residual chlorine and improve the accuracy and reliability of the prediction algorithm. For example, when predicting the residual chlorine content of tap water at a certain moment in the future, the algorithm can comprehensively consider historical data at different time scales to better capture the periodicity and trend characteristics in the data, thereby making more accurate predictions.

[0155] Based on the foregoing embodiments, the embodiments of the present application provide a tap water residual chlorine prediction device. The various units included in the device and the various modules included in each unit can be implemented by a processor in a computer device; of course, they can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0156] Figure 2 A schematic diagram of the composition structure of a tap water residual chlorine prediction device provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the tap water residual chlorine prediction device 200 includes: The data acquisition module 210 is used to acquire the historical detection data of residual chlorine in tap water; The algorithm calling module 220 is used to load the tap water residual chlorine historical detection data into the debugged converged target residual chlorine prediction algorithm, predict the tap water residual chlorine historical detection data based on the target residual chlorine prediction algorithm, and obtain the tap water residual chlorine prediction result.

[0157] Among them, the target residual chlorine prediction algorithm is obtained by training the tap water residual chlorine prediction method based on deep learning in the aforementioned embodiment.

[0158] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.

[0159] It should be noted that in the embodiment of the present application, if the above-mentioned deep learning-based tap water residual chlorine prediction method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0160] An embodiment of the present application provides a computer system, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0161] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0162] Figure 3 A hardware entity diagram of a computer system provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the hardware entity of the computer system 1000 includes: a processor 1001 and a memory 1002, wherein the memory 1002 stores a computer program that can be run on the processor 1001, and the processor 1001 implements the steps in the method of any of the above embodiments when executing the program.

[0163] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the method for predicting residual chlorine in tap water based on deep learning as in any of the above embodiments.

[0164] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A method for predicting residual chlorine in tap water based on deep learning, characterized in that: include: Acquire historical detection data of residual chlorine in tap water, and predict the historical detection data of residual chlorine in tap water based on a target residual chlorine prediction algorithm to obtain a prediction result of residual chlorine in tap water; Wherein, the debugging process of the target residual chlorine prediction algorithm includes: Obtaining a basic residual chlorine prediction algorithm and a plurality of tap water residual chlorine detection training data, wherein the plurality of tap water residual chlorine detection training data are initial time series training data obtained by continuously sparsely extracting initial tap water residual chlorine detection data; Loading the plurality of tap water residual chlorine detection training data into the time series data embedding mapping operator of the basic residual chlorine prediction algorithm to obtain a plurality of time series representation vectors, wherein the time series representation vectors are used to describe the historical dependency of the tap water residual chlorine detection training data; Loading the multiple time series characterization vectors into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain multiple time series reasoning data, the prediction analysis operator is used to perform data fitting according to the time series characterization vectors; Generate a plurality of first periodic representation vectors according to the plurality of tap water residual chlorine detection training data, and generate a plurality of second periodic representation vectors according to the plurality of time series reasoning data; Obtaining an overall debugging evaluation index of the basic residual chlorine prediction algorithm through the multiple time series characterization vectors, the multiple time series reasoning data, the multiple first periodic characterization vectors, and the multiple second periodic characterization vectors; When the overall debugging evaluation index meets the debugging stop requirement, the target residual chlorine prediction algorithm is obtained.

2. The method according to claim 1, characterized in that The step of obtaining an overall debugging evaluation index of the basic residual chlorine prediction algorithm through the multiple time series characterization vectors, the multiple time series reasoning data, the multiple first periodic characterization vectors, and the multiple second periodic characterization vectors includes: Acquire a first debugging evaluation index by combining the plurality of timing representation vectors with the plurality of timing reasoning data, wherein the first debugging evaluation index is used to evaluate and correct the timing reasoning data; Acquire a second debugging evaluation index by combining the plurality of first periodic characterization vectors with the plurality of second periodic characterization vectors, wherein the second debugging evaluation index is used to evaluate and correct the periodic distribution intensity of the temporal reasoning data; The overall debugging evaluation index is acquired based on the first debugging evaluation index and the second debugging evaluation index.

3. The method according to claim 2, characterized in that The step of combining the plurality of timing representation vectors with the plurality of timing reasoning data to obtain a first debugging evaluation indicator includes: Determine a Huber loss value between each time series representation vector in the multiple time series representation vectors and each time series reasoning data in the multiple time series reasoning data, and determine the Huber loss value as a first debugging evaluation indicator; The step of combining the plurality of first periodic characterization vectors with the plurality of second periodic characterization vectors to obtain a second debugging evaluation indicator includes: Combining the multiple first periodic characterization vectors with the multiple second periodic characterization vectors to obtain a first sub-debugging evaluation index, and combining the multiple first periodic characterization vectors with the multiple second periodic characterization vectors to obtain a second sub-debugging evaluation index, wherein the first sub-debugging evaluation index is used to evaluate and correct the distribution similarity of the timing reasoning data and the timing characterization vector in each periodic interval, and the second sub-debugging evaluation index is used to evaluate and correct the distribution similarity of the timing reasoning data and the timing characterization vector in each periodic interval; The sum of the first debugging evaluation index and the second debugging evaluation index is used as the second debugging evaluation index.

4. The method according to claim 3, characterized in that The step of combining the plurality of first periodic characterization vectors with the plurality of second periodic characterization vectors to obtain a first sub-debugging evaluation indicator includes: Obtaining a first periodic probability of the first periodic characterization vector corresponding to an m-th periodic interval in each periodic interval and a second periodic probability of the second periodic characterization vector corresponding to the m-th periodic interval, where m≥1; When the product obtained by multiplying the first periodic probability and the weight factor is obtained, the product is divided by the second periodic probability to obtain a quotient value, and the quotient value is determined as the distribution similarity comprehensive value of the mth periodic characterization vector set, wherein different periodic characterization vector sets correspond to the first periodic characterization vector and the second periodic characterization vector of different periodic intervals, and the weight factor is the result of the first periodic probability being exponentially processed by a set value; When the distribution similarity comprehensive values ​​of each periodic characterization vector set are obtained according to the calculation method of the distribution similarity comprehensive value of the mth periodic characterization vector set, the sum of the distribution similarity comprehensive values ​​of each periodic characterization vector set is used as the first sub-debugging evaluation indicator; The step of combining the plurality of first periodic characterization vectors with the plurality of second periodic characterization vectors to obtain a second sub-debugging evaluation indicator includes: Obtaining a JS divergence between the first periodic probability and the second periodic probability, and determining the JS divergence as a distribution similarity value of the mth periodic characterization vector set; When the distribution similarity values ​​of each periodic characterization vector set are obtained according to the calculation method of the distribution similarity value of the mth periodic characterization vector set, the sum of the distribution similarity values ​​of each periodic characterization vector set is used as the second sub-debugging evaluation indicator.

5. The method according to claim 2, characterized in that: Before acquiring the overall debugging evaluation indicator based on the first debugging evaluation indicator and the second debugging evaluation indicator, the method includes: Obtaining a third periodic probability of a target periodic characterization vector element corresponding to an n-th periodic interval in each periodic interval and a second periodic probability of the second periodic characterization vector corresponding to the n-th periodic interval, wherein the first periodic characterization vector includes the target periodic characterization vector element, and n≥1; Using the norm of the difference between the third periodic probability and the second periodic probability as the local periodic intensity value of the nth periodic characterization vector set; When the local periodic strength values ​​of each periodic characterization vector set are obtained according to the calculation method of the local periodic strength value of the nth periodic characterization vector set, the sum of the local periodic strength values ​​of each periodic characterization vector set is used as a third debugging evaluation indicator, wherein the third debugging evaluation indicator is used to evaluate and correct the local periodic strength of the time series reasoning data; The acquiring the overall debugging evaluation indicator based on the first debugging evaluation indicator and the second debugging evaluation indicator includes: The first debugging evaluation index, the second debugging evaluation index and the third debugging evaluation index are integrated to obtain the overall debugging evaluation index.

6. The method according to any one of claims 1 to 5, characterized in that The step of loading the multiple time series characterization vectors into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain multiple time series reasoning data includes: Combining the multiple time series representation vectors to obtain a target time series representation vector sequence; Each time series representation vector in the target time series representation vector sequence is loaded into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain target reasoning data, wherein the target reasoning data includes the multiple time series reasoning data.

7. The method according to any one of claims 1 to 5, characterized in that The method of acquiring the historical detection data of residual chlorine in tap water and predicting the historical detection data of residual chlorine in tap water based on the target residual chlorine prediction algorithm to obtain the prediction result of residual chlorine in tap water includes: When a residual chlorine prediction command generated for the tap water residual chlorine historical detection data is received, the tap water residual chlorine historical detection data is loaded into the time series data embedding mapping operator of the target basic residual chlorine prediction algorithm to obtain a plurality of data characterization vectors, wherein the data characterization vectors are used for historical dependence on the tap water residual chlorine historical detection data; Loading the multiple data representation vectors into the prediction analysis operator of the target residual chlorine prediction algorithm to obtain multiple data prediction results; The multiple data prediction results are merged to obtain a merged target data prediction result.

8. The method according to any one of claims 1 to 5, characterized in that The method of obtaining a basic residual chlorine prediction algorithm and a plurality of tap water residual chlorine detection training data includes: Acquire initial tap water residual chlorine detection data of a target monitoring period, wherein the target monitoring period represents a time period from a first moment to a second moment; Multi-scale data extraction is performed on the initial tap water residual chlorine detection data to obtain multiple periodic data, and the multiple periodic data are used as the multiple tap water residual chlorine detection training data.

9. A tap water residual chlorine prediction device, characterized in that: include: A data acquisition module is used to obtain historical detection data of residual chlorine in tap water; An algorithm calling module is used to load the tap water residual chlorine historical detection data into the debugged converged target residual chlorine prediction algorithm, and predict the tap water residual chlorine historical detection data based on the target residual chlorine prediction algorithm to obtain the tap water residual chlorine prediction result; Wherein, the target residual chlorine prediction algorithm is obtained by debugging the basic residual chlorine prediction algorithm, and the debugging process of the basic residual chlorine prediction algorithm includes: Obtaining a basic residual chlorine prediction algorithm and a plurality of tap water residual chlorine detection training data, wherein the plurality of tap water residual chlorine detection training data are initial time series training data obtained by continuously sparsely extracting initial tap water residual chlorine detection data, and the basic residual chlorine prediction algorithm is configured to predict the tap water residual chlorine data of a predefined time period based on the tap water residual chlorine historical detection data; Loading the plurality of tap water residual chlorine detection training data into the time series data embedding mapping operator of the basic residual chlorine prediction algorithm to obtain a plurality of time series representation vectors, wherein the time series data embedding mapping operator is used to perform data embedding mapping on the tap water residual chlorine detection training data, and the time series representation vector is used to describe the historical dependency of the tap water residual chlorine detection training data; Loading the multiple time series characterization vectors into the prediction analysis operator of the basic residual chlorine prediction algorithm to obtain multiple time series reasoning data, wherein the prediction analysis operator is used to perform data fitting according to the time series characterization vectors; Generate a plurality of first periodic characterization vectors according to the plurality of tap water residual chlorine detection training data, and generate a plurality of second periodic characterization vectors according to the plurality of time series reasoning data, wherein the first periodic characterization vector is used to describe the periodic distribution intensity of the tap water residual chlorine detection training data, and the second periodic characterization vector is used to describe the periodic distribution intensity of the time series reasoning data; Obtaining an overall debugging evaluation index of the basic residual chlorine prediction algorithm through the multiple time series characterization vectors, the multiple time series reasoning data, the multiple first periodic characterization vectors, and the multiple second periodic characterization vectors, wherein the overall debugging evaluation index is used to evaluate the debugging status of the basic residual chlorine prediction algorithm; When the overall debugging evaluation index meets the debugging stop requirement, the target residual chlorine prediction algorithm is obtained.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 8 are implemented.