Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Last active October 30, 2016 14:05
Show Gist options
  • Save jpotts18/dc8b1cf97bae528f99a0 to your computer and use it in GitHub Desktop.
Save jpotts18/dc8b1cf97bae528f99a0 to your computer and use it in GitHub Desktop.
Setup Jupyter

Python Machine Learning Setup (Python 2.7)

Install Python

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code. The language provides constructs intended to enable clear programs on both a small and large scale.

Install Python on Windows

Install Python on Mac

python --version - Show the system version

brew install python3 - If you want python3

Install Package Manager

A package is a library of code. Instead of having everyone rewrite the same code it is shared openly and can be downloaded by others easily. Python libraries are hosted on a service called they Python Package Index or PyPI

sudo easy_install pip - pip is a package management system used to install and manage software packages written in Python.

If you want to use anaconda you are on your own :)

Install Scientific Packages

  • pip install -U scipy - SciPy (pronounced “Sigh Pie”) is open-source software for mathematics, science, and engineering.
  • pip install -U numpy - NumPy is the fundamental package for scientific computing with Python.
  • pip install -U pandas - A Dataframe that is used to read, transform, and manipulate data
  • pip install -U scikit-learn - Sci-Kit Learn is a Simple and efficient tools for data mining and data analysis
  • pip install -U matplotlib - matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms
  • pip install -U jupyter - A Jupyter Notebook is web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.

Run Jupyter

  • Change into the right directory cd ~/datasci
  • jupyter notebook - This should launch your web browser.
  • Create a new Python2 Notebook (by clicking in the top right)
  • Run the following
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
  • If everything works without an issue then run this
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2  # 0 to 15 point radiuses

plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment