MyNixOS website logo
Description

Lab for Developing and Testing Recommender Algorithms.

Provides a research infrastructure to develop and evaluate collaborative filtering recommender algorithms. This includes a sparse representation for user-item matrices, many popular algorithms, top-N recommendations, and cross-validation. Hahsler (2022) <doi:10.48550/arXiv.2205.12371>.

R package recommenderlab - Lab for Developing and Testing Recommender Algorithms

CRANversion stream r-universestatus CRAN RStudio mirrordownloads

Introduction

Provides a research infrastructure to develop and evaluate collaborative filtering recommender algorithms. This includes a sparse representation for user-item matrices, many popular algorithms, top-N recommendations, and cross-validation. The package supports rating (e.g., 1-5 stars) and unary (0-1) data sets.

The following R packages use recommenderlab: cmfrec, crassmat, recometrics, recommenderlabBX, recommenderlabJester, RMOA

Please cite the use of this package as:

Hahsler M (2022). “recommenderlab: An R Framework for Developing and Testing Recommendation Algorithms.” arXiv:2205.12371 [cs.IR]. doi:10.48550/ARXIV.2205.12371https://doi.org/10.48550/ARXIV.2205.12371.

@Misc{,
  title = {recommenderlab: An R Framework for Developing and Testing Recommendation Algorithms},
  author = {Michael Hahsler},
  year = {2022},
  doi = {10.48550/ARXIV.2205.12371},
  howpublished = {arXiv:2205.12371 [cs.IR]},
  month = {May},
}

Supported algorithms

Recommender algorithm

  • User-based collaborative filtering (UBCF)
  • Item-based collaborative filtering (IBCF)
  • SVD with column-mean imputation (SVD)
  • Funk SVD (SVDF)
  • Alternating Least Squares (ALS)
  • Matrix factorization with LIBMF (LIBMF)
  • Association rule-based recommender (AR)
  • Popular items (POPULAR)
  • Randomly chosen items for comparison (RANDOM)
  • Re-recommend liked items (RERECOMMEND)
  • Hybrid recommendations (HybridRecommender)

Recommender Evaluation

The framework supports given-n and all-but-x protocols with

  • Train/test split
  • Cross-validation
  • Repeated bootstrap sampling

Available evaluation measures are

  • Rating errors: MSE, RMSE, MAE
  • Top-N recommendations: TPR/FPR (ROC), precision and recall

Installation

Stable CRAN version: Install from within R with

install.packages("recommenderlab")

Current development version: Install from r-universe.

install.packages("recommenderlab", repos = "https://mhahsler.r-universe.dev")

Usage

Load the package and prepare a dataset (included in the package). The MovieLense data contains user ratings for movies on a 1 to 5 star scale. We only use here users with more than 100 ratings.

set.seed(1234)

library("recommenderlab")
data("MovieLense")

MovieLense100 <- MovieLense[rowCounts(MovieLense) > 100, ]
MovieLense100
## 358 x 1664 rating matrix of class 'realRatingMatrix' with 73610 ratings.

Train a user-based collaborative filtering recommender using a small training set.

train <- MovieLense100[1:300]
rec <- Recommender(train, method = "UBCF")
rec
## Recommender of type 'UBCF' for 'realRatingMatrix' 
## learned using 300 users.

Create top-N recommendations for new users (users 301 and 302).

pre <- predict(rec, MovieLense100[301:302], n = 5)
pre
## Recommendations as 'topNList' with n = 5 for 2 users.
as(pre, "list")
## $`0`
## [1] "Amistad (1997)"                    "Kama Sutra: A Tale of Love (1996)"
## [3] "Farewell My Concubine (1993)"      "Roommates (1995)"                 
## [5] "Fresh (1994)"                     
## 
## $`1`
## [1] "Bitter Moon (1992)"         "Touch of Evil (1958)"      
## [3] "Braindead (1992)"           "Great Dictator, The (1940)"
## [5] "M (1931)"

Use a 10-fold cross-validation scheme to compare the top-N lists of several algorithms. Movies with 4 or more stars are considered a good recommendation. We plot true negative vs. true positive rate for top-N lists of different lengths.

scheme <- evaluationScheme(MovieLense100, method = "cross-validation", k = 10, given = -5,
    goodRating = 4)
scheme
## Evaluation scheme using all-but-5 items
## Method: 'cross-validation' with 10 run(s).
## Good ratings: >=4.000000
## Data set: 358 x 1664 rating matrix of class 'realRatingMatrix' with 73610 ratings.
algorithms <- list(`random items` = list(name = "RANDOM", param = NULL), `popular items` = list(name = "POPULAR",
    param = NULL), `user-based CF` = list(name = "UBCF", param = list(nn = 3)), `item-based CF` = list(name = "IBCF",
    param = list(k = 100)))

results <- evaluate(scheme, algorithms, type = "topNList", n = c(1, 3, 5, 10), progress = FALSE)

plot(results, annotate = 2, legend = "topleft")

Shiny App

A simple Shiny App running recommenderlab can be found at https://mhahsler-apps.shinyapps.io/Jester/ (source code).

References

Metadata

Version

1.0.6

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows