Using Jupyter Notebooks on Crane

HCC Fall Kickstart 2018 - October 16, 2018

Carrie Brown

What is Jupyter Notebook?

Jupyter Notebook is a web-based application used to create documents that contain code, visualizations and narrative text. Can we used interactively, or to create static reports.

These slides were created using a Jupyter Notebook

You can find this notebook in job-examples/jupyter/jupyter_overview.ipynb.

Layout of a Notebook

Notebooks are built of cells which can be executed individually. Cells can either contain code or text.

Text cells are rendered using Markdown, a lightweight markup language that can be used to create basic formatting or even including more complicated elements such as LaTeX. Similar in concept but simplier than HTML.

With markdown, we can insert:

Headlines:

Headline 1

Headline 2

Headine 3

Headline 4

Headline 5

Bulletted nested lists:

  • item 1
    • subitem A
      • subsubitem a
    • subitem B
  • item 2
  • item 3

Numbered nested lists:

  1. item 1
    1. subitem A
      1. subsubitem a
    2. subitem B
  2. item 2
  3. item 3

Links:

Holland Computing Center

Tables:

col1 col2 col3
row1 data11 data12 data13
row2 data21 data22 data23
row3 data31 data32 data33

Even LaTeX equations

Both inline: $e^{i\pi} + 1 = 0$ and displayed:

$$e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i$$

Kernels at HCC

The ‘kernel’ is a program that runs and introspects the user’s code. We have several popular kernels available for Jupyter Notebooks at HCC.

  • Python 2 and 3
  • R
  • MATLAB
  • SAS
  • Julia
  • TensorFlow (Python 2 and 3)

If you need an additional kernel, let us know by completing a software installation request: https://hcc.unl.edu/software-installation-request

Using libraries and packages in Jupyter Notebook

HCC has many of the commonly used packages and libraries already installed such as SciPy and the core tidyverse packages in R.

If you need custom environments, you can build them yourself using Anaconda. For information on how to use Anaconda with Jupyter Notebooks, check out our documentation at https://hcc-docs.unl.edu/display/HCCDOC/Using+Anaconda+Package+Manager

Accessing JupyterHub on Crane

Login using your HCC credentials at http://crane.unl.edu

Select one of the Notebook options from the dropdown menu and click

Once your server starts up, open a new notebook by clicking the New button in the top right corner.

Example Notebook

Iris Data Set in R

Load the data

We can load the built-in iris dataset in R by using the data() function.

In [2]:
data(iris)
head(iris)
Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpecies
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa

Create a plot

We can use popular libraries right in JupyterHub, such as ggplot2.

In [3]:
library(ggplot2)

ggplot(iris, aes(x=Petal.Length, y=Petal.Width, color=Species)) + geom_point()