Converting the dataset into LibFM format

The FM-based model that we are going to reuse can consume the training data only in LibFM format, which is more or less the same as LibSVM. Therefore, first, we must format the MovieLens 1M dataset sp that the training dataset contains both users, movies, and existing rating information.

The LibFM format is similar to the LibSVM format but has some basic differences. For more information, interested readers can take a look at http://www.libfm.org/libfm-1.42.manual.pdf.

At the same time, new features will be generated by the user information and movie information. First, we will define the input (this will be updated according to users, movies, and ratings) and output file path as follows:

//MovieLensFormaterWithMetaData.java ...

Get Java Deep Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.