|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mahout.cf.taste.impl.recommender.slopeone.MemoryDiffStorage
public final class MemoryDiffStorage
An implementation of DiffStorage that merely stores item-item diffs in memory. It is fast, but can
consume a great deal of memory.
| Constructor Summary | |
|---|---|
MemoryDiffStorage(DataModel dataModel,
Weighting stdDevWeighted,
long maxEntries)
See SlopeOneRecommender for the meaning of
stdDevWeighted. |
|
| Method Summary | |
|---|---|
void |
addItemPref(long userID,
long itemIDA,
float prefValue)
Updates internal data structures to reflect a new preference value for an item. |
RunningAverage |
getAverageItemPref(long itemID)
|
RunningAverage |
getDiff(long itemID1,
long itemID2)
|
RunningAverage[] |
getDiffs(long userID,
long itemID,
PreferenceArray prefs)
|
FastIDSet |
getRecommendableItemIDs(long userID)
|
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation. |
void |
removeItemPref(long userID,
long itemIDA,
float prefValue)
Updates internal data structures to reflect an update in a preference value for an item. |
String |
toString()
|
void |
updateItemPref(long itemID,
float prefDelta)
Updates internal data structures to reflect an update in a preference value for an item. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MemoryDiffStorage(DataModel dataModel,
Weighting stdDevWeighted,
long maxEntries)
throws TasteException
See SlopeOneRecommender for the meaning of
stdDevWeighted. maxEntries controls the maximum number of
item-item average preference differences that will be tracked internally. After the limit is reached, if
a new item-item pair is observed in the data it will be ignored. This is recommended for large datasets.
The first maxEntries item-item pairs observed in the data are tracked. Assuming that item
ratings are reasonably distributed among users, this should only ignore item-item pairs that are very
infrequently co-rated by a user. The intuition is that data on these infrequently co-rated item-item
pairs is less reliable and should be the first that is ignored. This parameter can be used to limit the
memory requirements of SlopeOneRecommender, which otherwise grow as the square of the number of
items that exist in the DataModel. Memory requirements can reach gigabytes with only about 10000
items, so this may be necessary on larger datasets.
stdDevWeighted - see SlopeOneRecommendermaxEntries - maximum number of item-item average preference differences to track internally
IllegalArgumentException - if maxEntries is not positive or dataModel is null
TasteException| Method Detail |
|---|
public RunningAverage getDiff(long itemID1,
long itemID2)
getDiff in interface DiffStorageRunningAverage encapsulating the average difference in preferences between items
corresponding to itemID1 and itemID2, in that direction; that is, it's
the average of item 2's preferences minus item 1's preferences
public RunningAverage[] getDiffs(long userID,
long itemID,
PreferenceArray prefs)
getDiffs in interface DiffStorageuserID - user ID to get diffs foritemID - itemID to assessprefs - user's preferendces
RunningAverages for that user's item-item diffspublic RunningAverage getAverageItemPref(long itemID)
getAverageItemPref in interface DiffStorageRunningAverage encapsulating the average preference for the given item
public void addItemPref(long userID,
long itemIDA,
float prefValue)
throws TasteException
DiffStorageUpdates internal data structures to reflect a new preference value for an item.
addItemPref in interface DiffStorageuserID - user whose pref is being addeditemIDA - item to add preference value forprefValue - new preference value
TasteException
public void updateItemPref(long itemID,
float prefDelta)
DiffStorageUpdates internal data structures to reflect an update in a preference value for an item.
updateItemPref in interface DiffStorageitemID - item to update preference value forprefDelta - amount by which preference value changed
public void removeItemPref(long userID,
long itemIDA,
float prefValue)
throws TasteException
DiffStorageUpdates internal data structures to reflect an update in a preference value for an item.
removeItemPref in interface DiffStorageuserID - user whose pref is being removeditemIDA - item to update preference value forprefValue - old preference value
TasteException
public FastIDSet getRecommendableItemIDs(long userID)
throws TasteException
getRecommendableItemIDs in interface DiffStorageTasteExceptionpublic void refresh(Collection<Refreshable> alreadyRefreshed)
RefreshableTriggers "refresh" -- whatever that means -- of the implementation. The general contract is that any should always leave itself in a consistent, operational state, and that the refresh atomically updates internal state from old to new.
refresh in interface RefreshablealreadyRefreshed - s that are known to have already been
refreshed as a result of an initial call to a method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||