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-d08ec5d0-56e5-413c-a2eb-dc0587f33026 6.39 100 0.1 10 6.42 0.20

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

Best Model saved in 0.11m

All the models trained in 2.35h

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-d08ec5d0-56e5-413c-a2eb-dc0587f33026 6.39 100 0.1 10 6.42 0.20
listenbrainz-recommendation-model-b0bc8584-1415-407e-8046-bcc03617aaa4 9.40 100 0.1 15 6.42 0.20
listenbrainz-recommendation-model-83be6d1b-6b57-4f64-8e8d-ae9f55b5880c 13.15 100 0.1 25 6.42 0.24
listenbrainz-recommendation-model-7740c86f-ca05-4680-a1c5-4b9b8d82153b 5.35 100 10.0 10 6.49 0.24
listenbrainz-recommendation-model-b61da58e-1fb8-4b84-badc-70fbdd575e08 7.91 100 10.0 15 6.49 0.24
listenbrainz-recommendation-model-a7db32ef-4167-498e-a0fd-cf096bbae5da 13.13 100 10.0 25 6.49 0.24
listenbrainz-recommendation-model-8d22d76b-6cbf-4a18-a3d0-968f747c4554 8.33 120 0.1 10 6.42 0.26
listenbrainz-recommendation-model-3995a329-37e0-40ac-9dfd-cfdd3487ca18 12.37 120 0.1 15 6.42 0.26
listenbrainz-recommendation-model-993d2f10-672f-4ac8-9116-3d9795c243ef 20.53 120 0.1 25 6.42 0.27
listenbrainz-recommendation-model-09b7377b-187a-4e78-b067-95ea72624dce 8.32 120 10.0 10 6.49 0.21
listenbrainz-recommendation-model-8108eef6-1c70-4981-b118-6c07eec4ba56 12.42 120 10.0 15 6.49 0.25
listenbrainz-recommendation-model-489dbcbb-5e7d-4c7d-8515-eae600dadf77 20.62 120 10.0 25 6.49 0.28

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.