com.planetj.taste.impl.neighborhood
Class ThresholdUserNeighborhood

java.lang.Object
  extended by com.planetj.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. Similartiy is defined by the given UserCorrelation.

Author:
Sean Owen

Constructor Summary
ThresholdUserNeighborhood(double threshold, UserCorrelation userCorrelation, DataModel dataModel)
           
ThresholdUserNeighborhood(double threshold, UserCorrelation userCorrelation, DataModel dataModel, double samplingRate)
           
 
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
 

Constructor Detail

ThresholdUserNeighborhood

public ThresholdUserNeighborhood(double threshold,
                                 UserCorrelation userCorrelation,
                                 DataModel dataModel)
                          throws TasteException
Parameters:
threshold - similarity threshold
userCorrelation - similarity metric
dataModel - 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 userCorrelation or dataModel are null
TasteException

ThresholdUserNeighborhood

public ThresholdUserNeighborhood(double threshold,
                                 UserCorrelation userCorrelation,
                                 DataModel dataModel,
                                 double samplingRate)
                          throws TasteException
Parameters:
threshold - similarity threshold
userCorrelation - similarity metric
dataModel - data model
samplingRate - 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 userCorrelation or dataModel are null
TasteException
Since:
1.3
Method Detail

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