com.planetj.taste.impl.neighborhood
Class NearestNUserNeighborhood
java.lang.Object
com.planetj.taste.impl.neighborhood.NearestNUserNeighborhood
- All Implemented Interfaces:
- Refreshable, UserNeighborhood
public final class NearestNUserNeighborhood
- extends java.lang.Object
Computes a neigbhorhood consisting of the nearest n Users to a given User.
"Nearest" is defined by the given UserCorrelation.
- Author:
- Sean Owen
|
Method Summary |
java.util.Collection<User> |
getUserNeighborhood(java.lang.Object userID)
|
void |
refresh()
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 |
NearestNUserNeighborhood
public NearestNUserNeighborhood(int n,
UserCorrelation userCorrelation,
DataModel dataModel)
throws TasteException
- Parameters:
n - neighborhood sizeuserCorrelation - nearness metricdataModel - data model
- Throws:
java.lang.IllegalArgumentException - if n < 1, or userCorrelation or dataModel are null
TasteException
NearestNUserNeighborhood
public NearestNUserNeighborhood(int n,
UserCorrelation userCorrelation,
DataModel dataModel,
double samplingRate)
throws TasteException
- Parameters:
n - neighborhood sizeuserCorrelation - nearness metricdataModel - data modelsamplingRate - 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 userCorrelation or dataModel are null
TasteException- Since:
- 1.3
getUserNeighborhood
@NotNull
public java.util.Collection<User> getUserNeighborhood(java.lang.Object userID)
throws TasteException
-
- Parameters:
userID - ID of user for which a neighborhood will be computed
- Returns:
Collection of Users in the neighborhood
- Throws:
TasteException - if an error occurs while accessing data
toString
@NotNull
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
refresh
public final void refresh()
Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that
any Refreshable 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