org.apache.mahout.cf.taste.example.kddcup
Class KDDCupDataModel

java.lang.Object
  extended by 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

Constructor Summary
KDDCupDataModel(File dataFile)
           
KDDCupDataModel(File dataFile, boolean storeDates, double samplingRate)
           
 
Method Summary
 File getDataFileDirectory()
           
 LongPrimitiveIterator getItemIDs()
           
 FastIDSet getItemIDsFromUser(long userID)
           
 float getMaxPreference()
           
 float getMinPreference()
           
 int getNumItems()
           
 int getNumUsers()
           
 int getNumUsersWithPreferenceFor(long itemID)
           
 int getNumUsersWithPreferenceFor(long itemID1, long itemID2)
           
 PreferenceArray getPreferencesForItem(long itemID)
           
 PreferenceArray getPreferencesFromUser(long userID)
           
 Long getPreferenceTime(long userID, long itemID)
           
 Float getPreferenceValue(long userID, long itemID)
           
static File getTestFile(File dataFileDirectory)
           
static File getTrackFile(File dataFileDirectory)
           
static File getTrainingFile(File dataFileDirectory)
           
 LongPrimitiveIterator getUserIDs()
           
static File getValidationFile(File dataFileDirectory)
           
 boolean hasPreferenceValues()
           
 void refresh(Collection<Refreshable> alreadyRefreshed)
           
 void removePreference(long userID, long itemID)
           
 void setPreference(long userID, long itemID, float value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 file
storeDates - if true, dates are parsed and stored, otherwise not
samplingRate - percentage of users to keep; can be used to reduce memory requirements
Throws:
IOException
Method Detail

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.