100 beginner machine learning projects with runnable Python code, tests and honest case studies. By Networkers Home, Bangalore.
This small teaching project demonstrates a simple pipeline for classifying short audio clips into coarse “genre-like” categories using purely synthetic audio. The aim is to teach feature extraction from raw audio (spectral summaries), how to avoid leakages by splitting data by artist/recording source, and how to evaluate a baseline classifier on held-out artists. The code extracts compact spectral features from generated waveforms and fits a RandomForestClassifier as a baseline.
The dataset is synthetic and constructed in code: short waveform clips are generated from mixtures of sinusoids plus noise. To simulate recording provenance and avoid artist-level leakage, each clip is assigned an “artist” id and each artist is assigned a single genre label. This is intentionally simplified and is not a substitute for real music recordings; it is used for teaching the pipeline and evaluation considerations.
Run the module; it exposes a run(seed: int = 42) -> dict function. When executed as a script it prints JSON with the returned metrics. Example: python project.py
Tests are provided with pytest. They verify the expected output keys, metric ranges, a conservative performance floor on the held-out macro F1, and determinism for a fixed seed. Run: pytest -q
Measured by running python project.py (seed 42) on 2026-10-23; the tests in test_project.py assert the floor.
| Metric | Value |
|---|---|
| macro_f1 | 0.7688 |
| accuracy | 0.7708 |
| n_train | 144 |
| n_test | 48 |
| model | RandomForestClassifier |
This project uses synthetic audio and simple spectral summaries. Distinguishing these synthetic mixtures is not equivalent to recognising real musical genre, artist identity or production conditions. Real audio contains complex timbral, rhythmic and production variations, and licensed datasets are needed for realistic evaluation. The pipeline nevertheless teaches important steps: feature extraction, artist-level split, baseline modelling and deterministic testing.
Possible next steps include using a small licensed music dataset with artist metadata, adding mel-frequency cepstral features (MFCCs) computed with a dedicated audio library, experimenting with data augmentation and calibration of class imbalance, and inspecting model errors on clips with mixed-genre content or high noise.
Full case study, build steps and evaluation checks: Music genre classifier on networkershome.com
Built by Networkers Home · Learn the skills in the AI Engineer Course · Part of 100 AI projects with code