|
||||||||||
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.file.FileDiffStorage
public final class FileDiffStorage
DiffStorage
which reads pre-computed diffs from a file and stores in memory. The file should have
one diff per line:
itemID1,itemID2,diff[,count[,mk,sk]]
The fourth column is optional, and is a count representing the number of occurrences of the item-item pair
that contribute to the diff. It is assumed to be 1 if not present. The fifth and sixth arguments are
computed values used by FullRunningAverageAndStdDev
implementations to compute a running standard deviation.
They are required if using Weighting.WEIGHTED
with SlopeOneRecommender
.
Commas or tabs can be delimiters. This is intended for use in conjuction with the output of
SlopeOneAverageDiffsJob
.
Note that the same item-item pair should not appear on multiple lines -- one line per item-item pair.
Constructor Summary | |
---|---|
FileDiffStorage(File dataFile,
long maxEntries)
|
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. |
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, toString, wait, wait, wait |
Constructor Detail |
---|
public FileDiffStorage(File dataFile, long maxEntries) throws FileNotFoundException
dataFile
- diffs filemaxEntries
- maximum number of diffs to store
FileNotFoundException
- if data file does not exist or is a directoryMethod Detail |
---|
public RunningAverage getDiff(long itemID1, long itemID2)
getDiff
in interface DiffStorage
RunningAverage
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 preferencespublic RunningAverage[] getDiffs(long userID, long itemID, PreferenceArray prefs)
getDiffs
in interface DiffStorage
userID
- user ID to get diffs foritemID
- itemID to assessprefs
- user's preferendces
RunningAverage
s for that user's item-item diffspublic RunningAverage getAverageItemPref(long itemID)
getAverageItemPref
in interface DiffStorage
RunningAverage
encapsulating the average preference for the given itempublic void addItemPref(long userID, long itemIDA, float prefValue)
DiffStorage
Updates internal data structures to reflect a new preference value for an item.
addItemPref
in interface DiffStorage
userID
- user whose pref is being addeditemIDA
- item to add preference value forprefValue
- new preference valuepublic void updateItemPref(long itemID, float prefDelta)
DiffStorage
Updates internal data structures to reflect an update in a preference value for an item.
updateItemPref
in interface DiffStorage
itemID
- item to update preference value forprefDelta
- amount by which preference value changedpublic void removeItemPref(long userID, long itemIDA, float prefValue)
DiffStorage
Updates internal data structures to reflect an update in a preference value for an item.
removeItemPref
in interface DiffStorage
userID
- user whose pref is being removeditemIDA
- item to update preference value forprefValue
- old preference valuepublic FastIDSet getRecommendableItemIDs(long userID)
getRecommendableItemIDs
in interface DiffStorage
public void refresh(Collection<Refreshable> alreadyRefreshed)
Refreshable
Triggers "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 Refreshable
alreadyRefreshed
- 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |