org.apache.mahout.cf.taste.impl.neighborhood
Class NearestNUserNeighborhood
java.lang.Object
org.apache.mahout.cf.taste.impl.neighborhood.NearestNUserNeighborhood
- All Implemented Interfaces:
- Refreshable, UserNeighborhood
public final class NearestNUserNeighborhood
- extends java.lang.Object
Computes a neighborhood consisting of the nearest n users to a given user. "Nearest" is defined by the
given UserSimilarity
.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
NearestNUserNeighborhood
public NearestNUserNeighborhood(int n,
UserSimilarity userSimilarity,
DataModel dataModel)
throws TasteException
- Parameters:
n
- neighborhood size; capped at the number of users in the data model
- Throws:
java.lang.IllegalArgumentException
- if n < 1, or userSimilarity or dataModel are null
TasteException
NearestNUserNeighborhood
public NearestNUserNeighborhood(int n,
double minSimilarity,
UserSimilarity userSimilarity,
DataModel dataModel)
throws TasteException
- Parameters:
n
- neighborhood size; capped at the number of users in the data modelminSimilarity
- minimal similarity required for neighbors
- Throws:
java.lang.IllegalArgumentException
- if n < 1, or userSimilarity or dataModel are null
TasteException
NearestNUserNeighborhood
public NearestNUserNeighborhood(int n,
double minSimilarity,
UserSimilarity userSimilarity,
DataModel dataModel,
double samplingRate)
throws TasteException
- Parameters:
n
- neighborhood size; capped at the number of users in the data modelminSimilarity
- minimal similarity required for neighborssamplingRate
- percentage of users to consider when building neighborhood -- decrease to trade quality for
performance
- Throws:
java.lang.IllegalArgumentException
- if n < 1 or samplingRate is NaN or not in (0,1], or userSimilarity or dataModel are
null
TasteException
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.