Data preprocessing and model training

Sparks's inbuilt function to train a model takes a dataframe of 'implicit preferences' given by users to some products. userID ~ user_id, productID ~ recording_id and preference ~ transformed count as represented by rows in playcounts dataframe.

Playcounts dataframe is loaded from HDFS in 0.03 minsm and is converetd to an RDD and each row is mapped to object of Rating class using

Rating(user_id, recording_id, count)

Playcounts dataframe is of the form:

user_id recording_id playcount transformed_listencount

Here, playcount is the actual listen count whereas the transformed_listencount was calculated by applying the following function on playcounts.

No transformation applied to listen counts

Preprocessing of playcounts dataframe takes 0.00 minsm. The preprocessed data divided the data into training and test data, in 5 : 1. Further, 80.0 % of the training dataset was used for training the model. The remaining listens in the training dataset were used for validating phase of the model. From the models trained, the best one is selected to generate recommendations.

Of all the trained models, the model with the least RMSE value is chosen to generate recommendations. The model will be referred to as "best model".

Best model parameters are as follows:

Best model ID Best model rank Best model lmbda Best model iteration Best model alpha Best model RMSE
listenbrainz-recommendation-model-99525ca5-a73c-4647-bbce-d8beabaeb2fd 5 5.0 10 40.0 23.74487978787023

Total time lapsed in data preprocessing and model training: 0.01 hoursh

Best Model saved in 0.04 minsm

All the models trained in 0.01 hoursh

The following table gives information about all the models trained

model ID rank lmbda iterations alpha RMSE
ALSModel: uid=ALS_835aa65a7af9, rank=5 23.971132702095613 5 5.0 10 5.0 listenbrainz-recommendation-model-3dafa343-9aaf-45d6-a5a6-a7e5ddc0ce5a
ALSModel: uid=ALS_835aa65a7af9, rank=5 23.74487978787023 5 5.0 10 40.0 listenbrainz-recommendation-model-99525ca5-a73c-4647-bbce-d8beabaeb2fd
ALSModel: uid=ALS_835aa65a7af9, rank=10 23.93690836447135 10 5.0 10 5.0 listenbrainz-recommendation-model-f27a6140-7482-4074-97a4-ed55a9e32fc1
ALSModel: uid=ALS_835aa65a7af9, rank=10 23.772636258629188 10 5.0 10 40.0 listenbrainz-recommendation-model-b11ab042-aeb8-4221-a4f0-e508210a7298

Following are the parameters required to train the model

The Mean Squared Error (MSE) is a direct measure of the reconstruction error of the user-item rating matrix. It is defined as the sum of the squared errors divided by the number of observations. The squared error, in turn, is the square of the difference between the predicted rating for a given user-item pair and the actual rating.

Ratings are predicted for all the (user_id, recording_id) pairs in validation data, the predicted ratings are then subtracted with actual ratings and RMSE is calculated.

Note: Number of rows in a dataframe or number of elements in a dataframe (count information) is not included because it leads to unnecessary computation time.