Setup Guide
Intro to Python for Machine Learning & AI
Introduction
Before you can do machine learning from your own computer, we need to make sure your computer's environment is ready.
In terms of computers, an environment is just the state of the computer based on the software, hardware and settings that it has.
This means that your computer's hardware, software and settings must be compatible and configured correctly.
This lesson will contain instructions for setting up Python for Windows and Mac.
We have designed this course to be compatible with Chrome and Firefox web browsers. If you are using a different web browser, we recommend you download and open the site in Chrome or Firefox before continuing.
You can Download Chrome Here or Download Firefox Here.
Hardware Requirements
- Windows OS version - Windows 7 or later
- RAM - 4 GB minimum, 16 GB or higher is recommended for advanced work in machine learning, but not necessary for this course's material.
- OS Version - MacOS 10.9 or later (earlier versions may still work, but the provided installation instructions here may not work)
- RAM - 4 GB minimum, 16 GB or higher is recommended for advanced work in machine learning, but not necessary for this course's material.
Machine learning and deep learning can be intensive on a computer. In this course, you will be performing basic machine learning calculations, so while these minimum settings may work with the projects for this course, you may need a more powerful computer if you want to continue creating more advanced machine learning programs after the course.
Make sure that your computer meets these minimum requirements.
Windows
Mac
Software
- Python Distribution - The python install comes with many of the essential tools we need such as IDLE, Pip and the Python language itself. You can download python distributions with different versions of python, so pay attention to the distribution version when you download python. If you download the wrong version of a distribution, some code may not work.
- IDLE - IDLE (Integrated DeveLopment Environment) is a GUI application where you can write python programs. This is the application that you will use to write python programs for this course.
- Pip - Pip (Pip Installs Packages) is a program that will install python packages that aren't included with the python distribution that you downloaded. You will use Pip to install machine learning packages that aren't included in the python distribution you will download.
- Packages - Programs with additional libraries, such as code that performs machine learning. You will be shown how to install all the packages you will need for this course.
There are many different software, tools and packages that are used for machine learning with python.
We will be using a few of the most common ones:
Installing Python
Before you can start writing machine learning programs, you will need to install Python on your machine.
Start by downloading Python here. Choose a release version.
This will take you to the downloads page. You will see the downloads in the Files section at the bottom of the page. Choose the installer for your operating system.
For Windows users, If you don't know if your system is 32-bit or 64-bit, the Microsoft FAQs Page provides instructions on how to look up this information on your computer.
Windows 64-bit: Windows x86-64 executable installer
Windows 32-bit: Windows x86 executable installer
macOS: macOS 64-bit installer
Open the installer and follow the installation instructions. If you are installing with windows, make sure to check the options on the guide below. If you don't follow these instructions, you may need to reinstall python to ensure you can follow the instructions in all of the lessons.
Select the box for Add Python X.X to PATH which tells the computer where to find Python when we search in the command line.
Click Install Now. This is the default installation option that includes Python, IDLE (Integrated Development Environment), pip and the official documentation.
Do not use 'customize installation' unless you have advanced knowledge.
Click Install Now. This is the default installation option that includes Python, IDLE (Integrated Development Environment), pip and the official documentation.
Do not use 'customize installation' unless you have advanced knowledge.
Once the install has finished, click close to close the installer.
Below is a video showing the process to download and install IDLE for Macs.
Command Line - Windows
To check that Python has installed correctly and for things we will do later, we need the command line.
The command line is a text interface for your computer that takes in commands for the operating system to run.
It is also referred to as the terminal, prompt, shell, console and more.
If you are using a Mac, skip ahead to the next section, which explains using the command line on Macs, called the Terminal.
Opening the command line - You can open this by clicking Start and in the Search or Run line, type cmd (short for command), and press Enter.
Read more about How to use the Windows command line.
We will be using the command line just for installations, but you can use the links to learn other ways to use the command line if you're interested.
Once you have your command line open, type python and hit Enter.
You should then see information about your Python version, meaning that it has installed correctly and you are ready to code.
You can also now use your command line as an interpreter meaning you can type code and it will be executed. E.g. type 2 + 3 and hit Enter.
The code will execute and you will see the result in the terminal. You can then type exit() or quit() and hit Enter to exit Python.
Remember that if you see three greater than signs (>>>), you are running Python in the command line and only Python code will work. If you do not see >>> then you are just in the regular command line and Python code will not work.
We won't be using the command line to write code (we will use IDLE for that). However, we do need to use the command line to install additional packages.
Command Line - Mac (Terminal)
To check that Python has installed correctly and for things we will do later, we need the terminal.
The terminal is a text interface for your computer that takes in commands for the operating system to run.
You can open this by going to your Applications folder, then the Utilities folder and clicking on Terminal. Alternatively you can just type Terminal in the Spotlight search.
Read more about How to use the Mac command line.
Below is a video showing the process to open the terminal on Mac.
We will be using the command line just for installations, but you can use the links to learn other ways to use the command line if you're interested.
Once you have the your command line open, type python3 and hit Enter.
You should then see information about your Python version, meaning that it has installed correctly and you are ready to code.
You can also now use your command line as an interpreter meaning you can type code and it will be executed. E.g. type 2 + 3 and hit Enter.
The code will execute and you will see the result in the terminal. You can then type exit() or quit() and hit Enter to exit Python.
Remember that if you see three greater than signs (>>>), you are running Python in the command line and only Python code will work. If you do not see >>> then you are just in the regular command line and Python code will not work.
When you are in the Python interpreter, there will be no differences between Mac and Windows.
We won't be using the command line to write code (we will use IDLE for that). However, we do need to use the command line to install additional packages.
Pip Installing
- Numpy - To install type:
pip install numpy
- Pandas - To install type:
pip install pandas
- Matplotlib - To install type:
pip install matplotlib
- Scikit-learn - To install type:
pip install -U scikit-learn
Note: This command also has -U in the command. This is short forupgrade
, and ensures that packages related to scikit-learn are upgraded to the correct versions that scikit-learn uses.
One of the simplest ways to install libraries for Python is through Pip.
Pip is a package manager for Python packages/modules. Modules are Python code libraries you can include in your project. A package contains all the files you need for a module.
Pip comes by default with Python so you should already have it installed.
Windows: You can check this by typing pip -V or pip --version in the command line to show the pip version.
Mac: You can check this by typing pip3 -V or pip3 --version in the command line to show the pip version. In the future, when you see a reference to
pip, make sure that you use the command
pip3instead. If you do not, you will see the error message
--bash: pip: command not found
To install a Python package, just type pip install <package> in the command line where <package> is the name of the package you want to install.
Here are the packages you must install for this course.
If you see a WARNING message with the text
WARNING: You are using pip version...you do not need to do anything different, just keep installing packages using the commands above.
After this you should have these packages with all the necessary files installed.
You can check what you have installed by typing pip list.
There are many other useful commands and you can see them all by typing pip.
You are now setup and ready to use Python, as well as the extra 4 packages, for starting data science and machine learning.