org.apache.mahout.cf.taste.example.kddcup
Class KDDCupDataModel
java.lang.Object
org.apache.mahout.cf.taste.example.kddcup.KDDCupDataModel
- All Implemented Interfaces:
- Serializable, Refreshable, DataModel
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.
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KDDCupDataModel
public KDDCupDataModel(File dataFile)
throws IOException
- Parameters:
dataFile - training rating file
- Throws:
IOException
KDDCupDataModel
public KDDCupDataModel(File dataFile,
boolean storeDates,
double samplingRate)
throws IOException
- Parameters:
dataFile - training rating filestoreDates - if true, dates are parsed and stored, otherwise notsamplingRate - percentage of users to keep; can be used to reduce memory requirements
- Throws:
IOException
getDataFileDirectory
public File getDataFileDirectory()
getTrainingFile
public static File getTrainingFile(File dataFileDirectory)
getValidationFile
public static File getValidationFile(File dataFileDirectory)
getTestFile
public static File getTestFile(File dataFileDirectory)
getTrackFile
public static File getTrackFile(File dataFileDirectory)
getUserIDs
public LongPrimitiveIterator getUserIDs()
throws TasteException
- Specified by:
getUserIDs in interface DataModel
- Throws:
TasteException
getPreferencesFromUser
public PreferenceArray getPreferencesFromUser(long userID)
throws TasteException
- Specified by:
getPreferencesFromUser in interface DataModel
- Throws:
TasteException
getItemIDsFromUser
public FastIDSet getItemIDsFromUser(long userID)
throws TasteException
- Specified by:
getItemIDsFromUser in interface DataModel
- Throws:
TasteException
getItemIDs
public LongPrimitiveIterator getItemIDs()
throws TasteException
- Specified by:
getItemIDs in interface DataModel
- Throws:
TasteException
getPreferencesForItem
public PreferenceArray getPreferencesForItem(long itemID)
throws TasteException
- Specified by:
getPreferencesForItem in interface DataModel
- Throws:
TasteException
getPreferenceValue
public Float getPreferenceValue(long userID,
long itemID)
throws TasteException
- Specified by:
getPreferenceValue in interface DataModel
- Throws:
TasteException
getPreferenceTime
public Long getPreferenceTime(long userID,
long itemID)
throws TasteException
- Specified by:
getPreferenceTime in interface DataModel
- Throws:
TasteException
getNumItems
public int getNumItems()
throws TasteException
- Specified by:
getNumItems in interface DataModel
- Throws:
TasteException
getNumUsers
public int getNumUsers()
throws TasteException
- Specified by:
getNumUsers in interface DataModel
- Throws:
TasteException
getNumUsersWithPreferenceFor
public int getNumUsersWithPreferenceFor(long itemID)
throws TasteException
- Specified by:
getNumUsersWithPreferenceFor in interface DataModel
- Throws:
TasteException
getNumUsersWithPreferenceFor
public int getNumUsersWithPreferenceFor(long itemID1,
long itemID2)
throws TasteException
- Specified by:
getNumUsersWithPreferenceFor in interface DataModel
- Throws:
TasteException
setPreference
public void setPreference(long userID,
long itemID,
float value)
throws TasteException
- Specified by:
setPreference in interface DataModel
- Throws:
TasteException
removePreference
public void removePreference(long userID,
long itemID)
throws TasteException
- Specified by:
removePreference in interface DataModel
- Throws:
TasteException
hasPreferenceValues
public boolean hasPreferenceValues()
- Specified by:
hasPreferenceValues in interface DataModel
getMaxPreference
public float getMaxPreference()
- Specified by:
getMaxPreference in interface DataModel
getMinPreference
public float getMinPreference()
- Specified by:
getMinPreference in interface DataModel
refresh
public void refresh(Collection<Refreshable> alreadyRefreshed)
- Specified by:
refresh in interface Refreshable
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.