nmslibR (Non Metric Space Library in R)
The nmslibR package is a wrapper of the Non-Metric Space Library (NMSLIB) python package. More details on the functionality of the nmslibR package can be found in the package Documentation and Vignette.
Reference:
https://github.com/searchivarius/nmslib
https://github.com/searchivarius/nmslib/blob/master/manual/manual.pdf
System Requirements
- Python (>= 2.7)
All modules should be installed in the default python configuration (the configuration that the R-session displays as default), otherwise errors will occur during the nmslibR package installation (reticulate::py_discover_config() might be useful here).
The installation notes for Linux, Macintosh, Windows are based on Python 2.7.
Debian/Ubuntu
Installation of the system requirements,
sudo pip install --upgrade pip setuptools
sudo pip install -U numpy
sudo pip install --upgrade scipy
sudo apt-get install libboost-all-dev libgsl0-dev libeigen3-dev
sudo apt-get install cmake
sudo pip install nmslib
Fedora
Installation of the system requirements,
sudo pip install --upgrade pip setuptools
sudo pip install -U numpy
sudo pip install --upgrade scipy
yum install python2-devel
yum install boost-devel
yum install gsl-devel
yum install eigen3-devel
Macintosh OSX
First do a fresh install of python using brew [ normally the brew-python will appear as python2, because python comes by default in Macintosh OS ]
brew install python
brew link --overwrite python
Then update the .bash_profile file in home directory with the following paths
export PATH=/usr/local/bin:/usr/bin:$PATH
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Installation of the system requirements,
sudo pip2 install --upgrade pip setuptools
sudo pip2 install -U numpy
sudo pip2 install --upgrade scipy
brew install boost
brew install eigen
brew install gsl
brew install cmake
brew link --overwrite cmake
sudo pip2 install nmslib
After a successful installation of the system requirements the user should open an R session and give the following reticulate command to change to the relevant (brew-python) directory (otherwise the nmslibR package won't work properly),
reticulate::use_python('/usr/local/bin/python2')
and then,
reticulate::py_discover_config()
to validate that a user is in the python version where nmslibR is installed.
Windows OS
First download of get-pip.py for windows
Update the Environment variables ( Control Panel >> System and Security >> System >> Advanced system settings >> Environment variables >> System variables >> Path >> Edit ) by adding ( for instance in case of python 2.7 ),
C:\Python27;C:\Python27\Scripts
Install the Visual C++ 2015 Build Tools
Open the Command prompt (console) and install / upgrade the system requirements,
pip install --upgrade pip setuptools
pip install -U numpy
pip install --upgrade scipy
Installation of cmake
First download cmake for Windows, win64-x64 Installer. Once the file is downloaded run the .exe file and during installation make sure to add CMake to the system PATH for all users.
Then install the nmslib library,
pip install nmslib
Installation of the nmslibR package
To install the package from CRAN use,
install.packages('nmslibR')
and to download the latest version from Github use the install_github function of the devtools package,
devtools::install_github(repo = 'mlampros/nmslibR')