# Advancing Taxonomy with Machine Learning: A Hybrid Ensemble for Species and Genus Classification
## 3 Materials and Methods
### Dataset with Simulated Undescribed Species
Conversely, it considers relationships between the sample embeddings of different classes. For this reason, the loss function is called Data-to-Data CE. This makes it so that by minimizing the loss, we make the sample embeddings more similar to the corresponding class proxies, but at the same time, we make the sample embeddings of images belonging to different classes different between each other. This idea is similar to the contrastive loss used in siamese networks. The intuition behind this loss is that we make the discriminator use visual features from the images to distinguish images of different classes instead of just making it only guess the class directly. If this intuition is correct, it would be useful for our purpose since our objective is not just to generate realistic images but to also obtain useful features that encode the class of the insect. Some sample obtained by ReACGAN are shown in Figure 4.

The last step to obtain the final version of D2 DCE (Equation (5)) is to consider the 3 hyperparameters: the margins \(m_{p}\) and \(m_{n}\) and the temperature \(\tau\). Since the model is too big for our dataset, we pre-trained it on a dataset of arbitrary animals taken from various internet datasets for 25 epochs. Then, we fine-tuned it on our dataset for 12 epochs. The dataset for the pre-training of the ReACGAN contains [38] and some other datasets from kaggle with pictures of insects and other animals. The whole pre-training dataset can be found at [39]. ### Discrete Wavelet Transform

In numerical analysis and functional analysis, a discrete wavelet transform (DWT) is a type of wavelet transform where the wavelets are discretely sampled. A significant advantage of DWT compared to Fourier transforms is its ability to provide temporal resolution, capturing both frequency and time location information [40]. Given a 1D discrete signal \(x[n]\), the DWT is calculated by passing the signal through two filters:

* A low-pass filter \(h[n]\) (scaling function);
* A high-pass filter \(g[n]\) (wavelet function). The outputs of these filters are downsampled by a factor of 2 to reduce the number of coefficients, effectively halving the time resolution. The signal decomposition can be expressed as follows:

\[cA[n] =\sum_{k}x[k]h[n-k]\] Figure 2:0

where \(cA[n]\) comprises the approximation coefficients (low-frequency components) and \(cD[n]\) comprises the detail coefficients (high-frequency components). The filtering and downsampling process is recursive. After each decomposition, the approximation coefficients are further decomposed into new approximation and detail coefficients at the next level. This decomposition process is visualized as a binary tree, see Figure 5, where each node represents a sub-space with distinct time-frequency localization. This structure is commonly referred to as a filter bank. The proposed approach utilizes the following mother wavelets:

* Haar;
* Daubechies;
* Symlets;

Figure 2:1 Images generated by the ReACGAN. Coiflets;
* Reverse Biorthogonal;
* Discrete Meyer;
* Fejer-Korovkin Orthogonal;
* Beylkin Orthogonal;
* Vaidyanathan Orthogonal. We did not perform a study to overfit which wavelets to use, instead using the ones available in MATLAB and using the default parameters; the same set is used for all the datasets, so we assume that there is no risk of overfitting. Below is the pseudocode for the described approach; see pseudocode Algorithm 2. This process is applied three times to create the 3 channels of the matrix used for feeding ResNet50. ```
Define vector the feature vector that describes a given pattern  Initialize a square matrix Mat of size \(\lceil\frac{\text{length}(vector)}{8}\rceil\) filled with zeros.