Using supervised machine learning to classify a song's genre as pop, hip-hop, or rock-n-roll based on properties returned from the Spotify API.
Currently a two step process: retrieving a random list of tracks from each genre, then retrieving properties for each track.
To retrieve a random list of tracks per genre that would be sufficiently large enough for training/testing the model, I used the following endpoint from the spotify API: Get Recommendations from Seed Genre.
I iteratively queried this endpoint and added track ids to a set in order to retrieve a large, random set of ids with no duplicates. The endpoint can only retrieve a maximum of 100 tracks at a time.
All of this work is done in the get_unique_tracks.py file under the dataset-creation folder.
Running this file will result in a saved pickle file (datasets/track_ids.pkl) that contains a pandas dataframe with two columns: track_id, genre.
I retrieved properties of each track by querying the following spotify API endpoints: Get a Track, Get Audio Features for a Track.
I added each property as a column in a pandas dataframe. All of this work is done in dataset-creation/get_track_info.py.
Running this file will result in a saved pickle file (datasets/predict_genre_dataset.pkl) that contains a dataframe where each row is a track, and each column is a property of that track.
This is done in predict_genre.py.
Current performance metrics per label can be found in the model-performance folder.