/music_recommender

Primary LanguageJupyter NotebookMIT LicenseMIT

Music Recommender System

Overview

This project is a music recommender system that suggests songs based on similarity measures. The system uses a precomputed similarity matrix to find songs that are similar to a given track. The dataset includes information about users, artists, tracks, and playlists.

Due to GitHub's file size limits, these files are not fully visible on the GitHub repository. You can download the complete files by cloning the repository and accessing them locally.

Features

  • Recommends songs based on a given track.
  • Uses a precomputed similarity matrix for fast recommendations.
  • Handles missing values in the dataset.

Setup

To set up the recommender system on your local machine, follow these steps:

  1. Clone the repository:

    git clone https://github.com/nikithamarythomas/music_recommender.git
    cd music_recommnder
  2. Install the required libraries:

    pip install -r requirements.txt
  3. Download the precomputed similarity matrix and data files:

    • similarity.pkl: The similarity matrix.
    • df.pkl: The dataset with user, artist, track, and playlist information.
  4. Load the data files in your script:

    import pickle
    
    with open('similarity.pkl', 'rb') as file:
        similarity = pickle.load(file)
    
    with open('df.pkl', 'rb') as file:
        df = pickle.load(file)

Usage

Here is an example of how to use the recommender system:

import pickle

# Load the similarity matrix and data frame
with open('similarity.pkl', 'rb') as file:
    similarity = pickle.load(file)

with open('df.pkl', 'rb') as file:
    df = pickle.load(file)

# Function to recommend songs based on a given song
def recommendation(song_name):
    idx = df[df['song'] == song_name].index[0]
    distances = sorted(list(enumerate(similarity[idx])), reverse=True, key=lambda x: x[1])
    recommended_songs = [df.iloc[i[0]]['song'] for i in distances[1:11]]
    return recommended_songs

# Example usage
print(recommendation('Glee'))

NOTE

Due to the file size limit on GitHub, the similarity.pkl is managed using Git Large File Storage (LFS). Make sure to install Git LFS and track the file with it. Here's how:

git lfs install
git lfs track "similarity.pkl"

License

This project is licensed under the MIT License - see the LICENSE file for details.