# Data-Based Modelling of Chemical Oxygen Demand for Industrial Wastewater Treatment
## 3 Results and Discussion
Since the minimum delay for the model is 10, this would indicate that effluent COD can be predicted 20 h in advance (one data point corresponds to two hours of data), assuming that there are no significant process changes. As discussed in Section 2.4, different moving median values were experimented with, and the 2 h period provided the best results from both the data analysis and modelling perspective. For the training data, the performance metrics show a correlation coefficient of 0.74. Similarly to the influent model, the identified model was tested on independent validation data. The results are presented in Figure 6b. One explanation for why the correlation is much higher in the validation data when compared to the training data in the case of the effluent model is the number of data points. The training data contained approximately 4000 data points, whereas the validation dataset utilised was only 600 data points long, for the reasons discussed in Section 2.5. The COD measurement does not work as intended between data points 440 and 520 on the test data (Figure 6b), as the measurement output is constant for a long period of time. During this time, the model outputs significantly lower values and provides a much better estimate of the COD than a measurement device that is not working. Such malfunctions occur at constant intervals due to sensor fouling. Zoomed in perspective is presented in Figure 7.  
Figure 5: Measured influent COD (black) and soft sensor estimates (blue) as a function of time (1 data point = 2 h), (**a**) training data (correlation 0.82, MAPE 9.4%). (**b**) Model testing on independent test data (correlation 0.89, MAPE 8.1%). Grey area is the estimated 95% prediction interval. \begin{table}
\begin{tabular}{c c c c c c c c c c c c c c c c} \hline \hline  & & & \multicolumn{3}{c}{**Inputs**} & \multicolumn{3}{c}{**Model**} & **Nonlinear** & **Training** & **Training Data** & **Training Data** & **Test** & **Test Data** & **Test Data** \\
**X\({}^{1}\)** & **X\({}^{2}\)** & **X\({}^{3}\)** & **X\({}^{4}\)** & **X\({}^{5}\)** & **X\({}^{6}\)** & **X\({}^{7}\)** & **X\({}^{8}\)** & **Structure** & **Scaling** & **Data r** & **MAPE [\%]** & **RMSE [mg/L]** & **Data r** & **Test** & **MAPE [\%]** & **RMSE [mg/L]** \\ \hline x & x & x & & & & & & & & & & & & & & \\ x & x & & x & & & & & & & & & & & & & \\ x & x & & & & & & & & & & & & & & & \\ x & x & & & & & & & & & & & & & & & \\ x & & & & & & & & & & & & & & & & \\ x & & & & & & & & & & & & & & & & \\ x & & & & & & & & & & & & & & & & \\ x & & & & & & & & & & & & & & & & \\ x & & & & & & & & & & & & & & & & \\ x & & & & & & & & & & & & & & & & \\ x & & & & & & & & & &Further model validation was performed by analysing the residuals of the created models. Histograms and normal probability plots were drawn for the training and test sets to evaluate model performance visually. A normal probability plot compares the residual to what would be expected if the data followed a normal distribution. The data are plotted in a way that should result in a straight line. If not, it suggests that the data do not conform to a normal distribution [27]. For the model to be considered good, the model residual should be close to normally distributed. The residuals for the influent COD soft sensor are plotted in Figure 8.  
The histogram and the normal probability plot for the soft sensor training data residual in Figure 8a,b suggest that the residual appears to be normally distributed. Minor deviations can be observed at the tails of the distribution. The soft sensor test data residual in Figure 8c,d, on the other hand, shows more deviations at the tails yet shows a relatively straight line in the middle portion of the data. For the effluent COD predictive model, the training data in Figure 9a,b shows significant deviation for residual values that differ from the predicted values by one standard deviation (approx. 10% of values). A similar phenomenon could be observed in the effluent COD test data in Figure 9d, albeit to a lesser degree.