# A Novel Tool for Biodiversity Studies: Earthworm Classification via NGS and Neural Networks
## 2 Materials and Methods
### Earthworm Classification  
The earthworms belonging to _Eisenia fetida, Dendrobaena_ ssp., and _Lumbricus terrestris_ were classified using machine learning models based on selected image texture parameters. The image texture selection was performed using the Best First and Correlation-based Feature Selection subset evaluator. The texture features with the highest discriminative power were: RS5 SZ3 InvDfMom, RS5 SV5 Contrast, RATeta4, LS5 SZ3 InvDfMom, aHperc01, aHperc10, aHperc99, aHDomn01, aHMaxm10, aGsonZeros, aSSSV1 SumEntrp, aSSSZ1 InvDfMom, bSSSZ3 SumOfSqs, YATeta2, UHSKewness, UHPerc01, VSGSKewness, VS4 RHRLNonUni, SHperc90, SHperc99, SS5 SZ1 InvDfMom, X54 RZImgREmph, ZHMean.  
The models were built using WEKA 3.9 machine learning software (Machine Learning Group, University of Waikato, Hamilton, New Zealand) [44; 45; 46] and MATLAB R2024a (Math Works, Inc., Natick, MA, USA).  
In the case of the classification performed using WEKA, machine learning algorithms from the groups of Bayes, Functions, Lazy, and Trees were used. The Naive Bayes, Logistic, Simple Logistic, KStar, and Random Forest algorithms were the most successful. The following parameters were used to build the models:  
- Naive Bayes--debug: False; batchSize: 100; doNotCheckCapabilities: False; useKernelEstimator: False; useSupervisedDiscretization: False;
- Logistic--debug: False; batchSize: 100; doNotCheckCapabilities: False; maxIts: \(-1\); ridge: 1.0 \(\times\) 10\({}^{-8}\); useConjugateGradientDescent: False.
- Simple Logistic--debug: False; batchSize: 100; doNotCheckCapabilities: False; heuristicStop: 50; maxBoostingIterations: 500; useCrossValidation: True;
- KStar--debug: False; batchSize: 100; doNotCheckCapabilities: False; entropicAutoBlend: False; globalBlend: 20; missingMode: Average column entropy curves;
- Random Forest--bagSizePercent: 100; batchSize: 100; debug: False; doNotCheckCapabilities: False; calcOutOfBag: False; breakTiesRandomly: False; numExecutionSlots: 1; numIterations: 100; seeds: 1; storeOutOfBagPredictions: False.  
A test mode of 10-fold cross-validation was applied. In this case of this mode, the dataset was randomly divided into ten parts, including nine training sets and one test set. Each part in turn was treated as the test set. The procedure was carried out ten times on different training sets. The final result was considered the average result of ten estimates. The confusion matrices and average accuracies were determined. Additionally, other classification performance metrics, such as Kappa statistic, TP Rate (True Positive Rate), FP Rate (False Positive Rate), Precision, F-Measure, MCC (Matthews Correlation Coefficient), ROC Area (Receiver Operating Characteristic Area), and PRC Area (Precision-Recall Area) were computed [47; 48].  
For the classification of earthworms using MATLAB, the SVM, KNN, Ensemble, and Narrow Neural Network algorithms were selected as providing the highest accuracies:- SVM--preset: linear SVM; box constraint level: 1; kernel scale: automatic; kernel function: linear; standardize data: yes; multiclass method: one-vs-one;
- KNN--preset: fine; distance metric: Euclidean; number of neighbors: 1; standardize data: yes; distance weight: equal;
- Ensemble--preset: Subspace Discriminant; Ensemble method: subspace; learner type: discriminant;
- Neural Network--preset: Narrow Neural Network; number of fully connected layers: 1; first layer size: 10; iteration limit: 1000; activation: ReLU; standardize data: yes; regularization strength (Lambda): 0.  
The models were developed using a test mode of 10-fold cross-validation. Building a single model took from a few to several dozen seconds. For the models, confusion matrices and overall accuracies were determined.