## org.apache.mahout.cf.taste.impl.transforms
Class InverseUserFrequency

    java.lang.Object
      org.apache.mahout.cf.taste.impl.transforms.InverseUserFrequency

All Implemented Interfaces:
  Refreshable, PreferenceTransform

    public final class InverseUserFrequency

extends java.lang.Object
implements PreferenceTransform

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

### InverseUserFrequency

    public InverseUserFrequency(DataModel dataModel,
                                double logBase)
                         throws TasteException

  Creates a transformation. Computations use the given log base.

  Parameters:
    `dataModel` - `DataModel` from which to calculate user frequencies
    `logBase` - calculation logarithm base
  Throws:
    `java.lang.IllegalArgumentException` - if dataModel is `null` or logBase is `Double.NaN` or <= 1.0
    `TasteException`

Method Detail

### getLogBase

    public double getLogBase()

  Returns:
    log base used in this object's calculations

### getTransformedValue

    public float getTransformedValue(Preference pref)

  Specified by:
    `getTransformedValue` in interface `PreferenceTransform`

### refresh

    public void refresh(java.util.Collection<Refreshable> alreadyRefreshed)

  Description copied from interface: `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.

  Specified by:
    `refresh` in interface `Refreshable`
  Parameters:
    `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.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.