• Stars
    star
    207
  • Rank 189,831 (Top 4 %)
  • Language
    R
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

R package recommenderlab - Lab for Developing and Testing Recommender Algorithms

CRAN version stream r-universe status CRAN RStudio mirror downloads

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. Supported algorithms are:

  • 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)

For evaluation, the framework supports given-n and all-but-x protocols with

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

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

More Repositories

1

dbscan

Density Based Clustering of Applications with Noise (DBSCAN) and Related Algorithms - R package
C++
278
star
2

arules

Mining Association Rules and Frequent Itemsets with R
R
181
star
3

Introduction_to_Data_Mining_R_Examples

R Code to accompany the book Introduction to Data Mining by Tan, Steinbach and Kumar (Code by Michael Hahsler)
HTML
101
star
4

rBLAST

Interface for the Basic Local Alignment Search Tool (BLAST) - R-Package
R
99
star
5

seriation

Infrastructure for Ordering using Seriation - R Package
R
72
star
6

TSP

Traveling Salesperson Problem - R package
R
61
star
7

arulesViz

Visualizing Association Rules and Frequent Itemsets with R
R
52
star
8

CS7320-AI

Examples for an AI course following the textbook Artificial Intelligence: A Modern Approach by Russell and Norvig.
Jupyter Notebook
44
star
9

stream

A framework for data stream modeling and associated data mining tasks such as clustering and classification. - R Package
R
36
star
10

pomdp

R package for Partially Observable Markov Decision Processes
R
14
star
11

CS2341

Code Examples for Data Structures with C++
C++
13
star
12

streamMOA

Interface for data stream clustering algorithms implemented in the MOA (Massive Online Analysis) framework.
R
12
star
13

rMSA

Interface to Popular Multiple Sequence Alignment Tools - R-package
TeX
8
star
14

arulespy

Python interface to arules for association rule mining
TeX
7
star
15

arulesNBMiner

Mining NB-Frequent Itemsets and NB-Precise Rules - R Package
Java
6
star
16

qap

Heuristics for the Quadratic Assignment Problem (QAP) - R package
Fortran
4
star
17

ShinyApp_DB_HelloWorld

An example for a simple ShinyApp that connects to a remote database (SQLServer)
R
3
star
18

mdp

R package for Discrete-Time Markov Decision Processes
R
2
star
19

fit_dist

Simple R script to fit distributions to data
R
2
star
20

rRDP

Seamlessly interfaces RDP classifier.
R
1
star
21

streamConnect

Connecting Stream Mining Components Using Web Services
R
1
star
22

rEMM

R
1
star
23

pomdpSolve

Provides Cassandra's pomdp-solve program.
C
1
star