Data preprocessing and model training

Sparks's inbuilt function to train a model takes an RDD of 'implicit preferences' given by users to some products, in the form of (userID (Int), productID (Int), preference (Double)) pairs. Here 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.00m 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.00m. Of the preprocessed data, approx. 66% (4,492,408) listens have been used as training data, 17% (1,123,985) listens have been used as validation data and 17% (1,123,596) listens have been used as test data. After preprocessing, training phase starts. 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 choosen to generate recommendations. The model will be referred to as "best model".

Best model parameters are as follows:

Bestmodel ID Best model training time(min) Best model rank Best model lmbda Best model iteration Best model alpha Best model RMSE Best model RMSE computation time(min)
listenbrainz-recommendation-model-54992920-1c6c-4b92-a511-8878ea43c244 0.44 20 0.1 10 3.0 13.11 0.20

Total time lapsed in data preprocessing and model training: 0.09h

Best Model saved in 0.03m

All the models trained in 0.08h

The following table gives information about all the models trained

model ID model training time(min) rank lmbda iterations alpha RMSE RMSE computation time(min)
listenbrainz-recommendation-model-17d709da-a552-458e-bd48-7a082bcac346 0.16 2 0.1 10 3.0 13.13 0.20
listenbrainz-recommendation-model-440e6b9b-f3ce-4b38-b77e-1cdbe2608394 0.16 2 10.0 10 3.0 13.14 0.19
listenbrainz-recommendation-model-a4ecc2e3-d908-44af-888b-f7aab0e28019 0.19 5 0.1 10 3.0 13.12 0.20
listenbrainz-recommendation-model-ae7c8666-9b13-441f-b86e-b4998b58df21 0.19 5 10.0 10 3.0 13.14 0.21
listenbrainz-recommendation-model-e62a648e-8c90-4a98-bb60-a84921819c08 0.25 10 0.1 10 3.0 13.12 0.20
listenbrainz-recommendation-model-f649715a-b6bc-4ae9-a0e5-e5913a5eacd8 0.27 10 10.0 10 3.0 13.14 0.20
listenbrainz-recommendation-model-3902ede8-778c-4dfb-a6ac-55aaa3a39eeb 0.35 15 0.1 10 3.0 13.12 0.20
listenbrainz-recommendation-model-ecfc72d5-5588-4ea8-aee1-1409dda70578 0.33 15 10.0 10 3.0 13.14 0.21
listenbrainz-recommendation-model-54992920-1c6c-4b92-a511-8878ea43c244 0.44 20 0.1 10 3.0 13.11 0.20
listenbrainz-recommendation-model-91c2a3fc-da50-45ad-b787-c17766a42179 0.44 20 10.0 10 3.0 13.14 0.21

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 an RDD (count information) is not included because it leades to unnecessary computation time.