org.apache.mahout.cf.taste.impl.neighborhood
Class ThresholdUserNeighborhood
java.lang.Object
org.apache.mahout.cf.taste.impl.neighborhood.ThresholdUserNeighborhood
- All Implemented Interfaces:
- Refreshable, UserNeighborhood
public final class ThresholdUserNeighborhood
- extends java.lang.Object
Computes a neigbhorhood consisting of all users whose similarity to the given user meets or exceeds a
certain threshold. Similarity is defined by the given UserSimilarity
.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ThresholdUserNeighborhood
public ThresholdUserNeighborhood(double threshold,
UserSimilarity userSimilarity,
DataModel dataModel)
- Parameters:
threshold
- similarity thresholduserSimilarity
- similarity metricdataModel
- data model
- Throws:
java.lang.IllegalArgumentException
- if threshold is Double.NaN
, or if samplingRate is not positive and less than or equal
to 1.0, or if userSimilarity or dataModel are null
ThresholdUserNeighborhood
public ThresholdUserNeighborhood(double threshold,
UserSimilarity userSimilarity,
DataModel dataModel,
double samplingRate)
- Parameters:
threshold
- similarity thresholduserSimilarity
- similarity metricdataModel
- data modelsamplingRate
- percentage of users to consider when building neighborhood -- decrease to trade quality for
performance
- Throws:
java.lang.IllegalArgumentException
- if threshold or samplingRate is Double.NaN
, or if samplingRate is not positive and less
than or equal to 1.0, or if userSimilarity or dataModel are null
getUserNeighborhood
public long[] getUserNeighborhood(long userID)
throws TasteException
- Parameters:
userID
- ID of user for which a neighborhood will be computed
- Returns:
- IDs of users in the neighborhood
- Throws:
TasteException
- if an error occurs while accessing data
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
refresh
public final 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.
Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.