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 ~ count as represented by rows in playcounts dataframe.

Playcounts dataframe is converetd to an RDD and each row is mapped to object of Rating class using

Rating(user_id, recording_id, count)

Preprocessing of playcounts dataframe takes 6.17m. Of the preprocessed data, approx. 66% (37,336,521) listens have been used as training data, 17% (9,335,864) listens have been used as validation data and 17% (9,338,835) 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 RMSE Best model RMSE computation time(min)
listenbrainz-recommendation-model-a67d670d-844f-40f9-b994-d39ae84baca5 13.82 12 10.0 20 7.57 6.01

Best Model saved in 0.56m

All the models trained in 2.15h

The following table gives information about all the models trained

model ID model training time(min) rank lmbda iterations RMSE RMSE computation time(min)
listenbrainz-recommendation-model-fe72d44c-00d3-4c5e-b77f-09562875ede0 6.77 8 0.1 10 8.52 5.92
listenbrainz-recommendation-model-54e5831f-4587-4da5-863f-fe2f928a2bf3 10.59 8 0.1 20 8.58 6.04
listenbrainz-recommendation-model-f1c65750-687d-47dd-9558-656a1e4442f1 7.62 8 10.0 10 8.32 6.05
listenbrainz-recommendation-model-5892c3ae-3bba-4f5f-ba65-1a0bf19497ae 11.11 8 10.0 20 8.13 6.00
listenbrainz-recommendation-model-9e63d5e4-fe2c-4b68-bf67-98574ba1816a 8.45 12 0.1 10 8.49 6.00
listenbrainz-recommendation-model-4bafbaa0-3a34-4857-aabe-55452a54cbef 13.90 12 0.1 20 9.00 5.99
listenbrainz-recommendation-model-74318206-65b0-438d-9c94-c6b9b2149f98 8.31 12 10.0 10 8.35 6.14
listenbrainz-recommendation-model-a67d670d-844f-40f9-b994-d39ae84baca5 13.82 12 10.0 20 7.57 6.01

Following are the parameters required to train the model

Value of alpha used is 3.0

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.

Next

Prev