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.00 mins and 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 mins. The preprocessed data divided the data into training and test data, in 5 : 1. The model was then trained on the training data using K-Folds Cross Validation with 5 folds. From the models trained, the one with least RMSE 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-aafd943e-47d6-4231-a0d8-bd620b714fb0 20 1.0 10 40.0 11.409

Test RMSE for the best model is 11.441

Total time lapsed in data preprocessing and model training: 0.90 hours

Best Model saved in 0.05 mins

All the models trained in 0.90 hours

The following table gives information about all the models trained

model id rank lmbda iterations alpha RMSE
listenbrainz-recommendation-model-47a301de-43a0-4313-b72a-dab1eb366e46 10 1.0 10 1.0 11.492
listenbrainz-recommendation-model-9c074ecf-bafa-478c-8d26-474929794c4f 10 1.0 10 3.0 11.471
listenbrainz-recommendation-model-503fc431-0d5d-4f2d-b11a-8f1c58975a37 10 1.0 10 40.0 11.412
listenbrainz-recommendation-model-f3778ae9-5238-4ba0-9074-dbfe0985da8d 10 10.0 10 1.0 11.507
listenbrainz-recommendation-model-427db741-049d-41c5-a6bd-58c1550b19a2 10 10.0 10 3.0 11.503
listenbrainz-recommendation-model-c9c7f4e5-277b-455b-b0c6-6468688bafd1 10 10.0 10 40.0 11.423
listenbrainz-recommendation-model-06e3422b-0356-4956-8dad-411d76ead2e1 10 100.0 10 1.0 11.507
listenbrainz-recommendation-model-6f4291b9-00c5-43a9-bf8d-57e1161ab3c1 10 100.0 10 3.0 11.507
listenbrainz-recommendation-model-e105dcd3-244f-40bc-b860-213586f7cb18 10 100.0 10 40.0 11.493
listenbrainz-recommendation-model-bd14a264-a03c-4b06-9116-9618a590d413 20 1.0 10 1.0 11.49
listenbrainz-recommendation-model-769efe69-a351-4e61-9805-4a8853048bcd 20 1.0 10 3.0 11.467
listenbrainz-recommendation-model-aafd943e-47d6-4231-a0d8-bd620b714fb0 20 1.0 10 40.0 11.409
listenbrainz-recommendation-model-4cc01d85-9fc2-4ffa-844c-0da3a68d4494 20 10.0 10 1.0 11.507
listenbrainz-recommendation-model-a859d37a-5aa0-4a00-9fcf-f092eb9b6341 20 10.0 10 3.0 11.503
listenbrainz-recommendation-model-e567ac48-1be3-42c5-a720-64fc86f86e9a 20 10.0 10 40.0 11.42
listenbrainz-recommendation-model-c3ecfe15-aeaa-4e9f-9db4-365936fe333d 20 100.0 10 1.0 11.507
listenbrainz-recommendation-model-741aa0f5-eb3f-4c69-a332-7a4a84a76eb5 20 100.0 10 3.0 11.507
listenbrainz-recommendation-model-635930ab-bbd7-48c5-8043-88c70458705d 20 100.0 10 40.0 11.493
listenbrainz-recommendation-model-31c77f00-a7c6-4784-8090-786ad336e54d 5 1.0 10 1.0 11.495
listenbrainz-recommendation-model-98d1c0d7-49fe-4c11-9735-26b14da3bb80 5 1.0 10 3.0 11.477
listenbrainz-recommendation-model-93c70e30-81df-4002-a503-955e2e7fcf2f 5 1.0 10 40.0 11.418
listenbrainz-recommendation-model-969006ed-b4a1-4e40-855e-11a4389c62e0 5 10.0 10 1.0 11.507
listenbrainz-recommendation-model-8f3c8d4e-ee45-466e-9d98-a6add7412467 5 10.0 10 3.0 11.504
listenbrainz-recommendation-model-a8acf857-661e-4e61-afd7-34edc47c0d57 5 10.0 10 40.0 11.428
listenbrainz-recommendation-model-0fba833a-18f9-4972-8837-5fe305bec19f 5 100.0 10 1.0 11.507
listenbrainz-recommendation-model-0b998f7e-68a8-4f43-ac69-ed6bc9714b44 5 100.0 10 3.0 11.507
listenbrainz-recommendation-model-d53f8518-b860-434a-a2f2-1b10d9cb9079 5 100.0 10 40.0 11.493
listenbrainz-recommendation-model-4f67e267-e748-4754-b560-6812a569bf2d 25 1.0 10 1.0 11.489
listenbrainz-recommendation-model-d9c3dd5f-f6f4-406b-8094-4f7a12d0b75f 25 1.0 10 3.0 11.466
listenbrainz-recommendation-model-37ad6d00-1abb-4dfd-873c-c1b2a72a089e 25 1.0 10 40.0 11.409
listenbrainz-recommendation-model-fe582e16-d050-4606-ab96-6a7d928c27ab 25 10.0 10 1.0 11.507
listenbrainz-recommendation-model-877dd556-23a7-43d6-8a3a-049c79c5b38f 25 10.0 10 3.0 11.503
listenbrainz-recommendation-model-b7ae9d08-6615-4605-8a5b-ad1a1fc02a2c 25 10.0 10 40.0 11.419
listenbrainz-recommendation-model-394ff142-f232-4583-8570-2edb9ac5309d 25 100.0 10 1.0 11.507
listenbrainz-recommendation-model-d7904ea5-5035-4ab8-8514-9cdbf5fa6fb1 25 100.0 10 3.0 11.507
listenbrainz-recommendation-model-b0f9e585-7b6f-4b03-9045-c6cbd901763d 25 100.0 10 40.0 11.493

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.