# Advanced Analysis of Electoretinograms Based on Wavelet Scalogram Processing
## 3 Materials and Methods
### Machine Learning Pipeline  
The generalized pipeline of data processing is presented at Figure 4. A machine learning approach was used to predict the diagnosis of the subjects (healthy person or a person with pathology), using the features of the biomedical signals. It was relevant for us to identify the usefulness of the new wavelet scalogram features. Different groups of signals were considered separately due to it:  
* Classical features (amplitudes \(a\) and \(b\), and the latencies \(l_{a}\) and \(l_{b}\) of the \(a\)- and \(b\)-waves) (CF);
* Wavelet analysis features for the 1 and 2 segments (WA1-2);
* Wavelet analysis features for the 1, 2, 3, and 4 segments (WA1-4);
* Joined list of current features and wavelet analysis features for the 1-4 segments (CF+WA1-4).  
The decision trees (DTs) were selected as a machine learning method to solve the classification task--predicting the target values (diagnosis) using the different features. The main reason for choosing DTs is their ability to select the most significant features for the task. In this paper, for the implementation of the decision trees, the training and validation of the respective functions of the scikit-learn library were used [24].  
As DT tends to easily overfit the data, it is important to carefully tune the hyperparameters. In this research, the tuning of the following hyperparameters was considered, with max_depth (in the range of \(1,2,\ldots,14,15\)) and min_samples_split (in the range of \(3,6,\ldots,12,15\)).  
For each of four different groups of signals, the most optimal hyperparameters were found with the grid search (GridSearch) using a 5-fold stratified K-fold cross-validation  
Figure 3: Parameters extracted from the wavelet scalogram of electroretinogram signal: (**a**) maximum brightness of the wavelet scalogram segment; (**b**) frequency and time of the maximum region of the wavelet scalogram segment; (**c**) median and mean brightness values of wavelet scalogram segment; (**d**) frequency and time extremes of the wavelet scalogram segment.  
(StratifiedKFold). After the optimal hyperparameters were found, training and evaluating of the model were conducted as follows. First, we fit DT with the whole data. Then, we selected significant features using the feature_importances attribute, and only features with non-zero values of feature_importances were selected for subsequent analysis. Here, we considered feature_importances based on the reduction in Gini impurity. Afterwards, we performed cross-validation of the DT model using only the important features. The cross-validation was performed using StratifiedKFold implementation to ensure that each fold preserves the percentage of samples for each class. The number of splits was set to 5. The standard classification metrics were used--Accuracy, Precision, Recall, and F1-score. To obtain the final evaluation of the DT model, we averaged the metrics over all five validation folds. The standard deviation of the metrics over five validation folds was also considered. It is worth pointing out that the analyzed task does not assume a high computation efficiency rather than the accuracy of the final classification that was the aim of our research.