This is a guest post by Francine Tan, Microsoft Student Partner at Imperial College London
Hi I'm Francine, a Penultimate year Electrical and Electronic Engineering student and Microsoft Student Partner at Imperial College London check out my linkedin profile at https://www.linkedin.com/in/francine-tran-b4b532102/
Introduction
Microsoft Azure Notebooks is a free service that provides Jupyter Notebooks along with supporting packages for R, Python and F#. The great thing about this service is that no downloads or lengthy setups are required. After signing up with a Microsoft ID, you can start working on a notebook within minutes.
What are the Jupyter notebooks?
Jupyter notebooks provide a seamless way to combine rich output, code and graphics . It allows you to embed YouTube videos, charts and more into one interactive environment. Meaning that your flow of thought is not interrupted; you can keep working and stay focussed. It’s perfect for avoiding those clunky workspaces that all student programmers know too well.
At its core, Jupyter Notebooks are simply JSON documents where each segment of the document is stored in a ‘cell’. At its highest level, it can be thought of as a dictionary with a few keys. You can think of it as a mixture of an editor and a command window that can also present your project in its entirety.
Signing up to and using the service
Sign up for a free account at https://notebooks.azure.com/
Once logged in, select Libraries from the upper toolbar, then you are directed to a page where you can create new libraries and view your existing ones. Libraries are a way of grouping and categorising your notebooks and they can be set to as Private or Public . The libraries can be shared with others, and you can also share individual notebooks. This means that it’s great for group projects which often involve sharing and co-authoring of code.
Once you are inside a library and have started up a notebook, it will be displayed under the Running tab. Note that simply exiting a notebook does not terminate a kernel. In order to exit a kernel, click Shutdown on the notebook you want to close.
Terminating a kernel
Getting started
There are a few features that you need to know to get started with the Jupyter notebooks.
The Cells
Each notebook consists of sections that are called cells.
An example of some cells
A cell can be thought of as a multiline text input field that can perform a number of operations. Cell types are not fixed and you can easily switch between the different types using the drop down menu whilst a cell is selected.
There are a number of handy shortcuts:
Command |
Action |
Shift+Enter |
Run the current cell |
Alt+Enter |
Run the current cell and insert a new one below |
Ctrl+Enter |
Run the current cell and enter command mode |
Double Click |
Edit a cell |
Code cells are the default cell type. They can be thought of as nuggets of code that are sent to the kernel when the cell is executed. There is also full syntax highlighting and tab completion within the Jupyter notebooks. The results that are returned are displayed as the cell’s output like so:
Code Cell example
Text is but one of the outputs included in IPython’s rich display capability. Figures generated using the Matplotlib library and HTML tables are also included, to name a few.
Plotting graphs
One of the most useful features of the Jupyter notebooks is that Notebook documents contain both the inputs and outputs of an interactive session. This is useful for making programming tutorials and for use in lectures and/or seminars.
Markdown CellsMarkdown cells output body text, headings and several other text options including LaTeX . Here are a few examples of the different text options:
Inputs
Outputs
One advantage of markdown is that you can avoid large chunks of commented out code, and instead simply switch the section between markdown or code using the dropdown menu.
RawNBConverts CellsRawNBConverts are any additional media that you would want to use in your notebook. You can embed photos, videos and more. These cells help enhance your notebook and make it more interesting as you can replace copious paragraphs of text with images that embed neatly inside. No formatting or copy pasting is required.
Menubar and Toolbar
The menu bar presents different options that may be used to manipulate the way the notebook functions. You have the option to interrupt, restart or change kernels; there is also the option to upload to/download from the Dropbox service.
The tool bar gives a shortcut method of performing the most-used operations within the notebook, by simply clicking on an icon.
Menubar and Toolbar
Presenting your Notebook
One of the best features of the Jupyter notebooks is the slide mode. It allow you to create impressive group presentations with live code executions and inline formulae. To enter slide mode, click the icon.
Slide Mode
Main Features
· Comments can be clearly expressed using the markdown cells instead of being cluttered up in your code, this is great for annotating your work throughout and allows you to provide full coherent explanations alongside your code.
· There are plenty of tutorials created using the Jupyter notebook available online that allow you to develop new skills, such as Machine Learning and Data Science .
· Several packages are already installed within Microsoft Azure, this saves you the trouble of locating said packages and installing them yourself. You can also install additional packages using pip install or conda install.
· It’s great for debugging as you are more likely to know exactly where the errors in your code are if you can run it in sections. In collaborative projects you often run the risk of writing conflicting code with your team members. By using the notebook, you can pinpoint your bugs and solve them immediately rather than waiting for a risky compile.
· You can export your notebook in several formats, such as LaTeX, HTML or PDF files. From there, the notebooks can be used in online blogs and you can even embed them into live websites.
· Each notebook is associated with a kernel, you can run multiple kernels simultaneously by starting multiple notebooks. This allows you to increase your productivity as you can work on multiple projects at the same time.