public final class NearestNUserNeighborhood extends Object
Computes a neighborhood consisting of the nearest n users to a given user. "Nearest" is defined by the
given UserSimilarity
.
Constructor and Description |
---|
NearestNUserNeighborhood(int n,
double minSimilarity,
UserSimilarity userSimilarity,
DataModel dataModel) |
NearestNUserNeighborhood(int n,
double minSimilarity,
UserSimilarity userSimilarity,
DataModel dataModel,
double samplingRate) |
NearestNUserNeighborhood(int n,
UserSimilarity userSimilarity,
DataModel dataModel) |
Modifier and Type | Method and Description |
---|---|
long[] |
getUserNeighborhood(long userID) |
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation.
|
String |
toString() |
public NearestNUserNeighborhood(int n, UserSimilarity userSimilarity, DataModel dataModel) throws TasteException
n
- neighborhood size; capped at the number of users in the data modelIllegalArgumentException
- if n < 1
, or userSimilarity or dataModel are null
TasteException
public NearestNUserNeighborhood(int n, double minSimilarity, UserSimilarity userSimilarity, DataModel dataModel) throws TasteException
n
- neighborhood size; capped at the number of users in the data modelminSimilarity
- minimal similarity required for neighborsIllegalArgumentException
- if n < 1
, or userSimilarity or dataModel are null
TasteException
public NearestNUserNeighborhood(int n, double minSimilarity, UserSimilarity userSimilarity, DataModel dataModel, double samplingRate) throws TasteException
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
performanceIllegalArgumentException
- if n < 1
or samplingRate is NaN or not in (0,1], or userSimilarity or dataModel are
null
TasteException
public long[] getUserNeighborhood(long userID) throws TasteException
userID
- ID of user for which a neighborhood will be computedTasteException
- if an error occurs while accessing datapublic final void refresh(Collection<Refreshable> alreadyRefreshed)
Refreshable
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.
refresh
in interface Refreshable
alreadyRefreshed
- Refreshable
s that are known to have already been
refreshed as a result of an initial call to a {#refresh(Collection)} method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.