|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mahout.cf.taste.impl.model.AbstractDataModel
org.apache.mahout.cf.taste.impl.model.GenericBooleanPrefDataModel
public final class GenericBooleanPrefDataModel
A simple DataModel which uses given user data as its data source. This implementation
is mostly useful for small experiments and is not recommended for contexts where performance is important.
| Constructor Summary | |
|---|---|
GenericBooleanPrefDataModel(DataModel dataModel)
Deprecated. without direct replacement. Consider toDataMap(DataModel) with GenericBooleanPrefDataModel(FastByIDMap) |
|
GenericBooleanPrefDataModel(FastByIDMap<FastIDSet> userData)
Creates a new GenericDataModel from the given users (and their preferences). |
|
GenericBooleanPrefDataModel(FastByIDMap<FastIDSet> userData,
FastByIDMap<FastByIDMap<Long>> timestamps)
Creates a new GenericDataModel from the given users (and their preferences). |
|
| Method Summary | |
|---|---|
LongPrimitiveArrayIterator |
getItemIDs()
|
FastIDSet |
getItemIDsFromUser(long userID)
|
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)
Retrieves the time at which a preference value from a user and item was set, if known. |
Float |
getPreferenceValue(long userID,
long itemID)
Retrieves the preference value for a single user and item. |
FastByIDMap<FastIDSet> |
getRawItemData()
This is used mostly internally to the framework, and shouldn't be relied upon otherwise. |
FastByIDMap<FastIDSet> |
getRawUserData()
This is used mostly internally to the framework, and shouldn't be relied upon otherwise. |
LongPrimitiveArrayIterator |
getUserIDs()
|
boolean |
hasPreferenceValues()
|
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation. |
void |
removePreference(long userID,
long itemID)
Removes a particular preference for a user. |
void |
setPreference(long userID,
long itemID,
float value)
Sets a particular preference (item plus rating) for a user. |
static FastByIDMap<FastIDSet> |
toDataMap(DataModel dataModel)
Exports the simple user IDs and associated item IDs in the data model. |
static FastByIDMap<FastIDSet> |
toDataMap(FastByIDMap<PreferenceArray> data)
|
String |
toString()
|
| Methods inherited from class org.apache.mahout.cf.taste.impl.model.AbstractDataModel |
|---|
getMaxPreference, getMinPreference, setMaxPreference, setMinPreference |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GenericBooleanPrefDataModel(FastByIDMap<FastIDSet> userData)
Creates a new GenericDataModel from the given users (and their preferences). This
DataModel retains all this information in memory and is effectively immutable.
userData - users to include
public GenericBooleanPrefDataModel(FastByIDMap<FastIDSet> userData,
FastByIDMap<FastByIDMap<Long>> timestamps)
Creates a new GenericDataModel from the given users (and their preferences). This
DataModel retains all this information in memory and is effectively immutable.
userData - users to includetimestamps - optionally, provided timestamps of preferences as milliseconds since the epoch.
User IDs are mapped to maps of item IDs to Long timestamps.
@Deprecated
public GenericBooleanPrefDataModel(DataModel dataModel)
throws TasteException
toDataMap(DataModel) with GenericBooleanPrefDataModel(FastByIDMap)
Creates a new GenericDataModel containing an immutable copy of the data from another given
DataModel.
dataModel - DataModel to copy
TasteException - if an error occurs while retrieving the other DataModel's users| Method Detail |
|---|
public static FastByIDMap<FastIDSet> toDataMap(DataModel dataModel)
throws TasteException
FastByIDMap mapping user IDs to FastIDSets representing
that user's associated items
TasteExceptionpublic static FastByIDMap<FastIDSet> toDataMap(FastByIDMap<PreferenceArray> data)
public FastByIDMap<FastIDSet> getRawUserData()
public FastByIDMap<FastIDSet> getRawItemData()
public LongPrimitiveArrayIterator getUserIDs()
public PreferenceArray getPreferencesFromUser(long userID)
throws NoSuchUserException
userID - ID of user to get prefs for
NoSuchUserException - if there is no such user
public FastIDSet getItemIDsFromUser(long userID)
throws TasteException
userID - ID of user to get prefs for
NoSuchUserException - if the user does not exist
TasteException - if an error occurs while accessing the datapublic LongPrimitiveArrayIterator getItemIDs()
LongPrimitiveIterator of all item IDs in the model, in order
public PreferenceArray getPreferencesForItem(long itemID)
throws NoSuchItemException
itemID - item ID
Preferences expressed for that item, ordered by user ID, as an array
NoSuchItemException - if the item does not exist
public Float getPreferenceValue(long userID,
long itemID)
throws NoSuchUserException
DataModel
userID - user ID to get pref value fromitemID - item ID to get pref value for
NoSuchUserException - if the user does not exist
public Long getPreferenceTime(long userID,
long itemID)
throws TasteException
DataModel
userID - user ID for preference in questionitemID - item ID for preference in question
NoSuchUserException - if the user does not exist
TasteException - if an error occurs while accessing the datapublic int getNumItems()
public int getNumUsers()
public int getNumUsersWithPreferenceFor(long itemID)
itemID - item ID to check for
public int getNumUsersWithPreferenceFor(long itemID1,
long itemID2)
itemID1 - first item ID to check foritemID2 - second item ID to check for
public void removePreference(long userID,
long itemID)
DataModelRemoves a particular preference for a user.
userID - user from which to remove preferenceitemID - item to remove preference for
public void setPreference(long userID,
long itemID,
float value)
DataModelSets a particular preference (item plus rating) for a user.
userID - user to set preference foritemID - item to set preference forvalue - preference valuepublic void refresh(Collection<Refreshable> alreadyRefreshed)
Refreshable
Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any
Refreshable should always leave itself in a consistent, operational state, and that the refresh
atomically updates internal state from old to new.
alreadyRefreshed - Refreshables that are known to have already been
refreshed as a result of an initial call to a Refreshable.refresh(Collection) method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.public boolean hasPreferenceValues()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||