Create your own Spotify recommendation algorithm. All you need is Python 3, Jupyter Notebook, and a Spotify account.
- Clone/download the repository.
- Ensure that you have Python 3 and Jupyter Notebook installed.
- Navigate to
/spotify-music-discovery
and runpip install -r requirements.txt
. - Create the file
spotify-music-discovery/pkg/config.py
as below, using your Spotify client information.
CLIENT_ID = 'your Spotify client id here'
CLIENT_SECRET = 'your Spotify client secret here'
CLIENT_USERNAME = 'your Spotify username here'
- To help avoid any OAuth errors that might occur, open your Spotify application here, and set up your Redirect URIs as follows:
Edit Settings
- Add
http://localhost:8888/callback/
under "Redirect URIs"
- Add
- When prompted in
get_spotify_data
, copy and paste the link you are redirected to in the input box that should pop up after running the first cell (even if the link throws a "localhost redirected you too many times" error).
- Start Jupyter Notebook in the
/spotify-music-discovery
directory. - Run through the notebooks in sequence, following the instructions in each:
get_spotify_data
- Downloads and parses song data from the training playlists you specify.
train
- Trains classifiers using the training data and saves the best one.
- Specifically, it pickles the classifier object and writes it to the
./classifiers
directory.
- Specifically, it pickles the classifier object and writes it to the
- Trains classifiers using the training data and saves the best one.
predict
- Predicts which songs you like from a playlist you specify.
To download playlists, you will have to specify their Spotify URIs. You can get Spotify URIs from the Spotify app, as follows:
- Right-click on a playlist
Share
Copy Spotify URI
This repo was originally created for a final project in an applied machine learning course at the University of Pennsylvania. For more detail, including the algorithms used, see the project report.