forked from rh-aiservices-bu/insurance-claim-processing
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added jupyter notebook guide and rearrange order (#42)
- Loading branch information
Showing
14 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
content/modules/ROOT/pages/02-04-first-jupyter-notebook.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
= Running code in a notebook | ||
include::_attributes.adoc[] | ||
|
||
NOTE: If you're already at ease with Jupyter Notebooks, you can skip to the next section. | ||
|
||
A notebook is an environment where you have _cells_ that can display formatted text or code. | ||
|
||
This is an empty cell: | ||
|
||
[.bordershadow] | ||
image::02/02-05-cell.png[Jupyter Cell] | ||
|
||
This is a cell with some code: | ||
|
||
[.bordershadow] | ||
image::02/02-05-cell_code.png[Jupyter Cell Code] | ||
|
||
Code cells contain Python code that you can run interactively. You can modify the code and then run it. The code does not run on your computer or in the browser, but directly in the environment that you are connected to, *{rhoai}* in our case. | ||
|
||
You can run a code cell from the notebook interface or from the keyboard: | ||
|
||
* *From the user interface:* Select the cell (by clicking inside the cell or to the left side of the cell) and then click *Run* from the toolbar. | ||
+ | ||
[.bordershadow] | ||
image::02/02-05-run_button.png[Jupyter Run] | ||
* *From the keyboard:* Press `CTRL`+`ENTER` to run a cell or press `SHIFT`+`ENTER` to run the cell and automatically select the next one. | ||
After you run a cell, you can see the result of its code as well as information about when the cell was run, as shown in this example: | ||
|
||
[.bordershadow] | ||
image::02/02-05-cell_run.png[Jupyter run cell] | ||
|
||
When you save a notebook, the code and the results are saved. You can reopen the notebook to look at the results without having to run the program again, while still having access to the code. | ||
|
||
Notebooks are so named because they are like a physical _notebook_: you can take notes about your experiments (which you will do), along with the code itself, including any parameters that you set. You can see the output of the experiment inline (this is the result from a cell after it's run), along with all the notes that you want to take (to do that, from the menu switch the cell type from `Code` to `Markup`). | ||
|
||
== Try It | ||
|
||
Now that you know the basics, give it a try! | ||
|
||
=== Procedure | ||
|
||
In your workbench: | ||
|
||
. In the left hand navigation menu, navigate to the folder called: `parasol-insurance/lab-materials/02` | ||
|
||
. Open the notebook called `02-04-first-jupyter-notebook.ipynb` | ||
|
||
. Experiment by, for example, running the existing cells, adding more cells and creating functions. | ||
+ | ||
You can do what you want - it's your environment and there is no risk of breaking anything or impacting other users. This environment isolation is also a great advantage brought by {rhoai}. | ||
. Optionally, create a new notebook in which the code cells are run by using a Python 3 kernel: | ||
.. Create a new notebook by either selecting *File ->New ->Notebook* or by clicking the Python 3 tile in the Notebook section of the launcher window: | ||
+ | ||
[.bordershadow] | ||
image::02/02-05-new_notebook.png[alt text] | ||
|
||
You can use different kernels, with different languages or versions, to run in your notebook. | ||
|
||
.Additional resource | ||
|
||
* If you want to learn more about notebooks, go to https://jupyter.org/[the Jupyter site,window=_blank]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "991808d0-7d79-47f2-b8cc-764fe86a6156", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"# Your First Jupyter Notebook\n", | ||
"\n", | ||
"NOTE: **If you are already familiar with Jupyter Notebook**, and you understand how to edit and run cells, and how to use other Jupyter features, you can skip this notebook and continue to the next one.\n", | ||
"\n", | ||
"## What are Jupyter notebooks?\n", | ||
"\n", | ||
"This is a [Jupyter](https://jupyter.org/) notebook. You need to know only a few things to get started.\n", | ||
"\n", | ||
"* Jupyter notebooks are made up of _cells_ that can contain prose, executable code, or interactive UI elements. This cell is a prose cell.\n", | ||
"\n", | ||
"* You can edit and execute cells. To edit a cell, double-click until the frame around it is highlighted. To execute a cell (whether you've edited it or not), click the play button at the top of the file window or select the cell and then press SHIFT+ENTER.\n", | ||
"\n", | ||
" <figure>\n", | ||
" <img src=\"../../content/modules/ROOT/assets/images/02/02-04-play-button.png\" alt='missing' width=\"300\" >\n", | ||
" <figure/>\n", | ||
" \n", | ||
" Jupyter executes the code in the cell, records the code output, and advances to the next cell. \n", | ||
"\n", | ||
"* While a cell is executing, an asterisk shows in the margin, for example: `In: [*]`. After a cell completes executing, the asterisk is replaced with a sequence number.\n", | ||
"\n", | ||
"\n", | ||
"Let's try it out now! Try executing the next cell" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3b4dc1f1-8d6e-4869-ade8-cafc22baa817", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def print_some_text(entered_text):\n", | ||
" print(\"This is what you entered: \\n\" + entered_text)\n", | ||
" \n", | ||
"my_text = \"This cell is for code. You can execute code by clicking on the play button above or hitting SHIFT+ENTER.\"\n", | ||
"\n", | ||
"print_some_text(my_text)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "70c9ed5e-60e1-42dd-b9c3-87fcfc79493e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"new_text = \"Next, let's see how you would write narrative text or documentation.\"\n", | ||
"\n", | ||
"# previously defined functions from another cell are still accessible.\n", | ||
"print_some_text(new_text)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "92bc6513-dbe5-4128-9399-d4d3ab9be845", | ||
"metadata": {}, | ||
"source": [ | ||
"## This is a markdown cell\n", | ||
"### Chapter 1\n", | ||
"You can use **markdown formatting** to enter your text.\n", | ||
"\n", | ||
"*Double-click* on a cell to modify it.\n", | ||
"\n", | ||
"[Markdown reference](https://www.markdownguide.org/basic-syntax/)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "edaf739c-ff87-457b-914e-5d74428fa8ed", | ||
"metadata": {}, | ||
"source": [ | ||
"## More Information\n", | ||
"\n", | ||
"For more information about Jupyter, click the **Help menu** in the Jupyter window's menu bar.\n", | ||
"\n", | ||
"<figure>\n", | ||
" <img src=\"../../content/modules/ROOT/assets/images/02/02-04-help-menu.png\" alt='missing' width=\"300\" >\n", | ||
"<figure/>" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.9", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.16" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
File renamed without changes.