org.apache.mahout.cf.taste.impl.recommender
Class SamplingCandidateItemsStrategy

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.recommender.AbstractCandidateItemsStrategy
      extended by org.apache.mahout.cf.taste.impl.recommender.SamplingCandidateItemsStrategy
All Implemented Interfaces:
Refreshable, CandidateItemsStrategy, MostSimilarItemsCandidateItemsStrategy

public class SamplingCandidateItemsStrategy
extends AbstractCandidateItemsStrategy

Returns all items that have not been rated by the user (3) and that were preferred by another user (2) that has preferred at least one item (1) that the current user has preferred too.

This strategy uses sampling to limit the number of items that are considered, by sampling three different things, noted above:

  1. The items that the user has preferred
  2. The users who also prefer each of those items
  3. The items those users also prefer

There is a maximum associated with each of these three things; if the number of items or users exceeds that max, it is sampled so that the expected number of items or users actually used in that part of the computation is equal to the max.

Three arguments control these three maxima. Each is a "factor" f, which establishes the max at f * log2(n), where n is the number of users or items in the data. For example if factor #2 is 5, which controls the number of users sampled per item, then 5 * log2(# users) is the maximum for this part of the computation.

Each can be set to not do any limiting with value NO_LIMIT_FACTOR.


Field Summary
static int DEFAULT_FACTOR
          Default factor used if not otherwise specified, for all limits.
static int NO_LIMIT_FACTOR
          Specify this value as a factor to mean no limit.
 
Constructor Summary
SamplingCandidateItemsStrategy(int numUsers, int numItems)
          Defaults to using no limit (NO_LIMIT_FACTOR) for all factors, except candidatesPerUserFactor which defaults to DEFAULT_FACTOR.
SamplingCandidateItemsStrategy(int itemsFactor, int usersPerItemFactor, int candidatesPerUserFactor, int numUsers, int numItems)
           
 
Method Summary
protected  FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel)
           
 
Methods inherited from class org.apache.mahout.cf.taste.impl.recommender.AbstractCandidateItemsStrategy
getCandidateItems, getCandidateItems, refresh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FACTOR

public static final int DEFAULT_FACTOR
Default factor used if not otherwise specified, for all limits. (30).

See Also:
Constant Field Values

NO_LIMIT_FACTOR

public static final int NO_LIMIT_FACTOR
Specify this value as a factor to mean no limit.

See Also:
Constant Field Values
Constructor Detail

SamplingCandidateItemsStrategy

public SamplingCandidateItemsStrategy(int numUsers,
                                      int numItems)
Defaults to using no limit (NO_LIMIT_FACTOR) for all factors, except candidatesPerUserFactor which defaults to DEFAULT_FACTOR.

See Also:
SamplingCandidateItemsStrategy(int, int, int, int, int)

SamplingCandidateItemsStrategy

public SamplingCandidateItemsStrategy(int itemsFactor,
                                      int usersPerItemFactor,
                                      int candidatesPerUserFactor,
                                      int numUsers,
                                      int numItems)
Parameters:
itemsFactor - factor controlling max items considered for a user
usersPerItemFactor - factor controlling max users considered for each of those items
candidatesPerUserFactor - factor controlling max candidate items considered from each of those users
numUsers - number of users currently in the data
numItems - number of items in the data
Method Detail

doGetCandidateItems

protected FastIDSet doGetCandidateItems(long[] preferredItemIDs,
                                        DataModel dataModel)
                                 throws TasteException
Specified by:
doGetCandidateItems in class AbstractCandidateItemsStrategy
Throws:
TasteException


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