Water bloom prediction model and method based on multi-scale time sequence convolutional neural network
The multi-scale temporal convolutional neural network model addresses the limitations of existing algal bloom prediction models by integrating data preprocessing, feature enhancement, and adaptive periodicity analysis to achieve accurate and reliable water bloom predictions.
Patent Information
- Application Number
- CN202411012080.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-12-03
AI Technical Summary
Existing algal bloom prediction models suffer from low prediction accuracy due to the inability to effectively capture long-distance dependencies and feature information of different scales, requiring extensive manual feature engineering.
A water bloom prediction model based on a multi-scale temporal convolutional neural network, incorporating a wavelet data preprocessing module, feature embedding module, time-frequency feature enhancement module, two-dimensional convolution feature extraction module, and adaptive periodicity analysis module to enhance feature representation and prediction accuracy.
The model effectively captures complex time series characteristics, improves data quality, and enhances feature expression, leading to high-precision water bloom predictions, supporting water resources management and environmental protection.
Smart Images

Figure CN119066348A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water bloom prediction, and in particular to a water bloom prediction model and method based on a multi-scale temporal convolutional neural network. Background Art
[0002] The main technologies used in the algae bloom prediction method based on multi-scale time series convolutional neural network are time series convolution technology (Time Series Convolution) and deep learning technology (Deep Learning). Its main purpose is to predict algae bloom with the help of monitored meteorological and hydrological time series data (including time, air temperature, air pressure, temperature, wind speed, rainfall, conductivity, water temperature, pH value, dissolved oxygen, turbidity, chlorophyll, etc.) information.
[0003] In order to effectively utilize various data feature information in different time periods, time series convolution technology has been designed, which enables the model to improve its ability to understand and characterize data according to different time periods and different types of features. Because by applying the time series convolution method, data information between different types and periods can be integrated, data of different types can complement each other, and future data can be inferred, which improves the model's ability to understand complex nonlinear data features, effectively improves the performance of the model and reduces the risk of overfitting. Therefore, the performance of the time series convolution model is often better than that of ordinary regression-based models and LSTM models based on gated units. The time series convolution model can efficiently extract local patterns and features in time series, and is particularly suitable for capturing local dependencies and changing trends in time series. These characteristics make the time series convolution model of great significance in various time series data prediction applications.
[0004] The existing algal bloom prediction methods mainly have the following defects:
[0005] 1) Existing water bloom prediction models are partly based on traditional disease prediction methods and prediction methods based on long short-term memory networks (LSTM). The performance of the models is not good enough, and most models may still not be able to effectively capture long-distance dependencies when dealing with particularly long time series;
[0006] 2) Existing algal bloom prediction models are unable to fully exploit the information of the dataset itself and cannot effectively extract feature information of different scales through multi-layer convolution like convolutional neural networks;
[0007] 3) Existing algal bloom prediction methods require a lot of time on manual feature engineering processing, and the utilization of features needs to be improved. Summary of the invention
[0008] The main purpose of the present invention is to provide a water bloom prediction model and method based on a multi-scale temporal convolutional neural network to solve the problems that the existing water bloom prediction methods have low prediction accuracy and fail to comprehensively utilize long-distance time dependencies and feature information of different scales.
[0009] In order to solve the above technical problems, the technical solution adopted by the present invention is: a water bloom prediction model based on a multi-scale time series convolutional neural network, including a wavelet data preprocessing module, a feature embedding module, a multi-scale time series convolution module and a prediction module, wherein the multi-scale time series convolution module includes a time-frequency feature enhancement module, a two-dimensional convolution feature extraction module and an adaptive periodicity analysis module, specifically including:
[0010] Wavelet data preprocessing module: responsible for the preliminary processing of the original time series data to ensure data quality and integrity, including screening out features with a large number of missing data, using the mean and standard deviation method or the quantile method to detect and delete outliers, using wavelet decomposition to denoise and smooth the data, and interpolating the missing data to obtain preprocessed data;
[0011] Feature embedding module: The feature extraction module is responsible for embedding the original time series data, encoding the data through multiple methods such as numerical embedding, position embedding and time embedding to enhance the feature representation capability;
[0012] Time-frequency feature enhancement module: Perform frequency domain analysis on time series data through fast Fourier transform, obtain frequency domain representation, calculate the amplitude of the spectrum to obtain the main frequency components, and calculate the average amplitude of the period and corresponding frequency components to enhance the features of the original time series data to obtain the enhanced features;
[0013] Two-dimensional convolution feature extraction module: It upgrades the time series data from 1D convolution to 2D convolution, extracts multi-scale time series features through a two-dimensional convolutional neural network, enhances the model's ability to recognize complex time series patterns, and obtains the extracted feature vector;
[0014] Adaptive periodicity analysis module: uses adaptive algorithms to analyze and weight the extracted periodic features, extract key features from time series data, and obtain optimized feature vectors;
[0015] Prediction module: Use the linear projection layer to restore the output scale of the model to the original scale of the data, comprehensively process the time series characteristics and periodic information, predict the water source information, and output the future water source information status.
[0016] In the preferred embodiment, the wavelet data preprocessing module specifically includes the following steps:
[0017] S01. Calculate the percentage of missing values in each column of the sample population, set the missing value tolerance threshold, and remove the missing values in the feature column if the number of missing values is higher than the tolerance threshold;
[0018] S02. Use the mean and standard deviation method to detect and delete outliers, set the standard deviation tolerance threshold, determine the normal value range through the range of the mean and standard deviation, and eliminate all sample data that are not within the normal value range;
[0019] S03, using wavelet decomposition to perform multi-resolution analysis on the data after missing values and outliers are processed, removing noise through thresholding, and retaining useful data rows;
[0020] S04. Perform piecewise linear interpolation processing on the denoised data so that each time slice has the same sample size, thereby obtaining the final preprocessed data.
[0021] In the preferred embodiment, the feature embedding module specifically includes the following steps:
[0022] S11. Get the data Data from the wavelet data preprocessing module and perform three types of embedding, namely value embedding, position embedding and time embedding. The value embedding applies a 1D convolutional layer to convert the input features into the embedding E. value , the position embedding is used to encode the position of each token in the sequence, resulting in the embedding E position , time embedding integrates month, week, date and hour to add embedding E temporal , to integrate the time features, the formula is as follows:
[0023] E value =ValueEmbadding(Data feature );
[0024] E position =PositionalEncoding(Data feature );
[0025] E temporal = TemporalEmbedding(Data mark );
[0026] Data feature Represents the features in the data, and Data mark Represents time stamps in data;
[0027] S12. Integrate the three different embeddings to get the final data embedding representation X, the formula is as follows:
[0028]
[0029] in, It means that each element of the matrix is added element by element.
[0030] In the preferred embodiment, the time-frequency feature enhancement module specifically includes the following steps:
[0031] S21, embed the time series data into the representation X and input it into the time-frequency feature enhancement module, apply fast Fourier transform in the time dimension, and obtain the single-sided spectrum representation XF. The specific encoding formula is as follows:
[0032] XF = FFT(X);
[0033] Among them, XF represents the single-sided spectrum representation obtained after the time series data feature is transformed by fast Fourier transform, and FFT represents fast Fourier transform;
[0034] S22. Calculate the amplitude of the spectrum and take its mean in the batch dimension Batch and the channel dimension Channels to obtain the average amplitude mean_frequency_list of each frequency component. The specific calculation formula is as follows:
[0035]
[0036] Here B represents the total number of batches, b represents each batch, C represents the total number of feature channels, and c represents each feature channel;
[0037] S23. Find the index of the first k frequency components with the largest amplitude, and obtain the main frequency component top_frequency_list. The specific calculation is as follows:
[0038] top_frequency_list=TopK(mean_frequency_list,k);
[0039] Here, k represents a hyperparameter, which specifies the index of how many frequency components to select;
[0040] S24, the period is calculated by dividing the total number of elements of the data embedding representation X by the index of the main frequency component, and the obtained period and the average amplitude of the corresponding frequency component are calculated by the following specific formula:
[0041] period list , period weight =ToPeriod(X,XF,top_frequency_list);
[0042] Among them, period_list represents the main period, and period_weight represents the weight of the corresponding frequency component.
[0043] In the preferred embodiment, the two-dimensional convolution feature extraction module specifically includes the following steps:
[0044] S31, input period_list into the two-dimensional convolution feature extraction module;
[0045] S32. Apply a processing transformation to the period corresponding to each frequency component and rearrange it into a shape suitable for 2D convolution. The specific calculation formula is as follows:
[0046] conv_tensor i =padding_and_reshape(period i );
[0047] Here, period i Represents each major period in period_list, conv_tensor i Represents the corresponding feature matrix associated with each period after padding and shape transformation and suitable for 2D convolution;
[0048] S33, applying a two-dimensional convolution block to perform feature extraction, rearranging the convolution results back to the original shape, and stacking the result list along the new dimension to obtain the final two-dimensional convolution feature;
[0049] conv_output i =2DConv(conv_tensor i );
[0050] feature_matrix=Stack(reshape(conv_output i ));
[0051] Here, conv_output i Represents the conv_tensor of each major cycle i The feature matrix output by the 2D convolution mechanism, reshape represents the process of rearranging it back to its original shape, and feature_matrix represents the conv_output of each cycle i The final feature matrix is obtained by superimposing them.
[0052] In the preferred embodiment, the adaptive periodicity analysis module specifically includes the following steps:
[0053] S41, inputting feature_matrix and period_weight into an adaptive periodicity analysis module;
[0054] S42, performing adaptive periodicity analysis on period_weight to obtain vector X, the specific calculation formula is as follows:
[0055]
[0056] Among them, weight represents the result of period_weight adaptive periodic analysis, and Softmax is used to scale the weight to the range of [0,1];
[0057] S43, expand the dimension of weight to use it as a weight matrix to perform operations with feature_matrix to obtain the result weight′. The specific calculation formula is as follows:
[0058] weight′=repeat_and_unsqueeze(weight);
[0059] Among them, repeat_and_unsqueeze is a function used to expand the dimension.
[0060] S44, weight′ and feature_matrix are calculated and summed, and then residual connection is performed with the original input data embedding X to obtain the result feature_weighted. The specific calculation formula is as follows:
[0061]
[0062] Among them, feature_weighted represents the result of the analysis by the adaptive periodicity analysis module, and Sum is a function that sums by dimension. represents matrix multiplication, It means that each element of the matrix is added element by element.
[0063] In the preferred embodiment, the prediction module specifically includes the following steps:
[0064] S51, input the feature_weighted after the adaptive periodicity analysis module into a linear projection layer, project it back to the output space, and obtain an output sequence with the same dimension as the input sequence, that is, the final prediction result. The specific calculation formula is as follows:
[0065] result_forecast=Projection(feature_weighted);
[0066] Among them, Projection is a linear projection layer, which is used to convert the results processed by the previous module into a true prediction sequence.
[0067] The present invention also provides a prediction method for a water bloom prediction model based on a multi-scale temporal convolutional neural network, comprising the following steps:
[0068] S1, the original data enters the wavelet data preprocessing module, and after missing values and outliers are screened, wavelet transform denoised, and piecewise linear interpolation, the processed data Data is obtained;
[0069] S2, process the data Data through the feature embedding module, and obtain the embedded representation X of the sample after multiple feature embedding processes;
[0070] S3. Build a multi-scale time series convolutional neural network model, and then process the sample embedding representation X by combining the time-frequency feature enhancement module, the two-dimensional convolution feature extraction module and the adaptive periodicity analysis module to obtain the processed feature vector feature_weighted.
[0071] S4. Use the linear projection layer to transform the dimension according to feature_weighted, project it to the dimension of the original data Data, and output the final prediction sequence.
[0072] S5. Establish a complete model for water bloom prediction based on a multi-scale time series convolutional neural network and train the model.
[0073] In the preferred embodiment, in step S5, the model is trained, specifically comprising the following steps:
[0074] S61, input the characteristics of the sample into the model to obtain X and y;
[0075] S62, then calculate the corresponding loss function Loss according to the corresponding true label and the result obtained in the previous step, where the loss function uses the mean square error function MSELoss;
[0076] S63, calculate the gradient according to Loss and back propagate to update the parameters;
[0077] S64, if the number of iterations is less than Epoch, return to step S61, otherwise go to the next step;
[0078] S65. The obtained model parameters are verified on the training set to obtain corresponding verification results.
[0079] The present invention provides a water bloom prediction model based on a multi-scale time series convolutional neural network. The wavelet data preprocessing module eliminates noise and outliers to ensure data quality. The feature embedding module integrates numerical values, positions and time embedding to enhance feature expression. The time-frequency feature enhancement module uses FFT to extract key spectrum information. The two-dimensional convolution feature extraction module analyzes time series patterns from multiple scales. The adaptive periodicity analysis module optimizes periodic features. The prediction module integrates the processed features through linear projection to generate a prediction of future water source status. The entire model designs preprocessing, feature enhancement and prediction processes, uses a multi-scale convolutional network to capture complex time series characteristics, optimizes parameters through training iterations, and finally achieves high-precision water bloom prediction, providing strong support for water resources management and environmental protection. A method for a water bloom prediction model based on a multi-scale time series convolutional neural network is provided. These modules are integrated to form a prediction method based on a multi-scale time series convolutional neural network to improve the accuracy and effect of the final water bloom prediction.
[0080] The beneficial effects of the present invention are:
[0081] 1) Through the wavelet data preprocessing module, the noise and outliers in the original data are effectively removed, the quality of the data is improved, and thus the prediction accuracy of the model is improved.
[0082] 2) The present invention uses a combination of multiple embedding methods to extract rich feature representations, which can more fully mine and utilize data information of different scales to form information complementarity and accurate prediction.
[0083] 3) The present invention uses a two-dimensional convolution feature extraction mechanism. Different from using only one-dimensional convolution or no convolution, two-dimensional convolution can widely learn different data information from more scales and extract features that are more important for algal bloom prediction. It can effectively accelerate model convergence and reduce noise interference, thereby improving the prediction effect of the model.
[0084] 4) The adaptive periodicity analysis module can automatically learn and utilize periodic patterns in time series data, which is particularly important for natural phenomena with seasonal changes such as algal blooms. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0086] Figure 1 It is a model overall structure diagram of the water bloom prediction method based on multi-scale temporal convolutional neural network proposed in the present invention;
[0087] Figure 2 It is a structural diagram of the multi-scale temporal convolution mechanism of the present invention;
[0088] Figure 3 It is a flow chart of model training of the present invention;
[0089] Figure 4 It is a comparison result diagram of the training and verification of the trained model of the present invention on the tested chlorophyll data set;
[0090] Figure 5 This is a comparison chart of the training and verification results of the model trained by the present invention on the chlorophyll dataset of the entire period;
[0091] Figure 6 This is a comparison chart of the training and verification results of the model trained by the present invention on the data set. DETAILED DESCRIPTION
[0092] Example 1
[0093] like Figures 1 to 6 As shown, a water bloom prediction model based on a multi-scale time series convolutional neural network includes a wavelet data preprocessing module, a feature embedding module, a multi-scale time series convolution module and a prediction module, wherein the multi-scale time series convolution module includes a time-frequency feature enhancement module, a two-dimensional convolution feature extraction module and an adaptive periodicity analysis module, specifically including:
[0094] Wavelet data preprocessing module: responsible for the preliminary processing of the original time series data to ensure data quality and integrity, including screening out features with a lot of missing data, using the mean and standard deviation method or the quantile method to detect and delete outliers, using wavelet decomposition to denoise and smooth the data, and interpolating the missing data to obtain the preprocessed data.
[0095] Feature embedding module: The feature extraction module is responsible for embedding the original time series data, encoding the data through multiple methods such as numerical embedding, position embedding and time embedding to enhance the feature representation capability.
[0096] Time-frequency feature enhancement module: The time series data is analyzed in the frequency domain through fast Fourier transform to obtain the frequency domain representation, the amplitude of the spectrum is calculated to obtain the main frequency components, and the average amplitude of the cycle and the corresponding frequency components is calculated to enhance the features of the original time series data to obtain the enhanced features.
[0097] Two-dimensional convolution feature extraction module: The time series data is upgraded from 1D convolution to 2D convolution, and multi-scale time series features are extracted through a two-dimensional convolutional neural network to enhance the model's ability to recognize complex time series patterns and obtain the extracted feature vector.
[0098] Adaptive periodicity analysis module: uses an adaptive algorithm to analyze and weight the extracted periodic features, extract key features from time series data, and obtain optimized feature vectors.
[0099] Prediction module: Use the linear projection layer to restore the output scale of the model to the original scale of the data, comprehensively process the time series characteristics and periodic information, predict the water source information, and output the future water source information status.
[0100] The present invention provides a water bloom prediction model based on a multi-scale time series convolutional neural network, which realizes accurate understanding and prediction of complex water environments by integrating wavelet preprocessing, multi-dimensional feature embedding, time-frequency analysis, two-dimensional convolution, and adaptive periodicity analysis. It can not only effectively purify raw data and improve the richness of feature expression, but also capture and enhance key patterns in time series, especially the periodicity and multi-scale characteristics of water bloom events. The prediction module converts this refined information into an intuitive water source status forecast, providing a scientific basis for water resources management, environmental monitoring, and ecological balance maintenance, and significantly improving the accuracy and practicality of the prediction.
[0101] In the preferred embodiment, the wavelet data preprocessing module specifically includes the following steps:
[0102] S01. Calculate the percentage of missing values in each column of the sample population and set a missing value tolerance threshold. If the number of missing values in a feature column is higher than the tolerance threshold, it will be removed and will not participate in subsequent model learning.
[0103] S02. Use the mean and standard deviation method to detect and delete outliers, set the standard deviation tolerance threshold, determine the normal value range through the range of the mean and standard deviation, and eliminate all sample data that are not within the normal value range.
[0104] S03. Use wavelet decomposition to perform multi-resolution analysis on the data after missing values and outliers are processed, remove noise through thresholding, and retain useful data rows; the specific process is to first use wavelet decomposition, then estimate the noise standard deviation, threshold the data according to the standard deviation, and finally reconstruct the denoised data.
[0105] S04. Perform piecewise linear interpolation on the denoised data so that each time slice has the same sample size, and obtain the final preprocessed data. Piecewise interpolation can also make the missing value interpolation more consistent with the distribution of adjacent time periods, and obtain the final preprocessed data.
[0106] The wavelet data preprocessing module improves data quality. Features with high proportion of missing values are eliminated to prevent invalid information from interfering with model learning. Statistical methods are used to accurately identify and exclude outliers to ensure that the data set reflects the real situation. Threshold denoising is implemented by utilizing the multi-resolution characteristics of wavelet decomposition to effectively retain the core components of the signal. Missing values are filled by piecewise linear interpolation to ensure the continuity and consistency of the time series. The above steps improve data quality, optimize model input, lay a solid foundation for subsequent feature extraction and prediction, and significantly improve the performance and reliability of the water bloom prediction model.
[0107] In the preferred embodiment, the feature embedding module specifically includes the following steps:
[0108] S11. Get the data Data from the wavelet data preprocessing module and perform three types of embedding, namely value embedding, position embedding and time embedding. The value embedding applies a 1D convolutional layer to convert the input features into the embedding E. value , the position embedding is used to encode the position of each token in the sequence, resulting in the embedding E position , time embedding integrates month, week, date and hour to add embedding E temporal , to integrate the time features, the formula is as follows:
[0109] E value =ValueEmbadding(Data feature );
[0110] E position =PositionalEncoding(Data feature );
[0111] E temporal = TemporalEmbedding(Data mark );
[0112] Data feature Represents the features in the data, and Data mark Represents time stamps in data;
[0113] S12. Integrate the three different embeddings to get the final data embedding representation X, the formula is as follows:
[0114]
[0115] in, It is represented as the element-by-element addition of each matrix element.
[0116] The feature embedding module significantly enhances the model's ability to understand complex time series data through triple processing of numerical embedding, position embedding, and time embedding. Numerical embedding transforms the original features through 1D convolutional layers to extract the deep representation of numerical information; position embedding encodes the relative position of each element in the data sequence to help the model understand the sequence structure; time embedding integrates time attributes such as month, week, date, and hour to capture periodic patterns. The combined use of these three types of embedding not only enriches the input features, but also enables the model to more accurately capture the time dependency and periodicity in the data, greatly improving the performance of the prediction model, especially in tasks such as algal bloom prediction involving seasonality and time series analysis.
[0117] In the preferred embodiment, the time-frequency feature enhancement module specifically includes the following steps:
[0118] S21, embed the time series data into the representation X and input it into the time-frequency feature enhancement module, apply fast Fourier transform in the time dimension, and obtain the single-sided spectrum representation XF. The specific encoding formula is as follows:
[0119] XF = FFT(X);
[0120] Among them, XF represents the single-sided spectrum representation obtained after the time series data features are transformed by fast Fourier transform, and FFT represents fast Fourier transform.
[0121] S22. Calculate the amplitude of the spectrum and take its mean in the batch dimension Batch and the channel dimension Channels to obtain the average amplitude mean_frequency_list of each frequency component. The specific calculation formula is as follows:
[0122]
[0123] Here, B represents the total number of batches, b represents each batch, C represents the total number of feature channels, and c represents each feature channel.
[0124] S23. Find the index of the first k frequency components with the largest amplitude, and obtain the main frequency component top_frequency_list. The specific calculation is as follows:
[0125] top_frequency_list=TopK(mean_frequency_list,k);
[0126] Here, k represents a hyperparameter, which specifies the index of how many frequency components to select.
[0127] S24, the period is calculated by dividing the total number of elements of the data embedding representation X by the index of the main frequency component, and the obtained period and the average amplitude of the corresponding frequency component are calculated by the following specific formula:
[0128] periodlist, periodweight=ToPeriod(X,XF,top__frequency_list);
[0129] Among them, period_list represents the main period, and period_weight represents the weight of the corresponding frequency component.
[0130] The time-frequency feature enhancement module converts time series data into the frequency domain through fast Fourier transform to obtain the periodic patterns hidden in the time series. The module first calculates the average of the spectrum amplitude to highlight the main frequency components, and then identifies the most influential frequencies, namely the main frequency components, which helps to capture the periodic characteristics of the data. By calculating the period and assigning corresponding weights, the model can focus on the periodic information most relevant to the prediction, effectively enhancing the ability to recognize the periodic changes of algal bloom events, thereby improving the accuracy of the prediction and the robustness of the model. This method is crucial for understanding and predicting changes in water environments with periodic characteristics.
[0131] In the preferred embodiment, the two-dimensional convolution feature extraction module specifically includes the following steps:
[0132] S31. Input period_list into the two-dimensional convolution feature extraction module.
[0133] S32. Apply a processing transformation to the period corresponding to each frequency component and rearrange it into a shape suitable for 2D convolution. The specific calculation formula is as follows:
[0134] conv_tensor i =padding_and_reshape(period i );
[0135] Here, period i Represents each major period in period_list, conv_tensor i Represents the corresponding feature matrix associated with each period after padding and shape transformation and suitable for 2D convolution.
[0136] S33, applying a two-dimensional convolution block to perform feature extraction, rearranging the convolution results back to the original shape, and stacking the result list along the new dimension to obtain the final two-dimensional convolution feature;
[0137] conv_output i=2DConv(conv_tensor i );
[0138] feature_matrix=Stack(reshape(conv_output i ));
[0139] Here, conv_output i Represents the conv_tensor of each major cycle i The feature matrix output by the 2D convolution mechanism, reshape represents the process of rearranging it back to its original shape, and feature_matrix represents the conv_output of each cycle i The final feature matrix is obtained by superimposing them.
[0140] The 2D convolution feature extraction module effectively captures the spatial and temporal correlation of the data by converting the time series data into a form suitable for 2D convolution. This module maps the periodic information into a two-dimensional space and uses the convolution kernel to scan at different scales to extract multi-scale feature representations. This method not only enhances the model's ability to recognize local patterns, but also promotes the integration of global features, enabling the model to better understand the complex dynamics of water bloom events, especially when dealing with data with periodic and spatial distribution characteristics, significantly improving the accuracy of predictions and the interpretability of the model.
[0141] In the preferred embodiment, the adaptive periodicity analysis module specifically includes the following steps:
[0142] S41, input feature_matrix and period_weight into the adaptive periodicity analysis module.
[0143] S42, performing adaptive periodicity analysis on period_weight to obtain vector X, the specific calculation formula is as follows:
[0144]
[0145] Among them, weight represents the result of period_weight adaptive periodic analysis, and Softmax is used to scale the weight to the range of [0,1] for subsequent calculation.
[0146] S43, expand the dimension of weight to use it as a weight matrix to perform operations with feature_matrix to obtain the result weight′. The specific calculation formula is as follows:
[0147] weight′=repeat_and_unsqueeze(weight);
[0148] Among them, repeat_and_unsqueeze is a function used to expand the dimension.
[0149] S44, weight′ and feature_matrix are calculated and summed, and then residual connection is performed with the original input data embedding X to obtain the result feature_weighted. The specific calculation formula is as follows:
[0150]
[0151] Among them, feature_weighted represents the result of the analysis by the adaptive periodicity analysis module, and Sum is a function that sums by dimension. represents matrix multiplication, It means that each element of the matrix is added element by element.
[0152] The adaptive periodicity analysis module improves the model's sensitivity to periodic patterns by weighting periodic features. The Softmax function is used to normalize the periodic weights to ensure that the contribution of each periodic component is within a reasonable range. Through dimensional expansion and weighted summation, the module can intelligently adjust the importance of different periodic features, and finally combine them with the original feature embedding to form a weighted feature representation. It not only enhances the model's capture of key periodic information, but also retains the details of the original features through residual connections, ensuring the accuracy of the prediction and the stability of the model, which is particularly suitable for the accurate grasp of periodic changes in water bloom prediction.
[0153] In the preferred embodiment, the prediction module specifically includes the following steps:
[0154] S51, input the feature_weighted after the adaptive periodicity analysis module into a linear projection layer, project it back to the output space, and obtain an output sequence with the same dimension as the input sequence, that is, the final prediction result. The specific calculation formula is as follows:
[0155] result_forecast=Projection(feature_weighted);
[0156] Among them, Projection is a linear projection layer, which is used to convert the results processed by the previous module into a true prediction sequence.
[0157] The prediction module receives the weighted feature representation output by the adaptive periodicity analysis module, maps these multi-dimensional features back to the scale of the original data through the linear projection layer, and generates a prediction sequence consistent with the dimension of the input sequence. This process ensures the interpretability and practicality of the model output, so that the prediction results directly correspond to the actual observations, which is convenient for direct application to the prediction and monitoring of water bloom events. As the last link, the linear projection layer not only integrates the processing results of all previous modules, but also realizes the accurate regression from abstract feature space to specific physical quantities through inverse scale conversion, thereby providing decision makers with directly available prediction information and enhancing the application value of the model in actual scenarios.
[0158] Example 2
[0159] Further illustrate with reference to Example 1, Figure 1-6 Shown
[0160] The present invention also provides a prediction method for a water bloom prediction model based on a multi-scale temporal convolutional neural network, comprising the following steps:
[0161] S1. The original data enters the wavelet data preprocessing module, and after missing value and outlier screening, wavelet transform denoising, and piecewise linear interpolation, the processed data Data is obtained.
[0162] S2. Process the data Data through the feature embedding module, and after multiple feature embedding processes, obtain the embedded representation X of the sample.
[0163] S3. Build a multi-scale time series convolutional neural network model, and then process the sample embedding representation X by combining the time-frequency feature enhancement module, the two-dimensional convolution feature extraction module and the adaptive periodicity analysis module to obtain the processed feature vector feature_weighted.
[0164] S4. Use the linear projection layer to transform the dimension according to feature_weighted, project it to the dimension of the original data Data, and output the final prediction sequence.
[0165] S5. Establish a complete model for water bloom prediction based on a multi-scale time series convolutional neural network and train the model.
[0166] The invention provides a prediction method of a water bloom prediction model based on a multi-scale time series convolutional neural network, which combines meteorological and hydrological time series data information, wherein the meteorological and hydrological time series data information includes time, air temperature, air pressure, temperature, wind speed, rainfall, conductivity, water temperature, pH value, dissolved oxygen, turbidity and chlorophyll, and uses a plurality of pre-processing methods at the same time, and combines wavelet transform denoising, mean standard deviation outlier screening and piecewise linear interpolation method for joint processing to obtain a data set less affected by noise and outliers; secondly, a plurality of embedding modes such as numerical embedding, position embedding and time embedding are used in combination to obtain a feature representation with richer information; then, the main feature information in the data is extracted by combining time-frequency feature enhancement, two-dimensional convolution feature extraction and adaptive periodicity analysis, and these modules are integrated to form a prediction method based on a multi-scale time series convolutional neural network, so as to improve the accuracy and effect of the final water bloom prediction.
[0167] In the preferred embodiment, in step S5, the model is trained, specifically comprising the following steps:
[0168] S61. Input the characteristics of the sample into the model to obtain X and y.
[0169] S62. Calculate the corresponding loss function Loss according to the corresponding true label and the result obtained in the previous step, where the loss function uses the mean square error function MSELoss.
[0170] S63. Calculate the gradient according to Loss and back-propagate to update the parameters.
[0171] S64. If the number of iterations is less than Epoch, return to step S61, otherwise go to the next step.
[0172] S65. The obtained model parameters are verified on the training set to obtain corresponding verification results.
[0173] The training above describes a typical neural network training cycle in supervised learning. The model receives input features X and produces predictions y, which are then quantified using the mean squared error (MSE) loss function to quantify the difference between the predictions and the true labels. The gradient descent mechanism backpropagates based on this loss and adjusts the model parameters to minimize the error. This process is iterated until a preset number of epochs is reached to ensure that the model has fully learned the data patterns. The trained model is evaluated on an independent validation set to test its generalization ability and ensure that the model can not only learn the training data, but also accurately predict new data. This process helps build models with strong robustness and high prediction accuracy, which is crucial for solving complex problems.
[0174] Example 3
[0175] Further illustrate with reference to Example 1 and Example 2, Figure 1-6As shown, in order to verify the effectiveness of the method, this patent conducted experiments and verification on the data set, such as Figure 4-6 As shown, Figure 4 The figure shows the prediction performance of the optimal solution and the traditional LSTM model-based solution on the test data after training with the same training data. Figure 5 The figure shows the prediction performance of the optimal solution and the traditional LSTM model-based solution on the complete data after training with the same training data. Figure 6 The performance indicators of the optimal solution and the traditional LSTM model-based solution on the test data after training with the same training data are compared. RMSE is the root mean square error, which measures the square root of the average of the squared difference between the predicted value and the actual value. The lower the value, the better the model performance; MAE is the mean absolute error, which measures the average of the absolute difference between the predicted value and the actual value. The lower the value, the better the model performance; R2 is the determination coefficient, which measures the fit of the model to the test data. The closer the value is to 1, the better the model performance; MRE is the mean relative error, which measures the average of the relative difference between the predicted value and the actual value. The lower the value, the better the model performance. The results show that this solution has achieved good prediction results on the data set.
[0176] The above embodiments are only preferred technical solutions of the present invention and should not be regarded as limiting the present invention. The protection scope of the present invention shall be the technical solutions recorded in the claims, including equivalent replacement solutions of the technical features in the technical solutions recorded in the claims. That is, equivalent replacement improvements within this scope are also within the protection scope of the present invention.
Claims
1. A water bloom prediction model based on a multi-scale temporal convolutional neural network, characterized by: It includes a wavelet data preprocessing module, a feature embedding module, a multi-scale time series convolution module and a prediction module. The multi-scale time series convolution module includes a time-frequency feature enhancement module, a two-dimensional convolution feature extraction module and an adaptive periodicity analysis module, which specifically include: Wavelet data preprocessing module: responsible for the preliminary processing of the original time series data, including screening out features with a lot of missing data, using the mean and standard deviation method or the quantile method to detect and delete outliers, using wavelet decomposition to denoise and smooth the data, and interpolating the missing data to obtain the preprocessed data; Feature embedding module: The feature extraction module is responsible for embedding the original time series data and encoding the data through multiple methods such as numerical embedding, position embedding and time embedding; Time-frequency feature enhancement module: Perform frequency domain analysis on time series data through fast Fourier transform, obtain frequency domain representation, calculate the amplitude of the spectrum to obtain the main frequency components, and calculate the average amplitude of the period and corresponding frequency components to enhance the features of the original time series data to obtain the enhanced features; Two-dimensional convolution feature extraction module: The time series data is upgraded from 1D convolution to 2D convolution, and multi-scale time series features are extracted through a two-dimensional convolutional neural network to obtain the extracted feature vector; Adaptive periodicity analysis module: uses adaptive algorithms to analyze and weight the extracted periodic features, extract key features from time series data, and obtain optimized feature vectors; Prediction module: Use the linear projection layer to restore the output scale of the model to the original scale of the data, comprehensively process the time series characteristics and periodic information, predict the water source information, and output the future water source information status.
2. The water bloom prediction model based on multi-scale temporal convolutional neural network according to claim 1 is characterized in that: The wavelet data preprocessing module specifically includes the following steps: S01. Calculate the percentage of missing values in each column of the sample population, set the missing value tolerance threshold, and remove the missing values in the feature column if the number of missing values is higher than the tolerance threshold; S02. Use the mean and standard deviation method to detect and delete outliers, set the standard deviation tolerance threshold, determine the normal value range through the range of the mean and standard deviation, and eliminate all sample data that are not within the normal value range; S03, using wavelet decomposition to perform multi-resolution analysis on the data after missing values and outliers are processed, removing noise through thresholding, and retaining useful data rows; S04. Perform piecewise linear interpolation processing on the denoised data so that each time slice has the same sample size, thereby obtaining the final preprocessed data.
3. The water bloom prediction model based on multi-scale temporal convolutional neural network according to claim 1 is characterized by: feature embedding The module specifically includes the following steps: S11. Get the data Data from the wavelet data preprocessing module and perform three types of embedding, namely value embedding, position embedding and time embedding. The value embedding applies a 1D convolutional layer to convert the input features into the embedding E. value , the position embedding is used to encode the position of each token in the sequence, resulting in the embedding E position , time embedding integrates month, week, date and hour to add embedding E temporal , to integrate the time features, the formula is as follows: E value =ValueEmbadding(Data feature ); E position =PositionalEncoding(Data feature ); E temporal =TemporalEmbedding(Data mark ); Data feature Represents the features in the data, and Data mark Represents time stamps in data; S12. Integrate the three different embeddings to get the final data embedding representation X, the formula is as follows: in, It is represented as the element-by-element addition of each matrix element.
4. The water bloom prediction model based on multi-scale temporal convolutional neural network according to claim 1 is characterized in that: The time-frequency feature enhancement module specifically includes the following steps: S21, embed the time series data into the representation X and input it into the time-frequency feature enhancement module, apply fast Fourier transform in the time dimension, and obtain the single-sided spectrum representation XF. The specific encoding formula is as follows: XF = FFT(X); Among them, XF represents the single-sided spectrum representation obtained after the time series data feature is transformed by fast Fourier transform, and FFT represents fast Fourier transform; S22. Calculate the amplitude of the spectrum and take its mean in the batch dimension Batch and the channel dimension Channels to obtain the average amplitude mean_frequency_list of each frequency component. The specific calculation formula is as follows: Here B represents the total number of batches, b represents each batch, C represents the total number of feature channels, and c represents each feature channel; S23. Find the index of the first k frequency components with the largest amplitude, and obtain the main frequency component top_frequency_list. The specific calculation is as follows: top_frequency_list=TopK(mean_frequency_list,k); Here, k represents a hyperparameter, which specifies the index of how many frequency components to select; S24, the period is calculated by dividing the total number of elements of the data embedding representation X by the index of the main frequency component, and the obtained period and the average amplitude of the corresponding frequency component are calculated by the following specific formula: period list ,period_weight=ToPeriod(X,XF,top_frequency_list); Among them, period_list represents the main period, and period_weight represents the weight of the corresponding frequency component.
5. The water bloom prediction model based on multi-scale temporal convolutional neural network according to claim 1 is characterized in that: The two-dimensional convolution feature extraction module specifically includes the following steps: S31, input period_list into the two-dimensional convolution feature extraction module; S32. Apply a processing transformation to the period corresponding to each frequency component and rearrange it into a shape suitable for 2D convolution. The specific calculation formula is as follows: conv_tensor i =padding_and_reshape(period i ); Here, period i Represents each major period in period_list, conv_tensor i Represents the corresponding feature matrix associated with each period after padding and shape transformation and suitable for 2D convolution; S33, applying a two-dimensional convolution block to perform feature extraction, rearranging the convolution results back to the original shape, and stacking the result list along the new dimension to obtain the final two-dimensional convolution feature; conv_output i =2DConv(conv_tensor i ); feature_matrix=Stack(reshape(conv_output i )); Here, conv_output i Represents the conv_tensor of each major cycle i The feature matrix output by the 2D convolution mechanism, reshape represents the process of rearranging it back to its original shape, and feature_matrix represents the conv_output of each cycle i The final feature matrix is obtained by superimposing them.
6. The water bloom prediction model based on multi-scale temporal convolutional neural network according to claim 1 is characterized by: The periodic analysis module specifically includes the following steps: S41, inputting feature_matrix and period_weight into an adaptive periodicity analysis module; S42, performing adaptive periodicity analysis on period_weight to obtain vector X, the specific calculation formula is as follows: Among them, weight represents the result of period_weight adaptive periodic analysis, and Softmax is used to scale the weight to the range of [0,1]; S43, expand the dimension of weight to use it as a weight matrix to perform operations with feature_matrix to obtain the result weight′. The specific calculation formula is as follows: weight′=repeat_and_unsqueeze(weight); Among them, repeat_and_unsqueeze is a function used to expand the dimension; S44, weight′ and feature_matrix are calculated and summed, and then residual connection is performed with the original input data embedding X to obtain the result feature_weighted. The specific calculation formula is as follows: Among them, feature_weighted represents the result of the analysis by the adaptive periodicity analysis module, and Sum is a function that sums by dimension. represents matrix multiplication, It means that the elements of the matrix are added element by element.
7. The water bloom prediction model based on multi-scale temporal convolutional neural network according to claim 1 is characterized by: The prediction module specifically includes the following steps: S51, input the feature_weighted after the adaptive periodicity analysis module into a linear projection layer, project it back to the output space, and obtain an output sequence with the same dimension as the input sequence, that is, the final prediction result. The specific calculation formula is as follows: result_forecast=Projection(feature_weighted); Among them, Projection is a linear projection layer, which is used to convert the results processed by the previous module into a true prediction sequence.
8. The prediction method of the water bloom prediction model based on a multi-scale temporal convolutional neural network according to any one of claims 1 to 7, characterized in that: The following steps are involved: S1, the original data enters the wavelet data preprocessing module, and after missing values and outliers are screened, wavelet transform denoised, and piecewise linear interpolation, the processed data Data is obtained; S2, process the data Data through the feature embedding module, and obtain the embedded representation X of the sample after multiple feature embedding processes; S3, build a multi-scale time series convolutional neural network model, and then process the sample embedding representation X by combining the time-frequency feature enhancement module, the two-dimensional convolution feature extraction module and the adaptive periodicity analysis module to obtain the processed feature vector feature_weighted; S4. Use the linear projection layer to transform the dimension according to feature_weighted, project it to the dimension of the original data Data, and output the final prediction sequence; S5. Establish a complete model for water bloom prediction based on a multi-scale time series convolutional neural network and train the model.
9. The prediction method of the water bloom prediction model based on a multi-scale temporal convolutional neural network according to claim 8 is characterized by: In step S5, the model is trained, which specifically includes the following steps: S61, input the characteristics of the sample into the model to obtain X and y; S62, then calculate the corresponding loss function Loss according to the corresponding true label and the result obtained in the previous step, where the loss function uses the mean square error function MSELoss; S63, calculate the gradient according to Loss and back propagate to update the parameters; S64, if the number of iterations is less than Epoch, return to step S61, otherwise go to the next step; S65. The obtained model parameters are verified on the training set to obtain corresponding verification results.
Citation Information
Cited By
Space-time decoupling feature fusion method and system based on space-time bidirectional Vision Mama
CN119693751A
Method and system for predicting septicemia risk based on transfer learning and time sequence feature mining
CN119889708A
