# Machine Learning Ship Classifiers for Signals from Passive Sonars
## 2 Preprocessing Chain for SoNaR Signals
### Database Balancing and Partitioning  
The Brazilian Navy provided a database for acoustic signals through the CASOP Military Organization. Hydrophones were installed on the sea floor to record the acoustic signatures of ships traveling along the Arraial do Cabo lane. The sound records are stored and cataloged in a database. The dataset contains static recordings, with the stalled ship's equipment operational under normal conditions, and dynamic recordings, i.e., with ships actively moving within the acoustic lane. The data records contain static instances of docked ships with equipment turned on and systems online, such as auxiliary combustion engines and water chiller units. The boat moved to the sea, and its acoustic signature was recorded in this dynamic situation with the equipment online. A ship sometimes used two main combustion engines, whereas the ship used just one engine in others. A distinct acoustic signature was obtained for each configuration. The original database comprises measurements for 12 ships of different types, with different durations and numbers of races per ship. Some recordings from the dynamic phase are longer than forty-five minutes, while others from the static phase are shorter than forty seconds. Figure 3: Window generated by the TPSW algorithm. The greatest number of dynamic races per ship is five, and some ships present only one dynamic race, but a greater number of static races. To counteract the varying numbers of runs and the different run durations, the database was balanced. From the previous description of acquired data, one readily sees that the database should be balanced. The database was balanced so that \(M\) distinct signatures from each ship were available while prioritizing the diversity of ship signals. Seven banks or subsets of segmented race blocks were created and merged from the original dataset of races to create a dataset that contained 40 signals for each vessel, or 480 signals, if decimation was not used. This bank prioritized different ship runs and parts of the same run, where each of them lasted four seconds, as depicted in Table 1. \begin{table}
\begin{tabular}{c c} \hline \hline
**Bank 1** & **Data** \\ \hline A1 & 0–40 s \\ A2 & 0–40 s \\ A3 & 0–40 s \\ A4 & 0–40 s \\ B1 & 0–40 s \\ C1 & 0–40 s \\ C2 & 0–40 s \\ \hline
**Bank 2** & **Data** \\ \hline A1 & 40–80 s \\ A2 & 40–80 s \\ A3 & 40–80 s \\ A4 & 40–80 s \\ B1 & 40–80 s \\ C1 & 40–80 s \\ C2 & 40–80 s \\ \hline
**Bank 3** & **Data** \\ \hline A1 & 80–120 s \\ A2 & 80–120 s \\ A3 & - \\ A4 & 80–120 s \\ B1 & 80–120 s \\ C1 & 80–120 s \\ C2 & 80–120 s \\ \hline
**Bank 4** & **Data** \\ \hline A1 & - \\ A2 & 120–160 s \\ A3 & - \\ A4 & - \\ B1 & 120–160 s \\ C1 & - \\ C2 & 120–160 s \\ \hline
**Bank 5** & **Data** \\ \hline A1 & - \\ A2 & 160–200 s \\ A3 & - \\ A4 & - \\ B1 & 160–200 s \\ C1 & 160–200 s \\ C2 & - \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Segmented databases. In Bank 1, as depicted in Table 1, our aim was to identify four distinct signatures for each ship. For the A signal, all four signatures were located in Bank 1. The process began by reading and registering A1, followed by incrementing the line counter. Subsequently, A2 was processed, and this continued until A4 was registered. At this point, the signal counter reached its maximum value or overflowed. Upon overflowing, the system proceeded to search for the next signal. Moving to the B signal, as the line counter incremented, a comparison revealed a different signal C1. Consequently, the database counter was incremented and moved to Bank 2. The process repeated for B1\({}^{\prime}\) to B1\({}^{\prime\prime}\), where it spanned Banks 2 to 4. Upon reading the fourth signal, the signal counter overflowed, which prompted the search for the next signal to commence in the first bank. Proceeding to the C signal in Bank 1, only two signatures were present. After registering C1 and incrementing the line counter, C2 was processed.