How to Setup your Python-Anaconda Environment for Machine Learning and Data Science Projects

Abenezer Girma
6 min readJul 23, 2020

This article is an easy and practical tutorial on how you can install a customized machine learning or data science anaconda environment on your machine. Currently, anaconda is one of the best open-source resources for simplifying machine learning package management and deployment.

The difference between anaconda nad mini-conda is, anaconda comes with many libraries and packages. Miniconda on the other hand comes with very few basic libraries, so it is good to set up a very customized environment. Additionally, if you want/have to save space on your computer mincoda is the best way to go.

In this tutorial, I will discuss step by step procedures on how to set up both Anaconda and miniconda for machine learning projects.

Content

Anaconda Installation

Miniconda installation

Visual Studio installation

CUDA Installation for accusing GPU

Creating the machine learning anaconda environment

Launching Jupyer and spyder

Anaconda installation

  1. Go to this Anacoda website and click download and choose the 64 or 32 graphic installer and click download it. As Pyhton 3 is the latest version, I suggest python 3 over Python 2.

2. Locate your download and open it then click on next.

3. In the following windows follow the following steps

-> I agree ->”just me” Next -> “destination folder” Next ->

4. When you get here, I suggest to select the second option as shown in the below picture, then click install.

5. When the installation is completed, it shows the following window with “completed”.

Mini Conda Installation

  1. Install miniconda from the following website (I installed windows installer python 3.7)

https://docs.conda.io/en/latest/miniconda.html

  • Open the downloaded installer file, which is shown below. Click next and start the installation by keeping all the default selected options.
  • As Miniconda is a lightweight version of anaconda (10x less, 2.15Gb Vs 200MB) it’s up to the user to customize it to own needs. So, we will customize the installed miniconda to make it ideal for machine learning.
  • To check that you successfully installed it, go to start bar and search for miniconda, then open it and write “conda” and hit enter. You will see condo optional arguments as shown below.

Install Visual studio

You need Visual Studio Tools to have an integrated development environment (IDE) that you can use to build, test, and deploy deep learning solutions.

  1. Download and install Visual Studio. Select the community version (free version). As we are interested to use in python environment, selection python development would be enough.

Installing CUDA Toolkit & cuDNN

  1. Make sure you have a driver that supports your GPU. The usual advice is to install the most recent driver for your GPU. That driver will support CUDA 8.x, CUDA 9.x, and/or CUDA 10.x, with no changes. Here is NVIDIA drivers download. Fill out the options based on your GPU specification to get the right driver.

2. Once you update your driver, install the latest CUDA toolkit. Choose the options based on your computer specification and install the toolkit.

3. When it finishes restart your computer.

Creating the machine learning anaconda environment

Lets first create an environment with a name “ML_env”. Open ‘miniconda’ or ‘anaconda’ prompt window from the start bar and run the following command.

conda create -n ML_env python=3.6
  • Activate the environment you just created by running the following command.
conda activate ML_env

Please don’t forget to always activate your environment before you install anything or start to work on your project.

This happened to me sometimes, especially when I am in hurry, I open anaconda/miniconda and without activating my environment I would start to work directly on the root, which sometimes costs me by messing other environments that I created for other projects.

Now we are in the environment, so let's start installing important machine learning libraries and frameworks. Working in enviornment is advisable for so many reasons, such as to structure your work, to easily share it, to easily replicate it.

  • Install Notebook using the following command

conda install -c anaconda notebook

Bellow are libraries with a small description followed by command to install them.

  • Numpy: is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices
conda install -c anaconda numpy
  • Matplotlib: a comprehensive library for creating static, animated, and interactive visualizations
conda install -c conda-forge matplotlib
  • Seaborn: data visualization library based on matplotlib
conda install -c anaconda seaborn
  • Pandas: fast, powerful, flexible and easy to use open-source data analysis and manipulation tool.
  • conda install -c anaconda pandas
  • OpenCv: library of programming functions mainly aimed at real-time computer vision
conda install -c conda-forge opencv
  • Scikit-learn: contains many important and widely used machine learning libraries for the Python programming language.
conda install -c anaconda scikit-learn
  • scipy : a free and open-source Python library used for scientific computing and technical computing.
conda install -c anaconda scipy
  • pytho : the package is an interface to HDF5 binary data format. It lets you store huge amounts of numerical data, and easily manipulate that data from NumPy.
conda install -c anaconda scipy
  • Tensorflow : is a free and open-source framework from google especially important for deep learning modeling.
conda install tensorflow-gpu
  • Keras: open-source neural-network library written in Python.
conda install -c anaconda keras-gpu

Now we are at the stage where we need to set up the conda environment to run into the jupyter notebook, to do so please install ipykernel as follows:

conda install -c anaconda ipykernel

To bring the newly created environment into Jupiter and to start working on it, run the following command:

python -m ipykernel install --user --name=ML_env

Using the above command, you will now have the new conda environment in your Jupyter notebook.

Launching Jupyer and spyder

To launch Jupiter open the anaconda prompt and activate the environment then run the following command:

Jupiter notebook

If you want to launch spyder editor, after you activate the conda environment type spyder in anaconda prompt and hit enter

spyder

One more tip:- tO make jupyter dark theme

  • Install the Jupyter notebook theme here and run the following.
  • jt -t monokai -f fira -fs 13 -nf ptsans -nfs 11 -N -kl -cursw 5 -cursc r -cellw 95% -T

Second tip: please follow for more machine learning and data science articles and don't hesitate to ask questions. You can ask me down in the comment section or DM me.

#technology #innovation #AI #artificialintelligence #future #datascience #data #statistics #datascientist #dataanalyst #businessintelligence #BusinessAnalyst #analytics #supplychain #engineer #machinelearning #computervision #deeplearning #artificialintelligence #deepneuralnetworks #deeplearning #data #convolutionalneuralnetwork #cnn

--

--

Abenezer Girma
Abenezer Girma

Written by Abenezer Girma

I’m a PhD student working as a researcher assistant in Autonomous Control Information & Technology Institute working on machine learning algorithms & robotics.

No responses yet