# A One-Class-Based Supervision System to Detect Unexpected Events in Wastewater Treatment Plants
## 2 Materials and Methods
### Unexpected Events Description  
The present document deals with the detection of unexpected events in WWTPs that may represent a potential risk for final water quality. This offers help in managing undesired working situations, contributing to enhancement of optimum decision-making. However, given the unfeasibility of registering datasets in that kind of situation, a synthetic dataset is required to emulate anomalies. Different experts in the field of chemistry and water treatment were consulted to determine which variables are especially significant in detecting dangerous situations in a WWTP. Following these criteria, the output variables of Chemical Oxygen Demand (COD), Ammonia (NH3), and Total Kjeldahl Nitrogen (NTK) were identified as the most critical due to their relevance in assessing water quality and environmental impact. Specific reasons why these variables are essential in environmental and water treatment studies are described below. * Chemical Oxygen Demand:
* Organic Pollution Indicator: COD measures the amount of oxygen needed to oxidize organic matter in a water sample. It is a direct indicator of the amount of organic contaminants present [28]. * Environmental Impact: High levels of COD in water bodies can result in decreased dissolved oxygen, affecting aquatic life and ecosystems [29]. * Process Control: In wastewater treatment plants, COD is essential to monitor and control the efficiency of treatment processes [30]. * Direct Toxicity: Ammonia is toxic to many aquatic species. Elevated levels can cause adverse effects in fish and other aquatic organisms [31]. * Eutrophication: Ammonia is a nutrient that, in excess, can contribute to the eutrophication of water bodies, promoting extensive growth of algae and aquatic plants, which can lead to water quality degradation and the death of aquatic fauna by anoxia [32]. * Pollution Indicator: The presence of ammonia can indicate recent contamination by agricultural, industrial, or domestic waste [33]. * Total Kjeldahl Nitrogen:
* Total Nutrient Component: TKN measures the total amount of nitrogen in the form of ammonia and organic matter, providing a more complete view of the nitrogen load in water [34]. * Eutrophication and Water Quality: Like ammonia, TKN is related to eutrophication. Excess nitrogen can promote the growth of oxygen-consuming organisms, degrading water quality and negatively affecting aquatic ecosystems [35]. \begin{table}
\begin{tabular}{c c} \hline \hline
**Description of the Measured Variable** & **Variable Name** \\ \hline Ammonia at the Entrance & NH3\_E \\ \hline Total Kjeldahl Nitrogen at the Entrance & NTK\_E \\ \hline Nitrate at the Entrance & NO3\_E \\ \hline Nitrogen dioxide at the Entrance & N02\_E \\ \hline
**Ammonia on Exit** & **NH3\_S** \\ \hline
**Total Kjeldahl Nitrogen on Exit** & **NTK\_S** \\ \hline Nitrate on Exit & NO3\_S \\ \hline Nitrogen dioxide on Exit & N02\_S \\ \hline Thickener input & INPUT\_ESP \\ \hline Total Nitrogen on Exit & NITROGEN\_T\_S \\ \hline \hline \end{tabular}
\end{table} 
Table 1: _Cont._Evaluation of Sources of Pollution: TKN helps to identify and quantify the sources of nitrogen pollution, whether agricultural, industrial, or urban [36]. In summary, these parameters are critical because they provide a comprehensive view of the pollutant load, potential toxicity, and environmental impact of water bodies. Their monitoring and control are essential for sustainable water resource management and protecting aquatic ecosystems. Hence, the generation of unexpected events followed the next steps:  
1. From the initial 237 samples, 16% were randomly selected to be converted to anomalies. 2. For each instance selected, one of the three variables (COD_S, NH3_S, and NTK_S) was randomly selected. 3. Once the variable to be modified was selected, its value was deviated by a given percentage. Figure 2 represents the process of selecting random instances for anomaly generation.