Sparse LInear Method (SLIM) [1] is an item-based top-N recommendation approach that combines the advantages of neighborhood- and model-based collaborative filtering methods. It achieves state-of-the-art recommendation performance and has low computational requirements.
This package provides a C-based optimized multi-threaded implementation of SLIM that consists of a set of command-line programs and a user-callable library for estimating and applying SLIM models as well as an easy to use Python interface.
SLIM uses Git submodules to manage external dependencies. Hence, please specify the --recursive
option while cloning the repo as follow:
To build SLIM you can follow the instructions below:
General dependencies for building slim are: gcc, cmake, build-essential. In Ubuntu systems these can be obtained from the apt package manager (e.g., apt-get install cmake, etc)
sudo apt-get install build-essential sudo apt-get install cmake
In order to build SLIM, first build GKlib by running:
cd lib/GKlib make config openmp=set make cd ../../
After building GKlib, you can build and install SLIM by running:
make config shared=1 cc=gcc cxx=gcc prefix=~/.local make install
In order to use SLIM's ADMM solver, you will need to install Intel's MKL library.
For Ubuntu machines on which you have sudo
privilages, we provided the depmkl.sh
script that automates the process of obtaining and installing MKL, which can be used as follows:
bash depmkl.sh source ~/.bashrc
For machines on which you do not have sudo
privilages, you should download the MKL tarball from Intel's website and then install it locally using the install.sh
script they provide. After installing it you should add your-path-to-intel/intel/mkl/bin/mklvars.sh intel64
in your bashrc and run source ~/.bashrc
.
You can build and install SLIM with MKL support by running:
make config shared=1 cc=gcc cxx=gcc with_mkl=1 prefix=~/.local make install
Note that SLIM's ADMM solver usually outperforms the default optimizer included in SLIM when the number of items in the dataset is relatively small compared to the number of users and the number of non-zeros in the dataset is large.
The Python package is located at python-package/
. The installation of python-package requires Python distutils
module and is often part of the core Python package or can be installed using a package manager, e.g., in Debian use
sudo apt-get install python-setuptools
After building the SLIM library, follow one of the following steps to install the python-package:
cd python-package sudo python setup.py install
cd python-package python setup.py install --user
Here are some examples to quickly try out SLIM on the sample datasets that are provided with SLIM.
The users can also refer to the python notebook UserGuide.ipynb
located at ./python-package/UserGuide.ipynb
for more examples on using the python api.
SLIM can also be used standalone by running the built binaries located under ./build
directory. The slim_learn
and slim_predict
program can be used to learn the model and predict using an existing model, respectively. The usage of slim_learn
is generally as follow:
slim_learn [options] train-file [output-model-file]
In above command, train-file
refers to the rating matrix stored in a file on disk in sparse format (by default it expects CSR format) and output-model-file
is the name of the file that will be used to save the learned model. The available options will be described later in detail. Following shows an example of using the slim_learn
program:
./build/Linux-x86_64/src/programs/slim_learn test/ml100k-train.csr model_output.slim
Similarly, the recommendations can be generated by using the program slim_predict
and the usage of slim_predict
is as follow:
slim_predict [options] model-file train-file [test-file]
In above command, model-file
refers to the SLIM model saved in a file, train-file
refers to the training data or past historical data used to generate the model and test-file
is the test data containing hidden ratings for the users.
The following optional parameters can be provided to the slim_learn
program.
If you use any part of this library in your research, please cite it using the following BibTex entry:
@online{slim, title = {{SLIM}: Sparse LInear Model library}, author = {Ning, Xia and Nikolakopoulos, Athanasios N. and Shui, Zeren and Sharma, Mohit and Karypis, George}, url = {https://github.com/KarypisLab/SLIM}, publisher = {GitHub}, journal = {GitHub Repository}, year = {2019}, }
SLIM was written by George Karypis with contributions by Xia Ning, Athanasios N. Nikolakopoulos, Zeren Shui and Mohit Sharma.
If you encounter any problems or have any suggestions, please contact George Karypis at karypis@cs.umn.edu.
Copyright 2019, Regents of the University of Minnesota
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.