Class TrainTestFilesDataSet

  • All Implemented Interfaces:
    DataSet

    public class TrainTestFilesDataSet
    extends Object
    implements DataSet
    This class implements the DataSet interface by loading training and test ratings from separated text files. Each line of the ratings files must have the following format:
    <userId><separator><itemId><separator><rating>

    Where <separator> is an special character that delimits ratings fields (semicolon by default).

    • Constructor Detail

      • TrainTestFilesDataSet

        public TrainTestFilesDataSet​(String trainingFileName,
                                     String testFileName)
                              throws IOException
        Generates a DataSet form training and test ratings files. Semicolon is used as separator.
        Parameters:
        trainingFileName - File with the (training) ratings.
        testFileName - File with the test ratings.
        Throws:
        IOException - When the file is not accessible by the system with read permissions.
      • TrainTestFilesDataSet

        public TrainTestFilesDataSet​(String trainingFileName,
                                     String testFileName,
                                     String separator)
                              throws IOException
        Generates a DataSet form training and test ratings files.
        Parameters:
        trainingFileName - File with the (training) ratings.
        testFileName - File with the test ratings.
        separator - Separator char between ratings fields.
        Throws:
        IOException - When the file is not accessible by the system with read permissions.
    • Method Detail

      • getRatingsIterator

        public Iterator<DataSetEntry> getRatingsIterator()
        Description copied from interface: DataSet
        This method generates an iterator to navigate through the raw ratings stored in DataSetEntries.
        Specified by:
        getRatingsIterator in interface DataSet
        Returns:
        Iterator of ratings
      • getTestRatingsIterator

        public Iterator<DataSetEntry> getTestRatingsIterator()
        Description copied from interface: DataSet
        This method generates an iterator to navigate through the raw test ratings stored in DataSetEntries.
        Specified by:
        getTestRatingsIterator in interface DataSet
        Returns:
        Iterator of test ratings
      • getNumberOfRatings

        public int getNumberOfRatings()
        Description copied from interface: DataSet
        This method indicates the number of (training) ratings.
        Specified by:
        getNumberOfRatings in interface DataSet
        Returns:
        Number of (training) ratings
      • getNumberOfTestRatings

        public int getNumberOfTestRatings()
        Description copied from interface: DataSet
        This method indicates the number of test ratings.
        Specified by:
        getNumberOfTestRatings in interface DataSet
        Returns:
        Number of test ratings