public final class KDDCupDataModel extends Object implements DataModel
An DataModel
which reads into memory any of the KDD Cup's rating files; it is really
meant for use with training data in the files trainIdx{1,2}}.txt.
See http://kddcup.yahoo.com/.
Timestamps in the data set are relative to some unknown point in time, for anonymity. They are assumed to be relative to the epoch, time 0, or January 1 1970, for purposes here.
Constructor and Description |
---|
KDDCupDataModel(File dataFile) |
KDDCupDataModel(File dataFile,
boolean storeDates,
double samplingRate) |
public KDDCupDataModel(File dataFile) throws IOException
dataFile
- training rating fileIOException
public KDDCupDataModel(File dataFile, boolean storeDates, double samplingRate) throws IOException
dataFile
- training rating filestoreDates
- if true, dates are parsed and stored, otherwise notsamplingRate
- percentage of users to keep; can be used to reduce memory requirementsIOException
public File getDataFileDirectory()
public LongPrimitiveIterator getUserIDs() throws TasteException
getUserIDs
in interface DataModel
TasteException
public PreferenceArray getPreferencesFromUser(long userID) throws TasteException
getPreferencesFromUser
in interface DataModel
TasteException
public FastIDSet getItemIDsFromUser(long userID) throws TasteException
getItemIDsFromUser
in interface DataModel
TasteException
public LongPrimitiveIterator getItemIDs() throws TasteException
getItemIDs
in interface DataModel
TasteException
public PreferenceArray getPreferencesForItem(long itemID) throws TasteException
getPreferencesForItem
in interface DataModel
TasteException
public Float getPreferenceValue(long userID, long itemID) throws TasteException
getPreferenceValue
in interface DataModel
TasteException
public Long getPreferenceTime(long userID, long itemID) throws TasteException
getPreferenceTime
in interface DataModel
TasteException
public int getNumItems() throws TasteException
getNumItems
in interface DataModel
TasteException
public int getNumUsers() throws TasteException
getNumUsers
in interface DataModel
TasteException
public int getNumUsersWithPreferenceFor(long itemID) throws TasteException
getNumUsersWithPreferenceFor
in interface DataModel
TasteException
public int getNumUsersWithPreferenceFor(long itemID1, long itemID2) throws TasteException
getNumUsersWithPreferenceFor
in interface DataModel
TasteException
public void setPreference(long userID, long itemID, float value) throws TasteException
setPreference
in interface DataModel
TasteException
public void removePreference(long userID, long itemID) throws TasteException
removePreference
in interface DataModel
TasteException
public boolean hasPreferenceValues()
hasPreferenceValues
in interface DataModel
public float getMaxPreference()
getMaxPreference
in interface DataModel
public float getMinPreference()
getMinPreference
in interface DataModel
public void refresh(Collection<Refreshable> alreadyRefreshed)
refresh
in interface Refreshable
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.