The Recommendation system can show similar songs to a song. It can also recommend songs acoording to user liked songs.
- Technologies Used
- Feature Engineering
- Similarity Calculation
- Installation
- Usage
- Screenshots for Reference
- Frontend: React.js (React.js)
- Backend: Django([Django]) and Django REST framework(DRF)
- Database: SQLite(sqlite)
- Contanerisation: Docker (Docker)
- Data Processing and ML: Pandas[Pandas(https://pandas.pydata.org/)], Numpy(Numpy), Scikit-learn(sklearn)
- Dataset: Kaggle (spotify-600k-tracks)
The idea is to represents songs into linear vectors according to there audio features such as danceability, energy, loudness, speechiness, acousticness etc. and other categorical features such as genres, release year, key (major note of track [0: C, 1: C#/Db, 2: D, …]), etc.
We use Word2Vec to create meaningful numerical representations (vectors) for genres. This helps us understand the relationships between different types of music.
We apply TF-IDF (Term Frequency-Inverse Document Frequency) to the genre vectors. This step makes rare and important genres more influential in our track representations.
By calculating a weighted average of genre vectors for each track (tf-idf is used as weights), we create a unique representation for every song based on its genres.
Era flags are created by dividing songs into decades (e.g., 40s, 50s) to capture historical trends and associations with different time periods.
We use one-hot encoding for categorical variables like "key," "time_signature," and "era_flags". This encoding transforms these categorical variables into binary vectors, with each category represented as a binary column.
For numerical variables such as artists' followers, track popularity, and artist popularity, we employ bucketing. This technique groups numerical values into ranges (0-5, 6-10) and converts them into categorical features. This helps manage dimensionality and making them suitable for categorical analysis.
Used to simplify numerical variables, making them easier to work with for cosine similarity calculations. This step helps improve the efficiency and scalability of the recommendation system.
Cosine similarity is a mathematical concept used in various fields, including natural language processing and recommendation systems, to determine the similarity between two vectors. In the context of song recommendation systems, cosine similarity can be a powerful approach.
-
Vector Representation: Each song is represented as a vector in a multi-dimensional space, with each dimension corresponding to a feature such as genre, tempo, mood, or instrument usage.
-
Cosine Calculation: When a user interacts with a song (e.g., listens to it, adds it to a playlist), their preferences are captured as a vector. To recommend similar songs, the cosine similarity between the user's vector and other song vectors is calculated.
-
Similarity Measurement: Cosine similarity measures the cosine of the angle between two vectors. A higher cosine value indicates a smaller angle and thus greater similarity between the songs.
Cosine similarity, with its simplicity and effectiveness, plays a vital role in enhancing user experience and engagement in music streaming platforms.
Prerequisites:
- Docker installed and Running: https://www.docker.com/products/docker-desktop/
Instructions:
-
Clone this repository:
git clone https://github.com/SumitRathor002/songsrecommendation.git
-
Navigate to the project directory:
cd songsrecommendation
-
Start the application:
docker-compose up
It takes around 600 seconds to populate database, please be patient
-
Access the application:
The application is likely accessible in your web browser at
http://localhost:<3000>
- The application presents you random songs on home page if you are guest user,
- It redirdects you to a signup page if you try to use features such History, Favourites, Like
- You can also here preview audio if its available
- If you are Logged In user
- Personalized Recommendation on Home feed
- you can Like/Unlike Songs
- you can see your Liked songs in /Favourites
- you can see your history in /History