An open API service indexing awesome lists of open source software.

https://github.com/mhahsler/recommenderlab

recommenderlab - Lab for Developing and Testing Recommender Algorithms - R package
https://github.com/mhahsler/recommenderlab

collaborative-filtering recommender-system

Last synced: 4 days ago
JSON representation

recommenderlab - Lab for Developing and Testing Recommender Algorithms - R package

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r echo=FALSE, results = 'asis'}
pkg <- 'recommenderlab'

source("https://raw.githubusercontent.com/mhahsler/pkg_helpers/main/pkg_helpers.R")
pkg_title(pkg)
```

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

```{r echo=FALSE, results = 'asis'}
pkg_usage(pkg)
pkg_citation(pkg, 2)
```

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

```{r echo=FALSE, results = 'asis'}
pkg_install(pkg)
```

## 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.
```{r}
set.seed(1234)

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

MovieLense100 <- MovieLense[rowCounts(MovieLense) > 100, ]
MovieLense100
```

Train a user-based collaborative filtering recommender using a small training set.
```{r}
train <- MovieLense100[1:300]
rec <- Recommender(train, method = "UBCF")
rec
```

Create top-N recommendations for new users (users 301 and 302).
```{r}
pre <- predict(rec, MovieLense100[301:302], n = 5)
pre
```

```{r}
as(pre, "list")
```

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.
```{r TNR_vs_TPR}
scheme <- evaluationScheme(MovieLense100, method = "cross-validation", k = 10,
given = -5, goodRating = 4)
scheme

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/](https://mhahsler-apps.shinyapps.io/Jester/)
([source code](https://github.com/mhahsler/recommenderlab/tree/master/Work/apps)).

## References

* Michael Hahsler (2022) recommenderlab: An R framework for developing and testing recommendation algorithms. arXiv:2205.12371 [cs.IR]. DOI: [10.48550/arXiv.2205.12371](https://doi.org/10.48550/arXiv.2205.12371).
* recommenderlab [reference manual](https://CRAN.R-project.org/package=recommenderlab/recommenderlab.pdf)
* Suresh K. Gorakala and Michele Usuelli (2015) [Building a Recommendation System with R](https://www.amazon.com/Building-Recommendation-System-Suresh-Gorakala/dp/1783554495) (Packt Publishing) features the package recommenderlab.