# Assignment 2 - Setup Jupyter

## Assignment Objectives

* Install Jupyter on your development machine
* Learn how to run Jupyter Notebook Server locally
* Get oriented with the basic features of Jupyter Notebooks
* Import and run a notebook authored by Me
* Export and submit a notebook authored by You!

### Pre-Requisites

An environment with [python](https://www.python.org/downloads/) and [pip](https://pip.pypa.io/en/stable/installing/) installed. If you prefer a different package manager for installing python modules that's fine too but instructions for this course will use pip. \
\
Basic command line literacy is assumed. If any commands or questions seem unclear please reach out to <wmcnichols@ccny.cuny.edu>.

## Install Jupyter

Run the following command from your terminal

```
$ pip install jupyterlab
```

Then create a directory for this course on your machine and navigate to it.&#x20;

For example (in unix)

```
$ mkdir ~/Developer/cs59974
$ cd ~/Developer/cs59974
```

{% hint style="info" %}
&#x20;You may not have a \~/Developer directory on your machine. Feel free to put your directory wherever you like.
{% endhint %}

Start a Jupyter notebook in the directory you just created by running the following command:

```
$ jupyter notebook
```

This command will automatically open a browser to **localhost:8888/tree**. When this command is run the server is ran locally and is reachable on a browser by the web address above. Jupyter is a deployable web service which makes it very portable for use with various cloud services.&#x20;

{% hint style="info" %}
Note once you run `jupyter notebook` command your current terminal window will now become an occupied by a live console for jupyter. If you want to run further commands you will need to do so in another window. \
\
If you need to shut down your notebook you can do so by killing the process on the terminal window with **ctrl + C**&#x20;
{% endhint %}

Portability is a big advantage because machine learning (and scientific computing in general) requires very heavy computational resources. For example, if you were to want to run your same code that you develop on your laptop on a machine with a very sophisticated/expensive GPU you could do so relatively easily.

If everything went as planned you should see an empty Jupyter Notebook as such:

![Example of an empty Jupyter Notebook](https://2641939408-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1M8HQIBfPa6b8wzjmH%2F-M1M99-Qhbc_eBJ5cN7F%2F-M1MhuInB3WxQKn8JdU_%2FScreen%20Shot%202020-03-01%20at%203.08.27%20PM.png?alt=media\&token=f36361f1-b32a-4f05-ad78-818f40f5e306)

## Get comfortable

After you've got your server up and running it's time to start playing around! Follow the instructions on the following page to create your first notebook and learn some of the basics of the interface. This is the "Hello World" guide for Jupyter.

{% embed url="<https://realpython.com/jupyter-notebook-introduction/#creating-a-notebook>" %}

After completing the above tutorial you should have learned:

* How to create a new notebook
* How to insert/run code in a Jupyter notebook
* How to insert and render markdown in a Jupyter notebook

## Import and Run A Notebook

Behind the scenes notebooks authored in Jupyter are generated into a `.ipynb` file. These files can be extracted and shared with others who can then run these notebooks on their own Jupyter Server.\
\
There are many repositories of notebooks that you can experiment and play around with on your own. Here is a list of examples highlighted by the Jupyter organization.

{% embed url="<https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks>" %}

Explore the above repository and find a notebook that interests you and read and play around with it. Once you've found one you like download the `.ipynb` file and corresponding dataset for the notebook and run it locally on your Jupyter Server. You will use

## Build Your First Notebook

Now that you've gotten an idea of how Jupyter notebooks work it's time for you to make your own. You can either use the notebook that you made in the **Get Comfortable** section or make a fresh new one.\
\
From here, the sky is the limit! Make a brief notebook that shows off some cool python code.\
\
For some inspiration you could try using some of the libraries that you found in **Import and Run A Notebook** to create your own unique program. Or you could take some python code that you wrote in previous courses and present it here.\
\
The only requirements for this assignment are that you have a notebook that includes some python code that you wrote and some markdown that explains what it does. *The best notebooks will have an opportunity to present next class.*&#x20;

**Inclusion of at least one meme in your notebook will give you one arbitrary brownie point.**

## Submission instructions

Once you've finished making a notebook it's time to submit. For now, please place your `.ipynb` file and any dependencies (datasets, etc) into a zip file and email it to me at <wmcnichols@ccny.cuny.edu>.\
\
**Note: I'm exploring other submission options for Notebooks. Future assignments will have different instructions for how to submit for a grade.**
