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 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 count

Preprocessing of playcounts dataframe takes 0.00m. Of the preprocessed data, approx. 66% (4,314,145) listens have been used as training data, 17% (1,079,360) listens have been used as validation data and 17% (1,079,292) 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-786026a2-3be6-4643-b289-e5e019559672 6.40 100 0.1 10 6.42 0.20

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

Best Model saved in 0.11m

All the models trained in 1.78h

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-9725caee-0fcb-4e9c-813f-1a32f017217b 3.18 100 0.1 5 6.43 0.20
listenbrainz-recommendation-model-786026a2-3be6-4643-b289-e5e019559672 6.40 100 0.1 10 6.42 0.20
listenbrainz-recommendation-model-3b452622-8ab8-4fd2-adee-f7d65e757946 3.22 100 10.0 5 6.49 0.24
listenbrainz-recommendation-model-7406fdf9-6c08-44ca-bbe7-b8279edc5649 6.38 100 10.0 10 6.49 0.25
listenbrainz-recommendation-model-5af1e369-d43d-42d7-b0e8-ed620d077c14 5.06 120 0.1 5 6.43 0.26
listenbrainz-recommendation-model-892fd752-17b4-4d10-80a3-4b499ec59546 10.19 120 0.1 10 6.42 0.25
listenbrainz-recommendation-model-36a03716-0146-4130-a757-d173b5e453f3 5.07 120 10.0 5 6.49 0.26
listenbrainz-recommendation-model-6999cbfb-9aa1-48fa-b8de-1ff81e7170f2 10.13 120 10.0 10 6.49 0.26
listenbrainz-recommendation-model-bc2e96a7-5719-4ed3-a02d-3793007071aa 9.17 150 0.1 5 6.43 0.26
listenbrainz-recommendation-model-404eeb51-5b4e-441a-8b39-39560ef1cf65 18.12 150 0.1 10 6.42 0.25
listenbrainz-recommendation-model-c811c50c-2827-474a-9167-8fc39a90ae5a 9.07 150 10.0 5 6.49 0.25
listenbrainz-recommendation-model-4d998ca5-2d0c-4103-b128-339e92bdf312 18.05 150 10.0 10 6.49 0.24

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.

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.