# An Unsupervised Anomaly Detection Based on Self-Organizing Map for the Oil and Gas Sector
## 4 Results and Discussions
### Output Map  
After an initial analysis of the U-Matrix, it is possible to analyse the matrix of occurrences of BMU responses (Figure 9b) through a colour map. In this case, dark-coloured boxes indicate those nodes that are recalled the most during the training phase and vice versa for the light-coloured boxes. The most responsive nodes have coordinates [5; 10] and [6; 10]. As shown in Figure 10, all readings of the system's steady state are placed in these two locations. Unlike all other samples in the anomaly tests, the system's steady-state samples always present the same trend and do not vary its state. Therefore, all steady-state readings are projected at those two nodes.  
The nodes that make up the output grid accommodate only one class type, but sometimes this does not happen. Therefore, an analysis of cluster purity (Equation (21)) is conducted to uniquely assign a single class to each cell in the map. First, the purity value is calculated for each cell. Then, the overall purity value considers all cell purities. The overall value is 0.90, which means that statistically, the algorithm assigns each cell only one class 90% of the time. In conclusion, each node in the output map is assigned a class based on the purity of the clusters and the values provided by the U-Matrix. Figure 11 represents the final output map, where each cell has been filled with the colour of the specific category, as shown in Table 4.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**System State** & **Type of Anomaly** & **Tag** & **Colour** \\ \hline Transient of steady state & / & Hex & Fuchsia \\ Steady state & / & Asterisk & Orange \\ Anomaly 3 L3 & Water & Dot & Green \\ Anomaly 5 L3 & Air-water & Dot & Red \\ Anomaly 6 L3 & Water & Dot & Purple \\ Anomaly 7 L3 & Air & Dot & Brown \\ Anomaly 8 L3 & Air & Cross & Pink \\ Anomaly 9 L3 & Air & Line & Gray \\ Anomaly 10 L3 & Tank & Rhombus & Yellow \\ \hline \hline \end{tabular}
\end{table}
Table 4: Legend of SOM output map.  
Figure 9: SOM Colour map: (**a**) U-Matrix Colour Map; (**b**) activation response map.  
Figure 11: All classes predicted by the SOM algorithm. The color legend can be consulted in Table 4.  
Figure 10: The output map of input data. The figure legend can be consulted in Table 4.  
The first readings of almost all anomaly tests are clustered near the regime area. Then, the shut-off valves are closed manually, and the system goes from a steady state to a new operating point. Indeed, the database provided to the network also contains the readings that characterize the transient of each abnormal test. The shut-off valves VM3 and VM6 impede the passage of water into the system and out of the tank. The SOM can recognize a water anomaly in the system in both cases and projects the readings in the left part of the map. The VM7 valve prevents air inflow, VM9 prevents air outflow, and VM8 simulates an air leak inside the tank. The algorithm recognizes that all three anomalies involve air and arranges the readings in the right part of the map. The red area shown in Figure 12 collects all the readings recorded on the system when the VM5 valve impedes the passage of the two-phase air-water fluid into the tank. The algorithm arranges these anomalous readings under the area marking the water anomaly and the air anomaly area. Finally, the yellow area (Figure 12) in the lower right collects the readings recorded on the system when a water leakage from the tank through the VM10 valve is simulated. The diversity of this anomaly from the others described above prompts the SOM to arrange the readings in a new area set in the lower right corner.  
From the study conducted on the output map, the algorithm arranges the input data into six macro areas (Figure 12): (i) steady-state area (orange), (ii) water anomaly macro-area (green), (iii) air-water anomaly area (red), (iv) tank anomaly area(yellow), (v) air anomaly macro-area (blue sky), and (vi) steady-state transition area (fuchsia).