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 String
DEFAULT_SEPARATOR
protected List<DataSetEntry>
ratings
Raw stored ratingsprotected List<DataSetEntry>
testRatings
Raw 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 int
getNumberOfRatings()
This method indicates the number of (training) ratings.int
getNumberOfTestRatings()
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:DataSet
This method generates an iterator to navigate through the raw ratings stored in DataSetEntries.- Specified by:
getRatingsIterator
in interfaceDataSet
- 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 interfaceDataSet
- 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 interfaceDataSet
- 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 interfaceDataSet
- Returns:
- Number of test ratings
-
-