rsparse
is an R package for statistical learning primarily on sparse matrices - matrix factorizations, factorization machines, out-of-core regression. Many of the implemented algorithms are particularly useful for recommender systems and NLP.
On top of that we provide some optimized routines to work on sparse matrices - multithreaded <dense, sparse> matrix multiplications and improved support for sparse matrices in CSR format (Matrix::RsparseMatrix
).
We've paid some attention to the implementation details - we try to avoid data copies, utilize multiple threads via OpenMP and use SIMD where appropriate. Package allows to work on datasets with millions of rows and millions of columns.
Please reach us if you need commercial support - hello@rexy.ai.
Matrix::RsparseMatrix
. However common R Matrix::CpasrseMatrix
(dgCMatrix
) will be converted automatically.WRMF
class and constructor option feedback = "explicit"
. Original paper which indroduced MMMF could be found here.WRMF
class and constructor option feedback = "implicit"
.We provide 2 solvers: 1. Exact based of Cholesky Factorization 1. Approximated based on fixed number of steps of Conjugate Gradient. See details in Applications of the Conjugate Gradient Method for Implicit Feedback Collaborative Filtering and Faster Implicit Matrix Factorization. *
%*%
and tcrossprod()
for <dgRMatrix, matrix>
%*%
and crossprod()
for <matrix, dgCMatrix>
CSR
matrices (Matrix::RsparseMatrix
) without converting them to triplet / CSCMost of the algorithms benefit from OpenMP and many of them could utilize high-performance implementation of BLAS. If you want make maximum out of the package please read the section below carefuly.
It is recommended to:
~/.R/Makevars
. For example on recent processors (with AVX support) and complier with OpenMP support following lines could be a good option:CXX11FLAGS += -O3 -march=native -mavx -fopenmp -ffast-math
CXXFLAGS += -O3 -march=native -mavx -fopenmp -ffast-math
If you are on Mac follow instructions here. After installation of clang4
additionally put PKG_CXXFLAGS += -DARMA_USE_OPENMP
line to your ~/.R/Makevars
. After that install rsparse
in a usual way.
Note that syntax is these posts/slides is not up to date since package was under active development
Here is example of rsparse::WRMF
on lastfm360k dataset in comparison with other good implementations:
We follow mlapi conventions.
Generate configure:
autoconf configure.ac > configure && chmod +x configure
install.packages('rsparse')