|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.cf.taste.impl.transforms.InverseUserFrequency
public final class InverseUserFrequency
Implements an "inverse user frequency" transformation, which boosts preference values for items for which few users have expressed a preference, and reduces preference values for items for which many users have expressed a preference. The idea is that these "rare" items are more useful in deciding how similar two users' tastes are, and so should be emphasized in other calculatioons. This idea is mentioned in Empirical Analysis of Predictive Algorithms for Collaborative Filtering.
A scaling factor is computed for each item by dividing the total number of users by the number of users expressing a preference for that item, and taking the log of that value. The log base of this calculation can be controlled in the constructor. Intuitively, the right value for the base is equal to the average number of users who express a preference for each item in your model. If each item has about 100 preferences on average, 100.0 is a good log base.
Constructor Summary | |
---|---|
InverseUserFrequency(DataModel dataModel,
double logBase)
Creates a transformation. |
Method Summary | |
---|---|
double |
getLogBase()
|
float |
getTransformedValue(Preference pref)
|
void |
refresh(java.util.Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public InverseUserFrequency(DataModel dataModel, double logBase) throws TasteException
Creates a transformation. Computations use the given log base.
dataModel
- DataModel
from which to calculate user frequencieslogBase
- calculation logarithm base
java.lang.IllegalArgumentException
- if dataModel is null
or logBase is Double.NaN
or <= 1.0
TasteException
Method Detail |
---|
public double getLogBase()
public float getTransformedValue(Preference pref)
getTransformedValue
in interface PreferenceTransform
public void refresh(java.util.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.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |