# Data Mining Techniques for Endometriosis Detection in a Data-Scarce Medical Dataset
## 2 Materials and Methods
### Machine Learning Models  
We conducted different experiments with machine learning algorithms using scikit-learn (version 1.3.0) [36], a free software library for Python, with the main support of the free software libraries numpy (version 1.24.3) and pandas (version 2.0.3). The experiments were run in a Conda environment (version 23.7.3) with Python (version 3.11.4). The experiments compared the viability of several classification techniques using real-world datasets. Cross-validation [37] is the standard technique to estimate the performance of machine learning models on unseen data. Data were divided into k groups or folds, and one fold was used as the test set and the rest as the training set. The choice of k affects the bias-variance trade-off of the model, where a smaller k leads to a higher bias but a lower variance, and a larger k leads to a lower bias but a higher variance. A single execution of k-fold cross-validation may result in noisy values, because the order of the data may affect the performance values, especially if the datasets are small or imbalanced [38]. However, if the computational cost is not a problem, repeated k-fold cross-validation, which repeats the process n times, each time using a different random seed to shuffle the data before splitting it into folds, can provide a more robust and less dependent estimate [39]. To achieve statistical stability, we used a group of 100 random state values for each test conducted in this study. Thus, we repeated the cross-validation process 100 times with different random seeds and averaged the results. Considering that the dataset consists of 21 observations, we set the number of splits in cross-validation to 7. Then, we had a large enough number of data points in the training set to be able to obtain an adequate classifier. Consequently, the number of training data points was 18, compared to 3 validation data points. If the dataset size was less than 21, the number of splits varied as indicated in Section 2.1. The general algorithm is described in Algorithm 1. The function performs the classification task using the given classifier and the repeated k-fold cross-validation method [40]. The function uses four inputs: the X matrix, the Y matrix, the number of folds for cross validation, and the specific classifier for the chosen method of classification. In this study, we used 100 repetitions for cross-validation. The function returns a dictionary with the tuples of the mean (\(\overline{X}\)), the standard deviation (\(\sigma\)), and the length of each cross-validation score of each metric. The function also handles cases where there is a zero-division error in calculating precision and recall by filtering out those scores. The standard deviation (\(\sigma\)) was used to monitor and prevent overfitting [41], which is a risk of having models with a large variance (\(\sigma^{2}\)). Overfitting considers the model's capture of noise or the specific features of the training set but does not generalize well to new or unseen data. The standard deviation measures how much the model's predictions deviate from the mean. We used the following four common metrics to evaluate the performance of machine learning models in classification tasks: _accuracy_ (see Equation (3)), _precision_ (see Equation (4)), _recall_ (see Equation (5)), and \(F1\) (see Equation (6)). Accuracy measures how often the model predicts the correct class. Precision measures how often the model's positive predictions are correct. Recall measures how often the model detects positive cases. The F1 score is the harmonic mean of precision and recall; it captures the trade-off between precision and recall, which was used to rank the performance of each algorithm due to the imbalance in the classes. Another interesting measure of fit for unbalanced data is the geometric mean [42]. However, during the experiment, we observed that there were many test sets with one class. In such cases, the result provided by this metric was 0, which invalidated this metric.