Skip to content
Snippets Groups Projects
Commit 87b53a6e authored by Tim Redick's avatar Tim Redick :robot:
Browse files

Add intro to JupyterLab

parent f87f993a
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
![IRT Logo](https://www.irt.rwth-aachen.de/global/show_picture.asp?id=aaaaaaaaaanuwoa)
# FML (Fundamentals of Machine Learning Course) Profile Quickstart
Welcome to the FML profile on JupyterLab!
This notebook should introduce you to the basic functionalities of the JupyterLab.
* Execute a single cell: <span class="fa-play fa"></span>
* Execute all cells: Menu: Run <span class="fa-chevron-right fa"></span> Run All Cells
* To reboot kernel: <span class="fa-refresh fa"></span>
Find more in the reference (menu: Help <span class="fa-chevron-right fa"></span> Jupyter Reference).
%% Cell type:markdown id: tags:
## Creating a new cell
You can choose the type of a new cell between _Code_ or _Markdown_. _Code_ is for Python code, and _Markdown_ is a text cell.
For example, you are currently reading the content of a Markdown cell!
### Markdown cells
Running a markdown cell parses the text and displays it in a more readable mode.
You can also edit the content of a Markdown cell by double clicking on it.
Markdown supports lists, images, LaTeX equations, and much more.
#### Lists
* Like
* this
1. We can even nest them like
2. this!
* Isn't that wonderfull?
#### Images
![Newtons cradle](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Newtons_cradle_animation_book_2.gif/200px-Newtons_cradle_animation_book_2.gif)
#### LaTeX equations
$$\mathrm{e}^{\mathrm{j} x} = \cos(x)+\mathrm{j}\sin(x)$$
### Further reading
Read more in the reference (menu: Help <span class="fa-chevron-right fa"></span> Markdown Reference).
%% Cell type:markdown id: tags:
### Python cells
You can enter code in these cells, and running the cell runs the corresponding code.
%% Cell type:code id: tags:
``` python
print("Hello world!")
```
%% Cell type:markdown id: tags:
#### Example
Execute the cell below to see the contents of variable `a`
%% Cell type:code id: tags:
``` python
import numpy as np
a = np.array([0, 1, -5])
print(a)
```
%% Cell type:markdown id: tags:
## Plots with matplotlib
Here is a nice matplotlib [tutorial](https://matplotlib.org/tutorials/introductory/usage.html#sphx-glr-tutorials-introductory-usage-py).
%% Cell type:code id: tags:
``` python
import matplotlib.pyplot as plt
fs = 44100;
(t, deltat) = np.linspace(-1, 1, 20*fs, retstep=True) # t axis in seconds
fig,ax = plt.subplots(); ax.grid();
ax.plot(t, np.sin(2*np.pi*t))
ax.set_xlabel(r'$t$'); ax.set_ylabel(r'$s(t) = \sin(2 \pi t)$');
```
%% Output
%% Cell type:markdown id: tags:
Copyright (c) 2024, Institute of Automatic Control - RWTH Aachen University
All rights reserved.
%% Cell type:markdown id: tags:
![IRT Logo](https://www.irt.rwth-aachen.de/global/show_picture.asp?id=aaaaaaaaaanuwoa)
# JupyterLab Quickstart
This notebook should introduce you to the basic functionalities of JupyterLab.
* Execute a single cell: ▶️
* Execute all cells: Menu: Run → Run All Cells (or ⏩ which includes restart of kernel)
* To reboot kernel: 🔄
Find more in the reference (menu: Help → JupyterLab Reference).
%% Cell type:markdown id: tags:
## Creating a new cell
You can choose the type of a new cell between _Code_ or _Markdown_. _Code_ is for Python code, and _Markdown_ is a text cell.
For example, you are currently reading the content of a Markdown cell!
### Markdown cells
Running a markdown cell parses the text and displays it in a more readable mode.
You can also edit the content of a Markdown cell by double clicking on it.
Markdown supports lists, images, LaTeX equations, and much more.
#### Lists
* Like
* this
1. We can even nest them like
2. this!
* Isn't that wonderfull?
#### Images
![Newtons cradle](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Newtons_cradle_animation_book_2.gif/200px-Newtons_cradle_animation_book_2.gif)
#### LaTeX equations
$$\mathrm{e}^{\mathrm{j} x} = \cos(x)+\mathrm{j}\sin(x)$$
### Further reading
Read more in the reference (menu: Help <span class="fa-chevron-right fa"></span> Markdown Reference).
%% Cell type:markdown id: tags:
### Python cells
You can enter code in these cells, and running the cell runs the corresponding code.
%% Cell type:code id: tags:
``` python
print("Hello world!")
```
%% Output
Hello world!
%% Cell type:markdown id: tags:
#### Example
Execute the cell below to see the contents of variable `a`
%% Cell type:code id: tags:
``` python
import numpy as np
a = np.array([0, 1, -5])
print(a)
```
%% Output
[ 0 1 -5]
%% Cell type:markdown id: tags:
Copyright (c) 2024, Institute of Automatic Control - RWTH Aachen University
All rights reserved.
%% Cell type:markdown id: tags:
# Tasks
The goal of the following tasks is to make you familiar with the JupyterLab user interface.
## Task 1 - Getting to know JupyterLab and Notebooks
* Restart the kernel and run the whole notebook.
* Add a new Code Cell below with the following lines:
```python
b = 1.5 * a
b
```
* The notebook will always output the return value of the last line - collapse / hide the output.
* Markdown cells are a good way to document your thoughts - add a markdown cell above the last cell and describe the calculation.
* Open the *JupyterLab reference* and find the *The JupyterLab Interface* section.
## Task 2 - Working with cells
* Notebooks are **stateful** - this means that it saves the value of variables in a global scope until the kernel is restarted. Thus, the order of execution matters.
* Have a look at the *Notebooks* section in the *JupyterLab reference*.
* Drag & drop the cell containingcalculation of `b` to the top of the notebook and run the whole notebook without restarting the kernel.
* Now restart the kernel and run the whole notebook.
* What happened? Fix the error by moving the calculation of `b` to an appropriate place.
%% Cell type:markdown id: tags:
![IRT Logo](https://www.irt.rwth-aachen.de/global/show_picture.asp?id=aaaaaaaaaanuwoa)
# Python Setup
Jupyter notebook providers like the RWTH, Google with Colab, or Kaggel notebooks typically serve environments which contain everything you need:
* A python installation
* Common packages like numpy, matplotlib, or PyTorch preinstalled
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment