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,448,071) listens have been used as training data, 17% (1,112,873) listens have been used as validation data and 17% (1,112,561) 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-30619812-9d36-42b3-a805-e9bcb37e22f0 0.25 10 0.1 10 10.03 0.20

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

Best Model saved in 0.03m

All the models trained in 0.05h

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-7eceb132-8cfb-4aaf-adde-24baae9a395c 0.13 5 0.1 5 10.04 0.19
listenbrainz-recommendation-model-0548e81e-3303-441a-b1a4-3a9944cd8150 0.19 5 0.1 10 10.04 0.19
listenbrainz-recommendation-model-76f58044-6d83-4fc6-82c9-20d541f3c6b1 0.13 5 10.0 5 10.07 0.19
listenbrainz-recommendation-model-0aa2a578-8c49-4cb5-a0f4-765870599779 0.19 5 10.0 10 10.07 0.20
listenbrainz-recommendation-model-bef088e8-236e-43f2-9f8f-1eb0021f6a21 0.16 10 0.1 5 10.04 0.19
listenbrainz-recommendation-model-30619812-9d36-42b3-a805-e9bcb37e22f0 0.25 10 0.1 10 10.03 0.20
listenbrainz-recommendation-model-4607c86e-ca05-454c-9302-292296d97795 0.17 10 10.0 5 10.07 0.20
listenbrainz-recommendation-model-f67066ce-5753-41c9-8f3a-fc8d53ad034f 0.25 10 10.0 10 10.07 0.20

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.