Skip to content

laiagomezmessia/lab-web-scraping-single-page

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Song Recommender


Table of Contents

  1. Project Overview
  2. Prerequisites
  3. Setup
  4. Functionality
  5. Note
  6. Contributors

Project Overview

This Python project utilizes the Spotify API and machine learning techniques to recommend songs based on user input. The recommendation system incorporates both a list of top songs and a clustering model to provide diverse and personalized suggestions.

Prerequisites

Ensure you have the following libraries installed:

pip install pandas regex spotipy scikit-learn

Setup

  1. Clone the repository:
git clone https://github.com/laiagomezmessia/lab-web-scraping-single-page.git
  1. Create a Spotify Developer account and obtain your client ID and client secret.

  2. Create a file named secrets.txt in the project root:

clientid: YOUR_CLIENT_ID
clientsecret: YOUR_CLIENT_SECRET
  1. Ensure you have the following CSV files in the project directory: top_songs.csv: List of top songs. playlist_cluster_df.csv: Playlist with relevant features.

  2. Run the recommend_song function in SongRecommender.ipynb:

python song_recommender.py

Enter a song and its artist when prompted to receive a song recommendation.

Functionality

The recommend_song function performs the following steps:

  1. Checks if the user-inputted song is in the top songs list. If yes, it recommends a random song from the remaining top songs.

  2. If the user-inputted song is not in the top songs list, it connects to the Spotify API, searches for the song, and retrieves its audio features.

  3. Uses a pre-trained KMeans clustering model to predict the cluster of the input song.

  4. Recommends a random song from the same cluster in the playlist DataFrame.

  5. Introduces a nap to avoid hitting rate limits when interacting with the Spotify API.

Note

  • The clustering model and scaler are loaded using pickle from files named kmeans.pkl and X_prep.pkl. Ensure these files are present in the project directory.

  • The script can be further extended to include additional features or improve the recommendation algorithm.

Feel free to explore, modify, and enhance the project according to your preferences!

Contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 100.0%