October 2, 2016

Installing scikit-learn in Windows : The Easy Way

I recently found myself in need of a quick prototyping tool for machine learning. That was when a dear friend of mine suggested to try out scikit-learn. I didn't know Python. Yet, however, that wasn't what disappointed me. You know you can learn Python in a day or two. Thats not the point. Your patience will be called in to action when you start setting up environment for development in Windows, or lets just say there's no easy getaway with installing anything on Windows.

I am using Windows 7 here. For those of you who are trying to get on with scikit-learn in your Windows machine, start with Python 2.7. I am assuming that you have your environment ready with Python and pip. If you are not, then set your environment PATH variable with C:\Python27\Scripts. This will allow your machine to recognize pip.

If you look at how to install scikit-learn page, there are two dependencies -
  • NumPy, and
  • SciPy
Before you install scikit-learn, you are required to have NumPy and SciPy in your machine. Now a lot of people stumbled upon this part because of a number of known reasons. A bit of googling will lead you to some stackoverflow posts. I will summarize here some known issues -
  1. Missing Visual C++ for Python 2.7. Just download and install VC compiler for Python 2.7. That will solve this issue.
  2. SciPy not installed [not properly installed!]
  3. Numpy+MKL is missing
There are other issues, but I think someway or the other, these three are related and core to installation problems. You can avoid the trouble by following this way -
  1. Download NumPy binary from here. DO NOT pip install numpy. Go to the directory where this file has been downloaded, open command prompt, write pip install "numpy-1.11.2rc1+mkl-cp27-cp27m-win32.whl".
  2. Download SciPy binary from the same site. Follow the same procedure above and write pip install scipy-0.18.1-cp27-cp27m-win32.whl.
  3. Finally if numpy and scipy installations are successful, install scikit-learn by writing pip install -U scikit-learn.
At this point, scikit-learn should work in your Windows 7 machine.