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.

Playcount Transformed Listencount
0 0
1 20
2 <= x <= 20 x + 20
> 20 50

Preprocessing of playcounts dataframe takes 0.00m. Of the preprocessed data, approx. 66% (4,492,464) listens have been used as training data, 17% (1,123,976) listens have been used as validation data and 17% (1,123,549) 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-d5e19e00-8b5f-4032-a827-5fa6fc361ff7 0.51 25 0.1 10 3.0 22.77 0.22

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

Best Model saved in 0.03m

All the models trained in 0.65h

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-a2523e78-fdfd-4d53-9c52-650a6d6b9035 0.19 5 0.1 10 3.0 22.82 0.20
listenbrainz-recommendation-model-191418d5-0769-4d48-849f-1907118032b9 0.19 5 10.0 10 3.0 22.89 0.20
listenbrainz-recommendation-model-0dcc7b05-4098-4727-90f8-39c18c93479c 0.16 2 0.1 10 3.0 22.88 0.19
listenbrainz-recommendation-model-d85747e8-a03e-4538-92cc-c187ec43a254 0.16 2 10.0 10 3.0 22.93 0.20
listenbrainz-recommendation-model-a12d91fd-08c7-4870-833c-bf2e74eaee45 0.26 10 0.1 10 3.0 22.79 0.19
listenbrainz-recommendation-model-b99bff31-96b1-4cae-b401-98238ee480b9 0.26 10 10.0 10 3.0 22.87 0.20
listenbrainz-recommendation-model-8be60a90-5836-440f-9b7c-a747f43c30e8 0.33 15 0.1 10 3.0 22.78 0.20
listenbrainz-recommendation-model-7ad8f403-2ace-455d-9c50-8a83662e107a 0.32 15 10.0 10 3.0 22.86 0.20
listenbrainz-recommendation-model-6ac5933e-236d-4852-85af-9666a897d7e9 0.39 20 0.1 10 3.0 22.78 0.19
listenbrainz-recommendation-model-88915124-827e-4b02-9ffb-42d02127e2f1 0.40 20 10.0 10 3.0 22.85 0.21
listenbrainz-recommendation-model-aad6fb9f-a1a3-4c11-8625-f6c936d63a3a 0.27 11 0.1 10 3.0 22.79 0.19
listenbrainz-recommendation-model-a4db33ad-0345-43fd-a3b6-9327ba42409c 0.26 11 10.0 10 3.0 22.87 0.19
listenbrainz-recommendation-model-66da8f95-b40e-4302-9294-60003478bd43 0.28 12 0.1 10 3.0 22.79 0.19
listenbrainz-recommendation-model-1baf7263-3c8f-4001-b275-95064cc065a7 0.28 12 10.0 10 3.0 22.87 0.19
listenbrainz-recommendation-model-a97c8c82-c2be-467b-99b3-4e7ae75f708f 0.28 13 0.1 10 3.0 22.79 0.19
listenbrainz-recommendation-model-56d41215-dddc-46ba-9648-52a481ac2acf 0.29 13 10.0 10 3.0 22.87 0.19
listenbrainz-recommendation-model-145a064c-fdc2-4d86-b9f9-f54b7e577a12 0.31 14 0.1 10 3.0 22.78 0.19
listenbrainz-recommendation-model-a067ff38-e59d-4eaa-aa4d-899bbc056115 0.31 14 10.0 10 3.0 22.86 0.20
listenbrainz-recommendation-model-6893bca2-4af5-4971-8a7d-47e8725e2e7f 0.34 16 0.1 10 3.0 22.78 0.22
listenbrainz-recommendation-model-6ee22e99-8d8b-432f-809c-95bfc6c38e9f 0.33 16 10.0 10 3.0 22.86 0.20
listenbrainz-recommendation-model-f0c8f63e-9168-47f7-afb0-1288f170d4e3 0.34 17 0.1 10 3.0 22.78 0.19
listenbrainz-recommendation-model-22664291-fd42-45d8-8185-acd352d10e34 0.35 17 10.0 10 3.0 22.86 0.20
listenbrainz-recommendation-model-c354820e-9cd0-4e06-b70b-92c1af6fabe1 0.37 18 0.1 10 3.0 22.78 0.20
listenbrainz-recommendation-model-4f4a7117-f2ff-4825-ade4-0dc017d4f819 0.38 18 10.0 10 3.0 22.86 0.19
listenbrainz-recommendation-model-a4bf605e-8ad4-478c-b802-ed4507375acb 0.38 19 0.1 10 3.0 22.78 0.19
listenbrainz-recommendation-model-a72dfa9e-3900-4767-b0ca-8ee3e481c084 0.40 19 10.0 10 3.0 22.86 0.19
listenbrainz-recommendation-model-9dd28456-a774-40b5-8c07-882c6f5ecc7f 0.42 21 0.1 10 3.0 22.78 0.19
listenbrainz-recommendation-model-2e9ecb7a-3278-4629-bc1a-1874abc9b694 0.42 21 10.0 10 3.0 22.85 0.19
listenbrainz-recommendation-model-d5e19e00-8b5f-4032-a827-5fa6fc361ff7 0.51 25 0.1 10 3.0 22.77 0.22
listenbrainz-recommendation-model-5031a387-87f2-48d4-9ed6-204461538a58 0.51 25 10.0 10 3.0 22.85 0.22
listenbrainz-recommendation-model-9b21d5f6-0edb-45d7-b0ed-222a54b1de48 1.41 50 0.1 10 3.0 22.78 0.24
listenbrainz-recommendation-model-d9c2ce4a-be74-4471-b301-b0b941d13ff6 1.38 50 10.0 10 3.0 22.85 0.20
listenbrainz-recommendation-model-9623ad01-558d-4fdd-9e69-3f71a26a0336 6.30 100 0.1 10 3.0 22.82 0.25
listenbrainz-recommendation-model-fa3fd07d-086c-4803-ba81-fa46582fb3a9 6.29 100 10.0 10 3.0 22.85 0.28
listenbrainz-recommendation-model-69b134f4-4690-4174-90ea-cfef648ab867 3.19 75 0.1 10 3.0 22.8 0.22
listenbrainz-recommendation-model-fe66c31a-1645-40d9-acda-6f201d33aab1 3.16 75 10.0 10 3.0 22.85 0.25

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.