Machine learning-assisted vibrational detection and classification of drywood termite infestations
收藏资源简介:
Machine learning-assisted vibrational detection and classification of drywood termite infestations Dataset DOI: 10.5281/zenodo.21662348 By: Lírio Cosme Júnior, Raul Narciso C. Guedes, Leonardo M. Turchen Description of the data and file structure This repository contains the data, R scripts, and analysis workflow (i.e, ML_dataset.zip) used to develop and evaluate machine learning models for detecting and classifying drywood termite infestations from vibratory cues. The workflow uses vibratory features extracted from .wav recordings and includes: 1. Audio preprocessing and MFCC feature extraction. 2. Dataset preparation for binary and multiclass classification. 3. Linear discriminant analysis (LDA) for visualization of class separation. 4. Training of eight machine learning algorithms. 5. Repeated 5-fold cross-validation with 10 repeats. 6. Internal validation using a withheld 30% subset of the training data. 7. External testing using an independent dataset. 8. Evaluation using classification performance metrics and confusion matrices. Classification tasks Binary classification The models distinguish between: (i) Infested – wood containing termites. (ii) Uninfested – wood without termites. Multiclass classification The models distinguish among: (i) High – high termite infestation. (ii) Low – low termite infestation. (iii) Empty – no termite infestation. Infestation classes were assigned according to the experimental classification based on X-ray images. Files and variables Repository structure The analysis requires the following project structure: ML_dataset/ ├── Dataset1/ │ └── .wav │ ├── Dataset2/ │ └── .wav │ ├── calc_MFCC.R │ ├── Protocol.Rmd │ └── Output-ML/ ├── Figures/ └── Tables/ Input data `Dataset1/` – primary dataset used for model development and internal validation. `Dataset2/` – independent dataset used for external testing. Code/software Software requirements The analysis was conducted in R using the following packages: beepr caret caretEnsemble cvms DT gbm ggord ggplot2 ggplotify here kableExtra kernlab MASS patchwork plotly pROC randomForest RColorBrewer stringr tidyverse tuneR viridis warbleR Reproducibility workflow 1. Configure the project Set the base_dir variable to the location of the downloaded repository: base_dir <- normalizePath("~/Desktop/ML_dataset") The analysis automatically creates the following output directories: Output-ML/ ├── Figures/ └── Tables/ 2. Extract MFCC features All .wav files in Dataset1/ and Dataset2/ are processed using the calcMFCC() function. MFCC features are extracted using a sliding window and subsequently centered and scaled before machine learning analysis. The processed data are stored as: `train_raw_binary.csv` `train_raw_class.csv` `test_raw_binary.csv` `test_raw_class.csv` 3. Prepare classification datasets The processed MFCC data are organized into binary and multiclass datasets. The training data contain: 100 infested samples, classified as high or low infestation. 100 uninfested samples, classified as empty. The external test dataset contains: 100 infested samples, classified as high or low infestation. 50 uninfested samples, classified as empty. The exact class assignments are defined in the analysis script and should be retained when reproducing the workflow. 4. Visualize class separation Linear discriminant analysis (LDA) is performed using the MFCC features to visualize separation among the three infestation classes. The resulting figure is saved as:Output-ML/Figures/LDA_plot.pdf 5. Split the training data For both classification tasks, the primary dataset is divided into: 70% training data – used to fit the machine learning models. 30% internal validation data – withheld from model training and used to evaluate model performance. The resulting datasets are saved as: train_set_binary.csv valid_set_binary.csv train_set_class.csv valid_set_class.csv 6. Train machine learning models Eight machine learning algorithms are evaluated: 1. Random Forest (rf) 2. k-Nearest Neighbors (knn) 3. Neural Network (nnet) 4. Linear Support Vector Machine (svmLinear2) 5. LogitBoost (LogitBoost) 6. Multilayer Perceptron (mlp) 7. C5.0 Decision Tree (C5.0) 8. Gradient Boosting (gbm) Models are trained using: 5-fold cross-validation 10 repeated cross-validation runs Grid-based hyperparameter search Class probability estimation Saved resampling predictions 7. Compare model performance Cross-validation performance is summarized for both binary and multiclass classification. The workflow generates: Figures/ ├── Boxplot_binary.pdf └── Boxplot_class.pdf and Tables/ ├── Summary_binary_models.csv └── Summary_class_models.csv 8. Evaluate binary classification Binary classification models are evaluated using: Internal validation – the 30% validation subset. External testing – the independent Dataset2 samples. Performance is assessed using: Accuracy, Kappa, Precision, Recall, F1-score Results are saved as: Tables/Model_Summary_Results_Binary.csv Confusion matrices are generated separately for internal and external evaluation. 9. Evaluate multiclass classification Multiclass models are evaluated using the same two datasets: Internal validation dataset. Independent external test dataset. The following metrics are calculated: Accuracy, Kappa, Precision, Recall, F1-score The results are saved as: Tables/Model_Class_Metrics_Summary_AllModels.csv Confusion matrices are generated for each model and evaluation dataset. Output files Processed datasets: train_raw_binary.csv train_raw_class.csv test_raw_binary.csv test_raw_class.csv train_set_binary.csv valid_set_binary.csv train_set_class.csv valid_set_class.csv Model performance tables Summary_binary_models.csv Summary_class_models.csv Model_Summary_Results_Binary.csv Model_Summary_Results_Class.csv Figures The Figures/ directory contains: LDA ordination plot. Binary cross-validation performance plot. Multiclass cross-validation performance plot. Binary confusion matrices for internal validation. Binary confusion matrices for external testing. Multiclass confusion matrices for internal validation. Multiclass confusion matrices for external testing. How to reproduce the analysis 1. Download or clone the complete repository. 2. Install R and the required R packages. 3. Place the .wav files in Dataset1/ and Dataset2/. 4. Open the main R Markdown analysis file. 5. Update base_dir to the local project directory. 6. Run the analysis sequentially from beginning to end. 7. The processed datasets, tables, and figures will be generated automatically in Output-ML/. Data and code availability This repository is intended to provide the data and computational workflow required to reproduce the machine learning analyses described in the associated study. The analysis depends on the original .wav recordings and the R Markdown analysis workflow. All paths should be adapted to the local directory structure when reproducing the analysis. More information Leonardo M. Turchen (leonardo.turchen@ufv.br)



