Setup Python Environment for ml and Deep Learning

Written by razzormandar | Published 2018/03/19
Tech Story Tags: machine-learning | python-environment-for-ml | python | deep-learning | artificial-intelligence

TLDRvia the TL;DR App

Originally Published 12 May 2017

This page gives quick and easy steps to setup your machine for machine learning and deep learning.

Hi guys, In python there are many prebuilt libraries which can be used for machine learning and deep learning. But one major problem lies in setting up the environment for development using these libraries (especially for Windows based machines).

Since most of these libraries were built to be used on Linux (Ubuntu etc), its easier to setup the working environment in Linux. At the same time its a very confusing and lengthy procedure on Windows machine.

So below are the steps to get you up and running for ml and deep learning development on Windows:

Step 1: Download Anaconda Distribution

For your version of system 32bit or 64bit from here Its better to select the version for Python 3.6 or 3.5.x since Tensorflow is yet only available for Python 3.5.

Fig 1. Anaconda Navigator download page

Step 2: Install Anaconda

Follow through the on-screen instructions Next->Next->Next-> then :

  • check the box to add python to environment variables path.
  • also make Anaconda as the default python checkbox to maintain uniformity.

Fig 2. Installation step for Anaconda 3

The following packages will be preinstalled in the Navigator:

  • Spyder (IDE of choice)
  • Jupyter Notebook (for interactive programming)
  • Qt console ( for inline figures and graphics)

Fig 3. Initial view of the Anaconda Navigator Panel

Step 4: Now go to the Environments tab

on the left side of the Navigator

  • Here click on Create new environment button, and
  • type in the Environment name you want (say environment)
  • Check only the Python check box ( uncheck R)
  • In the Python version tab select Python 3.5, since Tensorflow currently only works for 3.5

Fig 4. Environment selection and creation page

Once your new environment for Python 3.5 has been created it would appear like this

Fig 5. Installed packages in a given environment

Now from the search packages box, type-in and download the following packages:

  1. Jupyter
  2. Scikit-learn
  3. qtconsole
  4. matplotlib
  5. numpy
  6. pandas
  7. pip
  8. scipy

Step 5:

Once all above packages are installed, open up a terminal from your newly created Environment.

Fig 6. Steps to open a terminal in given environment

Once the terminal opens up type in the following for installing Theano:

conda install theano pygpu

Let the download and installation finish. After this type in the following for installing Tensorflow:

For CPU

pip install --ignore-installed --upgrade [https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl](https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl)

For GPU

pip install --ignore-installed --upgrade [https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl](https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl)

Once tensorflow has been successfully installed, type the following for installing Keras:

pip install git+git://github.com/fchollet/keras.git

Once everything has been installed,go to next Step. If not search for your specific error on Google, you will find numerous discussions and answers on StackOverflow. Otherwise ping me.

Step 6: Testing

Now to test whether scikit-learn, Theano , Tensorflow and Keras are working properly; open up a terminal just like the previous step but with python

Fig 7. Opening a python shell in a given environment

Once the terminal opens up, it should appear like this.

Fig 8. Python Shell showing the installed version 3.5.3

Now type the following commands to test their working

import tensorflow as tf import theano import keras

If there are no errors, then Congratulations you have successfully setup your Environment for machine learning and deep learning.

If some errors pops up, copy the error content as search for solution on Google and stack overflow. This will only help you later in fixing other such minor issue.

Otherwise ping me :D

Originally published at mandroid6.github.io on May 12, 2017.

Checkout my other posts on machine learning and deep learning : https://medium.com/@razzormandar


Published by HackerNoon on 2018/03/19