Loading data from a file

Loading data from a file can be achieved with the FileDataModel class. We will be expecting a comma-delimited file, where each line contains a userID, an itemID, an optional preference value, and an optional timestamp, in the same order, as follows:

userID,itemID[,preference[,timestamp]] 

An optional preference accommodates applications with binary preference values, that is, the user either expresses a preference for an item or not, without a degree of preference; for example, with a like or dislike.

A line that begins with a hash (#) or an empty line will be ignored. It is also acceptable for the lines to contain additional fields, which will be ignored.

The DataModel class assumes the following types:

  • The userID ...

Get Machine Learning in Java - Second Edition 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.