# What is this?

R package which implement several algrithms for matrix factorization targeting recommender systems.

Package is quite efficient - extensively use BLAS and parallelized with OpenMP, see benchmarks below.

# Tutorials

- Introduction to matrix factorization with Weighted-ALS algorithm - collaborative filtering for implicit feedback datasets.
- Music recommendations using LastFM-360K dataset
- evaluation metrics for ranking
- setting up proper cross-validation
- possible issues with nested parallelism and thread contention
- making recommendations for new users
- complimentary item-to-item recommendations

- Benchmark against other good implementations

# Algorithms

At the moment following algorithms are implemented:

### Alternating Least Squares for implicit feedback

Current implementation used RcppArmadillo and **extensively uses BLAS and LAPACK**, so on my 4-core PC with OpenBLAS it is **~1.7x faster** than highly optimized Quora's qmf library.

See Collaborative Filtering for Implicit Feedback Datasets paper by (Yifan Hu, Yehuda Koren, Chris Volinsky) for details.

**VERY IMPORTANT** if you use multithreaded BLAS (you generally should) such as OpenBLAS, Intel MKL, Apple Accelerate, I **highly recommend disable its internal multithreading ability**. This leads to **substantial speedups** (can be 10x!) for this package (since matrix factorization is already parallelized in package with OpenMP). This can be done by setting corresponding environment variables **before starting R**:

- OpenBLAS:
`export OPENBLAS_NUM_THREADS=1`

. - Intel MKL:
`export MKL_NUM_THREADS=1`

- Apple Accelerate:
`export VECLIB_MAXIMUM_THREADS=1`

It it also possible to change number of threads in runtime, see for example OpenBlasThreads and RhpcBLASctl packages.

### Alternating Least Squares for explicit feedback

# API

We follow mlapi conventions.

# Quice reference

TODO