Jingwei Li*,
Jia Liu,
Iqbal Muhammad Tauqeer and
Zhiyu Shao
School of Electrical, Energy and Power Engineering, Yangzhou University, No. 88 South University Road, Yangzhou 225009, China. E-mail: jingwei_li@yzu.edu.cn
First published on 9th June 2025
Chemical oxygen demand (COD) is an important indicator of organic pollution in water. It plays a crucial role in assessing water quality and protecting the environment. The rapid and accurate detection of COD is essential for continuous water quality monitoring. Traditional methods are often time-consuming and require chemical reagents. To address these challenges, a novel approach based on a one-dimensional convolutional neural network (1D-CNN) combined with UV-vis spectroscopy is proposed. This method is efficient, fast, and reagent-free, offering significant advantages over conventional techniques. The proposed 1D-CNN method incorporates one-dimensional multi-scale feature fusion to enhance the accuracy of COD detection. The method improves spectral feature extraction by fusing features extracted from three parallel sub-convolutional and pooling layers within the same channel. Experimental results show that the fusion network performs well in COD detection. The proposed method demonstrates superior performance compared to traditional and deep learning methods such as partial least squares regression (PLSR), support vector machines (SVM), artificial neural network (ANN), and 1D-CNNs. It significantly improves the accuracy of UV-vis spectroscopy for COD detection, achieving higher precision in real-time water quality monitoring.
Chemical oxygen demand (COD) is a key indicator employed to assess the degree of water pollution. It represents the mass concentration of oxygen consumed by dissolved substances and suspended matter in water when exposed to strong oxidants like potassium dichromate and potassium permanganate.2 A higher COD value signifies a higher concentration of reducing substances, indicating more severe water pollution. At present, the mainstream methods for determining COD are chemical and physical methods.3 Chemical methods, such as titrimetric and electrochemical analysis, are often complex, slow, and require reagents.4 These limitations hinder real-time detection. Physical methods, like molecular spectroscopy, offer a different approach by identifying and quantifying substances through their emission or absorption spectra.5 Among these, UV-vis spectroscopy has gained widespread use in water quality monitoring due to its fast measurement, convenience, low cost, and high sensitivity. This method is not only environmentally friendly but also highly efficient for real-time monitoring.6 The advantages of UV-vis spectroscopy significantly improve monitoring efficiency, enabling governments to track pollution distribution more effectively and timely.
After obtaining spectral data, it is essential to establish an accurate mapping relationship between UV-vis spectroscopy and COD. Traditional methods mainly focus on preprocessing spectral data to enhance spectral quality and extract relevant spectral features. These preprocessing steps are necessary to reduce interference and improve model performance. After extracting features, statistical or machine learning algorithms are commonly applied to construct COD analysis models. These models aim to establish a quantitative relationship between spectral data and COD concentration.7–9 Fogelman et al.10 proposed a novel approach for the rapid estimation of COD in wastewater samples. This method integrates the mathematical processing of spectral absorbance profiles with artificial neural networks (ANNs). It was necessary to reduce the dimensionality of the input data to optimize the performance of the spectroscopic analysis and improve computational efficiency. Specifically, reducing the size of the input vector was essential for accelerating the training process of the ANN and minimizing storage requirements for the trained model. Key features were systematically extracted from the raw spectral data to achieve this reduction. As a result, the dimensionality of the ANN input vector was significantly decreased from 160 to 10 features, while preserving the relevant information necessary for accurate COD estimation. The reduced-input ANN model was rigorously evaluated against the full-input model. The results demonstrated that COD values predicted using the selected features closely matched those derived from the complete spectral profile. Cao et al.11 investigated a rapid and efficient method for determining COD in aquaculture wastewater using ultraviolet (UV) spectroscopic analysis. The study aimed to enhance the speed and accuracy of COD estimation through advanced modeling and data processing techniques. Four calibration methods were employed and compared to establish an effective prediction model. These included multiple linear regression (MLR), partial least squares (PLS), least squares support vector machine (LS-SVM), and ANN. A variable selection strategy was implemented to reduce the influence of redundant and irrelevant spectral data. The successive projections algorithm (SPA) was adopted to identify efficient wavelengths (EWs) that contribute significantly to the COD prediction. Furthermore, six spectral pretreatment methods were evaluated to improve the quality and consistency of the input data. Among the various modeling and preprocessing combinations, the best performance was observed with the ANN model. This model utilized 11 EWs selected by SPA, in conjunction with the standard normal variate (SNV) pretreatment method, which proved to be the most effective. Liu et al.12 conducted a comprehensive investigation focused on the rapid determination of COD in aquaculture water. A total of 135 absorbance spectra were collected from aquaculture water samples to serve as the basis for spectral analysis. To minimize the influence of absolute noise present in the raw spectral data, three preprocessing methods were applied: Savitzky–Golay (SG) smoothing, empirical mode decomposition (EMD), and wavelet transform (WT). Following preprocessing, latent variables (LVs) were extracted from the spectral data using PLS, which served to reduce the dimensionality and highlight relevant spectral features. Multiple modeling strategies were explored based on these LVs. PLS was first used to construct models utilizing the full spectral dataset. In parallel, ANN and LS-SVM models were developed using the extracted LVs. A comparative analysis of the modeling results revealed that both ANN and LS-SVM models exhibited superior predictive performance compared to the PLS models. Among all configurations, the LS-SVM model built using LVs derived from WT-preprocessed spectra achieved the most accurate results. Lepot et al.13 conducted a comprehensive comparative study to evaluate the performance of various modeling methods for estimating key water quality parameters. The primary objective was to determine the accuracy and robustness of different predictive approaches across a range of environmental scenarios. Four modeling techniques were explicitly assessed, including linear regression (LR), support vector machine (SVM), evolutionary algorithm (EVO), and PLS. These models were applied to diverse datasets obtained from different aquatic environments, including sewers, rivers, and wastewater treatment plants (WWTPs). The study also considered varying meteorological conditions, such as dry, wet, and all-weather situations, to enhance the generalizability of the results. The target water quality parameters included COD and others. The results indicated that PLS and SVM methods consistently provided the most accurate predictions, as reflected by their lower RMSE values. Li et al.14 proposed a practical and efficient method for COD detection based on UV-vis spectroscopy. The COD estimation model was globally calibrated using effluent samples collected from rural sewage treatment facilities. The performance of PLS, SVM, and ANN methods was compared to identify the most effective modeling technique. Among them, PLS achieved superior performance and was validated as the most suitable algorithm for global model construction. A wavelength selection strategy was implemented to reduce computational complexity and improve model simplicity. Instead of utilizing the full spectral range, the model employed absorbance values at specific wavelengths selected via interval partial least squares regression (iPLSR) and synergy interval partial least squares regression (siPLSR). The simplified model was based on three key wavelengths: 251 nm, 356 nm, and 363 nm. It demonstrated stable and reliable predictive capability. There has been some progress in COD detection by traditional methods. However, these methods often suffer from limitations, such as poor accuracy or the need for extensive preprocessing. Traditional statistical learning or machine learning models require more preprocessing of the spectra, which involves extracting COD-related features in advance. This step is crucial because the quality of feature extraction during spectral preprocessing has a significant impact on the model's accuracy. Without proper feature extraction, the model may struggle to make accurate predictions, thereby reducing its overall effectiveness.15
A general and efficient method is needed to automatically extract spectral features without manual intervention. The success of deep learning in image and language processing has encouraged researchers to investigate it in spectral feature extraction and modeling.16–18 Among deep learning models, convolutional neural networks (CNNs) are widely used for feature extraction. CNNs extract high-dimensional features through multi-level convolutional operations and reduce feature dimensions with a pooling layer. Compared to traditional prediction models, CNNs provide superior self-learning and adaptive capabilities. They can automatically extract features and handle nonlinear relationships more effectively.19 Due to their strong feature extraction and nonlinear mapping capabilities, CNNs can achieve high prediction accuracy even without spectral preprocessing. This advantage makes CNNs a promising alternative to traditional methods in COD detection.20 Jia et al.21 developed a COD prediction model based on CNNs and UV-vis spectroscopy. In this model, spectral data features were automatically extracted through the CNN framework, eliminating the need for complex preprocessing. Experimental results showed that the CNN model exhibited strong predictive ability, high accuracy, and excellent regression fitting. Compared to other models, the CNN-based approach achieved the smallest root mean square error of prediction (RMSEP) and mean absolute error (MAE). Additionally, it obtained the highest coefficient of determination (R2), indicating the best-fitting performance among all the evaluated models. These results highlight the effectiveness of CNNs in improving COD prediction accuracy. Xia et al.22 proposed a novel spectrometric quantification method based on a double-channel 1D CNN to quantify nitrate and COD concentrations in water combined with long UV-vis absorption spectra. To improve model robustness, a new dataset augmentation method was introduced, enhancing the model's ability to resist turbidity disturbances. The absorption spectra of nitrate and COD under different turbidity conditions were successfully simulated, allowing the model to adapt to varying water qualities. A comparison with the PLSR model demonstrated a significant improvement in regression accuracy. The CNN model increased nitrate solution accuracy from 56% to 93% and COD solution accuracy from 68% to 91%. These results highlight the CNN model's superior performance in nitrate and COD quantification compared to traditional spectroscopic modeling approaches. Ye et al.23 proposed a COD prediction model that combines UV-vis spectroscopy with CNNs. Unlike traditional COD prediction models, this approach utilizes the absorbance of all ultraviolet and visible wavelengths. It avoids information loss that occurs when only specific wavelengths are selected by considering the full spectrum. The model leverages CNN's strong feature extraction capability, reducing dependence on preprocessing methods. This enhances the utilization of spectral information, improving COD prediction accuracy. Experimental results showed that the CNN-based model achieved better fitting performance and higher accuracy compared to traditional COD prediction models. It outperformed methods such as principal component analysis (PCA), PLSR, and BP-ANN, demonstrating its effectiveness for COD detection. Compared to traditional methods, CNN-based approaches have greatly improved spectral feature extraction and COD modeling. These models can automatically learn complex relationships from UV-vis spectra, reducing the need for extensive preprocessing. They also enhance the accuracy and robustness of COD prediction. However, despite these advancements, challenges remain. There is still significant room for improvement in further enhancing the accuracy of COD detection. Future research should focus on optimizing CNN architectures and improving automatic feature extraction capability to achieve more accurate COD predictions.
This paper focuses on enhancing the accuracy of COD detection in water by UV-vis spectroscopy. Traditional methods for COD detection have several limitations, including complexity, slow analysis times, and the need for reagents. These challenges hinder real-time monitoring and the accuracy of results. To address these issues, the paper draws inspiration from the success of two-dimensional convolutional neural networks in image processing. It proposes a novel approach based on a one-dimensional multi-scale feature fusion convolutional neural network (1D-MSFF-CNN) for UV-vis spectral modeling tasks. Spectral features at various scales are extracted by the model, which employs three parallel sub-convolutional neural networks with different convolution kernel sizes. A multi-scale feature fusion algorithm is proposed to provide a more comprehensive and accurate representation of the UV-vis spectrum. Experimental results demonstrate that the proposed method effectively predicts COD with high accuracy, surpassing the performance of traditional and deep learning methods. The comparison with other COD prediction techniques shows a smaller prediction error, indicating the superior performance of the proposed method. It offers a more effective solution for improving the accuracy of COD detection based on UV-vis spectroscopy, paving the way for more reliable water quality monitoring.
![]() | ||
Fig. 2 COD standard value collection equipment. (a) DRB200 digester device; (b) DR3900 visible spectrophotometer. |
![]() | ||
Fig. 3 One-dimensional convolutional neural network COD prediction model based on multi-scale feature fusion. |
The 1D-MSFF-CNN consists of three parallel sub 1D-CNN, each made up of convolutional and pooling layers. One of the convolutional and pooling layers is named the conv-pooling layer. The three sub networks employ different convolution kernel sizes (1, 3, and 5) to capture spectral features at different scales. Each sub 1D-CNN is structured with three one-dimensional conv-pooling layers, with 32, 64, and 128 units in each layer, respectively. Features are extracted by multiplying the input with a filter, and the operation only moves in one direction along the spectral vector. The rectified linear unit (ReLU) activation function is used in each convolutional layer due to its simplicity and efficiency in computation. A max pooling layer follows each convolutional layer to extract features, reduce the number of parameters, and improve model training efficiency. The pooling operation focuses on retaining the most “important” local features, ensuring more accurate feature extraction. After the max pooling step, a multi-scale feature fusion layer combines the features extracted from the three sub 1D-CNN at different scales by element-wise addition. The outputs from the three sub conv-pooling layers are then merged into a single layer with the same number of channels. A batch normalization (BN) layer is added after the feature fusion to normalize the data, helping to solve issues like gradient vanishing and improving training speed. This batch normalization also regularizes the data, enhancing both the training efficiency and overall model performance. The entire multi-scale feature fusion process is shown in Fig. 4.
The feature fusion layer calculation process is divided into two steps. These steps are crucial for effectively combining the features extracted from three sub networks. The first step involves combining the features extracted from the three sub 1D-CNN at different scales by element-wise addition. The second step is to add a BN layer after the feature fusion to normalize the data. The equations for these calculations are provided in eqn (1) and (2).
![]() | (1) |
![]() | (2) |
After the feature fusion layer, a fully connected layer (flatten) is added to convert the output into a single vector. This step helps to simplify the output and prepares it for further processing. Two additional fully connected layers, with 128 and 32 units, are then introduced to map the learned feature distribution to the label space. These layers enable the network to capture more complex relationships within the data. At the end, a fully connected output layer (Dense 1) is added to provide the final COD prediction results. The network extracts spectral features at different scales, performs feature fusion, and predicts the COD concentration through the fully connected layers. In comparison to traditional CNNs, the multi-scale feature fusion CNN is more effective in obtaining valuable spectral information and providing a more comprehensive description of sample features. The detailed parameters of the proposed 1D-MSFF-CNN architecture are provided in Table 1.
Layer | Input shape | Output shape | Kernel number | Kernel size | Padding | Stride | Activation |
---|---|---|---|---|---|---|---|
Convolution 0_1 | (1,2048,1) | (1,2048,32) | 32 | 1 × 1 | 0 | 1 | ReLU |
Convolution 1_1 | (1,2048,1) | (1,2048,32) | 32 | 1 × 3 | 1 | 1 | ReLU |
Convolution 2_1 | (1,2048,1) | (1,1024,32) | 32 | 1 × 5 | 2 | 1 | ReLU |
Max pooling 0_1 | (1,2048,32) | (1,1024,32) | None | 1 × 2 | None | 2 | None |
Max pooling 1_1 | (1,2048,32) | (1,1024,32) | None | 1 × 2 | None | 2 | None |
Max pooling 2_1 | (1,2048,32) | (1,1024,32) | None | 1 × 2 | None | 2 | None |
Fusion | (1,1024,32) | (1,1024,32) | None | None | None | None | None |
Convolution 0_2 | (1,1024,32) | (1,1024,64) | 64 | 1 × 1 | 0 | 1 | ReLU |
Convolution 1_2 | (1,1024,32) | (1,1024,64) | 64 | 1 × 3 | 1 | 1 | ReLU |
Convolution 2_2 | (1,1024,32) | (1,1024,64) | 64 | 1 × 5 | 2 | 1 | ReLU |
Max pooling 0_2 | (1,1024,64) | (1,512,64) | None | 1 × 2 | None | 2 | None |
Max pooling 1_2 | (1,1024,64) | (1,512,64) | None | 1 × 2 | None | 2 | None |
Max pooling 2_2 | (1,1024,64) | (1,512,64) | None | 1 × 2 | None | 2 | None |
Fusion | (1,512,64) | (1,512,64) | None | None | None | None | None |
Convolution 0_3 | (1,512,64) | (1,512,128) | 128 | 1 × 1 | 0 | 1 | ReLU |
Convolution 1_3 | (1,512,64) | (1,512,128) | 128 | 1 × 3 | 1 | 1 | ReLU |
Convolution 2_3 | (1,512,64) | (1,512,128) | 128 | 1 × 5 | 2 | 1 | ReLU |
Max pooling 0_3 | (1,512,128) | (1,256,128) | None | 1 × 2 | None | 2 | None |
Max pooling 1_3 | (1,512,128) | (1,256,128) | None | 1 × 2 | None | 2 | None |
Max pooling 2_3 | (1,512,128) | (1,256,128) | None | 1 × 2 | None | 2 | None |
Fusion | (1,256,128) | (1,256,128) | None | None | None | None | None |
Flatten | (1,256,128) | (1,256*128) | None | None | None | None | None |
FC | (1,256*128) | (1,128) | None | None | None | None | ReLU |
FC | (1,128) | (1,32) | None | None | None | None | ReLU |
FC (output) | (1,32) | (1,1) | None | None | None | None | None |
![]() | (3) |
Step 1: the UV-vis spectroscopy data for the water samples are obtained to perform the COD prediction. The data is collected by the spectroscopy acquisition system, as shown in Fig. 1.
Step 2: the samples are randomly divided into two sets: a training set and a testing set. The training set is used as input during the model training stage, allowing the model to learn mapping relationships within the data. The testing set, on the other hand, is reserved for the testing stage of the model. It is used to evaluate the performance of the trained model on unseen data.
Step 3: the 1D-MSFF-CNN model is designed for COD detection. The hyperparameters and weights of the model are initialized to set up the training process. The training set is then input into the model, allowing it to learn from the data. During the training process, forward propagation is applied to calculate the error between the model's predicted results and the standard values.
Step 4: the model is regularly checked for convergence to ensure it meets a certain criterion. If the model satisfies the convergence criterion, it proceeds to step 5. However, if the model does not meet the criterion, it requires further optimization. In this case, the weights are adjusted layer by layer through backpropagation.
Step 5: the model's performance is evaluated to determine whether it meets the criteria for accurate COD prediction. If the model satisfies the performance requirements, the testing set is input into the trained model, and the final prediction results are generated. However, if the model does not meet the performance criteria, it proceeds to step 3 for further adjustments. In this case, the hyperparameters are re-designed to improve the model's performance.
![]() | (4) |
![]() | (5) |
![]() | (6) |
![]() | ||
Fig. 6 UV-vis spectra of the water samples. (a) UV-vis spectra of training set; (b) UV-vis spectra of testing set. |
![]() | ||
Fig. 7 Changes of loss value and R2 during the training process of 1D-MSFF-CNN model. (a) changes of loss; (b) changes of R2. |
Method | Calibration set | Prediction set | ||
---|---|---|---|---|
R2 | RMSEC | R2 | RMSEP | |
1D-MSFF-CNN | 0.9705 | 5.1219 | 0.9693 | 5.2250 |
To further quantify the prediction performance of the model, a comparison was made between the predicted COD values and the standard COD values. The comparison curve presents the relationship between the COD prediction values from the 1D-MSFF-CNN model and the standard values in the testing set, as shown in Fig. 8. The higher the accuracy of the model, the closer the predicted values are to the standard values, and the closer the scatter points are to or on the blue straight line, indicating good consistency. The scattering of points near the blue line also suggests that the model has strong robustness and adaptability, providing accurate COD predictions. Notably, the error does not increase with higher COD concentrations, indicating that the error distribution remains uniform. The model achieves high accuracy within the COD concentration range of 20 to 120 mg L−1, ensuring reliable performance for lake water. These results demonstrate that the method effectively extracts UV-vis spectroscopy features, leading to accurate and consistent COD detection.
Method | Calibration set | Prediction set | ||
---|---|---|---|---|
R2 | RMSEC | R2 | RMSEP | |
PLSR | 0.9096 | 8.976 | 0.8941 | 9.7167 |
SVM | 0.9179 | 8.5531 | 0.9032 | 9.2869 |
ANN | 0.9471 | 6.8629 | 0.9436 | 7.0854 |
1D-CNN21 | 0.9577 | 6.1351 | 0.9532 | 6.4564 |
1D-CNN22 | 0.9683 | 5.3100 | 0.9642 | 5.6462 |
1D-CNN23 | 0.9594 | 6.0127 | 0.9565 | 6.2246 |
1D-MSFF-CNN | 0.9705 | 5.1219 | 0.9693 | 5.2250 |
![]() | ||
Fig. 9 Comparison of the proposed method with other methods. (a) R2; (b) RMSE. Here, Jia 2020 represents 1D-CNN,21 Xia 2023 represents 1D-CNN,22 Ye 2022 represents 1D-CNN.23 |
The comparison presented in Table 3 and Fig. 9 comprehensively evaluates the performance of traditional methods, deep learning methods, and the proposed method for predicting COD based on our spectral data. This comparative analysis reveals significant performance differences among these approaches. Among traditional methods, the ANN achieves the best results. It achieves R2 values of 0.9471 for the calibration set and 0.9436 for the prediction set. The corresponding RMSEC and RMSEP values are 6.8629 and 7.0854, respectively. Although ANN outperforms other traditional methods, it still lacks the capacity to fully capture the nonlinear and complex relationship between spectral features and COD concentrations. PLSR and SVM models perform even less effectively. Both exhibit higher RMSEC and RMSEP values, indicating reduced predictive accuracy and limited modeling capability. In contrast, deep learning methods show overall improvements in fitting performance. The 1D-CNN, as reported in previous studies (ref. 22), emerges as the strongest among the three deep learning methods. It achieves R2 values of 0.9683 and 0.9642 for the calibration set and prediction set, along with RMSEC and RMSEP values of 5.3100 and 5.6462, respectively. However, the remaining two deep learning models under evaluation fail to match the performance of the 1D-CNN (ref. 22). These two models demonstrate a weaker capacity to model the nonlinear spectral–COD relationship, reflecting inefficiencies in feature extraction and prediction accuracy. The proposed method clearly surpasses all the traditional and deep learning methods. It achieves the highest R2 values, reaching 0.9705 for the calibration set and 0.9693 for the prediction set. Furthermore, it obtains the lowest RMSEC and RMSEP values of 5.1219 and 5.2250, respectively. These results indicate its superior capability in accurately modeling the nonlinear relationship between spectral data and COD. The method's excellent fit and low prediction error reflect its enhanced ability to extract and utilize spectral features. Overall, the proposed method delivers highly reliable and precise COD predictions, outperforming all other evaluated methods and providing a promising solution for spectral-based water quality assessment.
Further comparisons were made between the proposed method and the three traditional methods and deep learning methods, as shown in Fig. 8 and 10. A scatter plot was applied to visualize the predicted COD values against the standard values from the testing set. The closer the prediction points are to the blue line in the plot, the higher the prediction accuracy. The accuracy of the models was evaluated by analyzing the distance between the scatter points and the blue line. Two red lines were added as reference lines in the scatter plots. These red lines maintained the same position and width across all subplots. The distance of the points from the red lines helped assess the accuracy of the models. The points in Fig. 10(a)–(c) are clearly farther from the blue line compared to those in Fig. 10(d)–(f) and 8. More points in Fig. 10(a)–(c) exceeded the red line area or were at the boundary, indicating relatively low prediction accuracy for PLSR, SVM, and ANN. In contrast, Fig. 10(d)–(f) show that no points exceeded the red line area, only one point of each subplot at the boundary, indicating that the prediction accuracy of the three deep learning methods is better. Finally, all points in Fig. 8 are within the red line area, and there are no points at the boundary, indicating that the proposed model has the best prediction accuracy. Overall, the proposed 1D-MSFF-CNN method showed the best COD prediction accuracy and stability compared to other methods.
![]() | ||
Fig. 10 Comparison curve between the prediction and standard COD values of 1D-MSFF-CNN and other methods. (a) PLSR; (b) SVM; (c) ANN; (d) 1D-CNN;21 (e) 1D-CNN;22 (f) 1D-CNN.23 |
This journal is © The Royal Society of Chemistry 2025 |