View source: R/HybridRecommender.R
HybridRecommender | R Documentation |
Creates and combines recommendations using several recommender algorithms.
HybridRecommender(..., weights = NULL, aggregation_type = "sum")
... |
objects of class 'Recommender'. |
weights |
weights for the recommenders. The recommenders are equally weighted by default. |
aggregation_type |
How are the recommendations aggregated. Options are "sum", "min", and "max". |
The hybrid recommender is initialized with a set of pretrained Recommender objects. Typically, the algorithms are trained using the same training set. If different training sets are used, then, at least the training sets need to have the same items in the same order.
Alternatively, hybrid recommenders can be created using the regular Recommender()
interface. Here method
is set to HYBRID
and parameter
contains
a list with recommenders and weights. recommenders are a list of recommender alorithms,
where each algorithms is represented as a list with elements name (method of the recommender)
and parameters (the algorithms parameters). This method can be used in evaluate()
For creating recommendations (predict
), each recommender algorithm
is used to create ratings. The individual ratings are combined using
a weighted sum where missing ratings are ignored. Weights can be specified in weights
.
An object of class 'Recommender'.
Recommender
data("MovieLense")
MovieLense100 <- MovieLense[rowCounts(MovieLense) >100,]
train <- MovieLense100[1:100]
test <- MovieLense100[101:103]
## mix popular movies with a random recommendations for diversity and
## rerecommend some movies the user liked.
recom <- HybridRecommender(
Recommender(train, method = "POPULAR"),
Recommender(train, method = "RANDOM"),
Recommender(train, method = "RERECOMMEND"),
weights = c(.6, .1, .3)
)
recom
getModel(recom)
as(predict(recom, test), "list")
## create a hybrid recommender using the regular Recommender interface.
## This is needed to use hybrid recommenders with evaluate().
recommenders <- list(
RANDOM = list(name = "POPULAR", param = NULL),
POPULAR = list(name = "RANDOM", param = NULL),
RERECOMMEND = list(name = "RERECOMMEND", param = NULL)
)
weights <- c(.6, .1, .3)
recom <- Recommender(train, method = "HYBRID",
parameter = list(recommenders = recommenders, weights = weights))
recom
as(predict(recom, test), "list")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.