Package es.upm.etsisi.cf4j.data
Class TrainTestFilesDataSet
- java.lang.Object
-
- es.upm.etsisi.cf4j.data.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).
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDEFAULT_SEPARATORprotected List<DataSetEntry>ratingsRaw stored ratingsprotected List<DataSetEntry>testRatingsRaw stored test ratings
-
Constructor Summary
Constructors Constructor Description TrainTestFilesDataSet(String trainingFileName, String testFileName)Generates a DataSet form training and test ratings files.TrainTestFilesDataSet(String trainingFileName, String testFileName, String separator)Generates a DataSet form training and test ratings files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetNumberOfRatings()This method indicates the number of (training) ratings.intgetNumberOfTestRatings()This method indicates the number of test ratings.Iterator<DataSetEntry>getRatingsIterator()This method generates an iterator to navigate through the raw ratings stored in DataSetEntries.Iterator<DataSetEntry>getTestRatingsIterator()This method generates an iterator to navigate through the raw test ratings stored in DataSetEntries.
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
protected static final String DEFAULT_SEPARATOR
- See Also:
- Constant Field Values
-
ratings
protected List<DataSetEntry> ratings
Raw stored ratings
-
testRatings
protected List<DataSetEntry> testRatings
Raw stored test ratings
-
-
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:DataSetThis method generates an iterator to navigate through the raw ratings stored in DataSetEntries.- Specified by:
getRatingsIteratorin interfaceDataSet- Returns:
- Iterator of ratings
-
getTestRatingsIterator
public Iterator<DataSetEntry> getTestRatingsIterator()
Description copied from interface:DataSetThis method generates an iterator to navigate through the raw test ratings stored in DataSetEntries.- Specified by:
getTestRatingsIteratorin interfaceDataSet- Returns:
- Iterator of test ratings
-
getNumberOfRatings
public int getNumberOfRatings()
Description copied from interface:DataSetThis method indicates the number of (training) ratings.- Specified by:
getNumberOfRatingsin interfaceDataSet- Returns:
- Number of (training) ratings
-
getNumberOfTestRatings
public int getNumberOfTestRatings()
Description copied from interface:DataSetThis method indicates the number of test ratings.- Specified by:
getNumberOfTestRatingsin interfaceDataSet- Returns:
- Number of test ratings
-
-