Code Monkey home page Code Monkey logo

recommender-system's Introduction

Recommender System(Music)

In this project, we recommend the top 100 popular songs to each user. We implement popularity baseline model, alternating least square model, and an extension LightFM to recommend songs for each user accross music listening platforms. Then we use meanAP at 100 items to evaluate the performance.

Dataset

This project uses the dataset ListenBrainz dataset, which consists of implicit feedback from music listening behavior, spanning several thousand users and tens of millions of songs.

Code

  • partition.py: this uses PySpark and SQL to preprocess dataset. We calculate the number of times (frequency) of listening the song per person as the popularity of the song per person. Then we partition the data into 20% validation set and 80% training set across users (user_id).
  • baseline.py: we use baseline popularity model. The popularity per each recording ($P[i]$) will be calculated by the sum of interactions for all users in the 𝑖th recording divided by the total number of plays for $i$ th recording plus the damping factor $\beta$. The popularity for each recording ($i$) is the formula below: $$P[i] \rightarrow \dfrac{\sum_u R[u, i]}{|R[:, i]| + \beta}$$ To tune the hyperparameter $\beta$, we select a range of damping factors, $0, 10, 20, 30, 40, 50, 60, 70, 80, 90$. Then we sort the recordings based on popularity values calculated above, and choose the top $100$ most popular recordings as the prediction.
  • convert_string.py: to prepare for alternating least square model, this converts the song id with from the string format to int format by using window in pyspark.
  • als.py: this is the als model construction. We import ALS model from pyspark.ml.recommendation library. To tune the hyperparameters in the als model, we used grid search to find the best rank, regularization term and $\alpha$.
  • lightfm_ext.py: This is an extension model, lightFM, in our project. We implement lightFM known for its flexibility and ability to handle sparse data. It uses matrix factorization to make recommendations on the top 100 songs. First we use Dataset.fit and Dataset.build_interactions to transform the dataframe of numeric user ID, numeric recording ID to interaction matrix. Then we train and test the LightFM model on the matrix.
  • test.py: this calculates test accuracy using meanAP at 100 with the input of saved model from als.py and lightfm_ext.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.