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:
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
.
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
protected FastIDSet |
doGetCandidateItems(long[] preferredItemIDs,
DataModel dataModel,
boolean includeKnownItems) |
doGetCandidateItems, getCandidateItems, getCandidateItems, refresh
public static final int DEFAULT_FACTOR
public static final int NO_LIMIT_FACTOR
public SamplingCandidateItemsStrategy(int numUsers, int numItems)
NO_LIMIT_FACTOR
) for all factors, except
candidatesPerUserFactor
which defaults to DEFAULT_FACTOR
.public SamplingCandidateItemsStrategy(int itemsFactor, int usersPerItemFactor, int candidatesPerUserFactor, int numUsers, int numItems)
itemsFactor
- factor controlling max items considered for a userusersPerItemFactor
- factor controlling max users considered for each of those itemscandidatesPerUserFactor
- factor controlling max candidate items considered from each of those usersnumUsers
- number of users currently in the datanumItems
- number of items in the dataprotected FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel, boolean includeKnownItems) throws TasteException
doGetCandidateItems
in class AbstractCandidateItemsStrategy
TasteException
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.