4 min to read
Basic Tutorials Part 4
Basic Tutorials Part 4
Welcome to this tutorial, Part 4 of the series on using Jupyter notebooks.
As a seasoned practitioner, you might want to demonstrate your code. Your insights and the techniques used.
The notebook is a web application that allows you to combine explanatory text, math equations, code, and visualizations all in one easily sharable document.
Notebooks have quickly become an essential tool when working with data. You’ll find them being used for data cleaning and exploration, visualization, machine learning, and analysis.
These support one of my favourite philosophies of Literate programming. To qoute Donald Knuth
Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
Jupyter notebooks grew out of the IPython project started by Fernando Perez.
IPython is an interactive shell, similar to the normal Python shell but with great features like syntax highlighting and one of my favourite-code completion (For the note, I’m not lazy, I’m a relaxed typer)
The central point is the notebook server. You connect to the server through your browser and the notebook works as a web app. The code is sent through the server to the kernel. The kernel runs the code and sends it back to the server, then any output is rendered back in the browser.
The notebooks are saved as .ipynb files, in a JSON format.
Jupyter isn’t Python exclusive! The new name Jupyter comes from the combination of Julia, Python, and R. The basic working is the same for any given language. Just the kernel running everything in the background changes.
Note: Since the Notebooks do not have to be on the same machine, we will use to render notebooks on our machine while using a cloud vendor’s offering.
conda install jupyter notebook
Launching a jupyter server:
When in the environment
You’ll see a little box outlined in green. This is called a cell. Cells are where you write and run your code.
Juputer also supports Markdown. In the toolbar, click “Code” to change it to Markdown and back. The little play button runs the cell, and the up and down arrows move cells up and down. Notice, the colour is now Blue.
Now there is a lot of things in the toolbar, feel free to play around a bit and familiarize yourself. Here are a few:
To activate a cell, press enter when it is highlighted.
Now, in my defence I’m not lazy, the touchpad is just too far down on Macbook. So here are a few commands that I think are common:
These will often become intuitive and you will find the faster rather than searching for these commands via the GUI
- Tab completion: Hit TAB key after typing half of a command to complete it automatically or see the options that can be used to complete it.
- Shift Plus enter Executes/Renders a cell.
- Shift + Tab : Hit Shift + Tab to find the mini docstring of a function
- When in an active cell, press escape to enter command mode
- Esc + M will change the cell to a Markdown cell
- Esc + A will add a cell above the current cell
- Esc + B will add a cell below the current cell
- Esc + 0 0 (0 twice) will restart your kernel.
These are few of the shorcuts that are worthy of a quick mention. There many more mentioned in our Git Repo
To get a list of all commands,
- Esc + H
Markdown is the widely used format to create web documents. This post is written in Markdown. So it’s worth to mention a few of the Syntaxes that are common.
You may want to leverage this when you create a notebook for showcasing your models/results.
# Heading ## Sub-heading ### Sub Sub heading
Sub Sub Heading
- Sharing links
**A Bold line**
A Bold line
*An italic line*
An italic line
_Underline this line_
Underline this line
This is a basic overview of the funtionalities offered by Jupyter notebooks, this is by no means an exhaustive list.
We encourage you to play around, get familiar with the interface and leave us a comment below if you want to discuss anything!
Subscribe to my weekly-ish [Newsletter](https://tinyletter.com/sanyambhutani/) for a set of curated Deep Learning reads