## 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 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`.

Constructor Summary
`ThresholdUserNeighborhood(double threshold, UserSimilarity userSimilarity, DataModel dataModel)`
`ThresholdUserNeighborhood(double threshold, UserSimilarity userSimilarity, DataModel dataModel, double samplingRate)`

Method Summary
`long[]` `getUserNeighborhood(long userID)`
`void` `refresh(Collection<Refreshable> alreadyRefreshed)` Triggers "refresh" -- whatever that means -- of the implementation.
`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,
                                     UserSimilarity userSimilarity,
                                     DataModel dataModel)

Parameters:
  `threshold` - similarity threshold
  `userSimilarity` - similarity metric
  `dataModel` - data model
Throws:
  `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 threshold
  `userSimilarity` - similarity metric
  `dataModel` - data model
  `samplingRate` - percentage of users to consider when building neighborhood -- decrease to trade quality for performance
Throws:
  `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`

Method Detail

### 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 String toString()

  Overrides:
    `toString` in class `Object`

### refresh

    public final void refresh(Collection<Refreshable> alreadyRefreshed)

  Description copied from interface: `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.

  Specified by:
    `refresh` in interface `Refreshable`
  Parameters:
    `alreadyRefreshed` - `Refreshable`s that are known to have already been refreshed as a result of an initial call to a `Refreshable.refresh(Collection)` method on some object. This ensure that objects in a refresh dependency graph aren't refreshed twice needlessly.

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.