The Music Genre Recognition (MGR) project is a web application which predicts the genre for a song selected by the user. The application allows users to search for a song, and once a particular song is selected, user is presented with the true and predicted genres of the song.
Music artists and streaming services annotate the genre of the music manully. Most of the time, the artists decide the genre of the song which they had created. Through this project I've tried to explore that to what extent does the music itself decides the genre of a song.
User's search query is sent to the backend, which fetches top 50 search results from Spotify Search>Search for Item API and send it back to frontend. When user selects a particular song from the displayed results, song's trackID and artistID are sent to the backend. True genres are fetched from Spotify Artists>Get Artist API and predicted genres from the ML Model. Input for the ML Model is fetched from Spotify Tracks>Get Track's Audio Features API.
- Frontend: React
- Backend: Express
- Machine Learning: Flask
Spotify Dataset (derived from here) was used for model training. Original dataset contained 114 Genres and for the majority of these genres not enough data points were present. These 114 genres were mapped to 8 parent genres - namely "Electronic/Dance"; "Rock/Metal"; "Pop"; "Country/Folk"; "Classical/Orchestral"; "R&B/Soul"; "Blues/Jazz" and "Hip-Hop". You can refer the dataset for mapping structure.
In philosophy, Occam's razor is a problem-solving principle that suggests - "The Simplest explanation is usually the best one."
For classification, binary classifiers were trained for each of the genres (Only Electronic/Dance, Rock/Metal and Pop were finally considered due to data imbalance). Random Forest was giving the best predictions among the selected traditional ML algorithms.
For a given song, all three models will give their prediction of probability by which the song can belong to the respective genre. User is presented by the normalized probability ratio of individual positive probabilities given by all the models.
Below are the results showing the performance of the MGR algorithm on some of the well know songs.