A classical machine learning pipeline for environmental sound classification, built on the ESC-50 dataset. The project covers manual feature extraction, feature analysis, model training, hyperparameter tuning, and evaluation using SVM and Random Forest classifiers.
Best model accuracy: 86% - surpassing human-level performance (~81%) on ESC-50
The ESC-50 dataset is an industry-standard benchmark for environmental sound classification. This project focuses on 10 selected classes of diverse sound categories, using manually extracted acoustic features to train and tune classical ML classifiers.
The supervised learning component was developed independently as part of the Applied Machine Learning course at Hanze University of Applied Sciences (2024–2025).
| Category | Classes |
|---|---|
| Animals | Chirping birds, Frog, Insects |
| Natural | Thunderstorm |
| Urban | Airplane, Car horn, Vacuum cleaner |
| Human | Breathing, Brushing teeth |
| Mechanical | Clock tick |
- Import required libraries and modules
- Read audio file metadata
- Select 10 classes (2 from each major ESC-50 category)
- Split data using predefined folds (to prevent data leakage)
- Visualize waveforms and spectrograms (1 instance per class)
- Extract features: MFCC, RMS, Zero Crossing Rate, Spectral Centroid, Spectral Roll-off, Spectral Contrast
- Aggregate features using mean and standard deviation
- Visualize features using pair plots
- Analyze correlation coefficients to ensure feature decorrelation
- Create feature subsets for comparative experiments
- Find initial hyperparameter ranges using GridSearchCV
- Fine-tune hyperparameters on selected ranges
- Select best model per feature set
- Evaluate using Confusion Matrix and ROC-AUC curves
- Train and compare Random Forest classifier
| Model | Feature Set | Test Accuracy |
|---|---|---|
| SVM (Linear, C=0.1) | All features | 86% |
| SVM | Feature Set 1 | ~65% |
| SVM | Feature Set 2 | ~74% |
| SVM | PCA-reduced | ~37% |
| Random Forest (1000 trees) | All features | Comparable to SVM |
ROC-AUC (best SVM): 0.97–0.98
Human-level performance on ESC-50 is reported at ~81%. The best model in this project surpasses that benchmark using only classical ML and manually extracted features.
- Feature extraction: MFCC, ZCR, RMS, Spectral Centroid, Roll-off, Contrast via Librosa
- Cross-validation: PredefinedSplit (respects ESC-50 fold structure to avoid data leakage)
- Hyperparameter tuning: Two-stage, GridSearchCV and manual (broad → narrow)
- Evaluation: Confusion matrix, per-class ROC-AUC, macro-average F1
audio-classification-esc50/
│
├── audio_classification_esc50.ipynb # Full pipeline notebook
├── requirements.txt # Dependencies
└── README.md
Note: The ESC-50 dataset is not included. Download it from the official repository.
- Clone the repository:
git clone https://github.com/MostafaJahanian/audio-classification-esc50.git
cd audio-classification-esc50- Install dependencies:
pip install -r requirements.txt-
Download the ESC-50 dataset and update the file paths in the notebook accordingly.
-
Run the notebook top to bottom.