Skip to content

Commit

Permalink
add first tutorial and remove build
Browse files Browse the repository at this point in the history
  • Loading branch information
chillerb committed Oct 23, 2024
1 parent 2aad526 commit 8b5d664
Show file tree
Hide file tree
Showing 8 changed files with 343 additions and 68 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dsc_tutorials/_builds/

# Created by https://www.toptal.com/developers/gitignore/api/jupyternotebooks
# Edit at https://www.toptal.com/developers/gitignore?templates=jupyternotebooks

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/bckrlab/dsc-tutorials/HEAD)

# DSC Tutorials

> Machine Learning Tutorials for the Data Science Club.
Expand Down
285 changes: 274 additions & 11 deletions dsc_tutorials/01_python-intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@
"id": "e71f1f45-a62c-4e71-acdc-636706992f9e",
"metadata": {},
"source": [
"Task: Change the text of this cell!"
"> Change the text of this cell!"
]
},
{
"cell_type": "markdown",
"id": "ce251bdc-3b8a-4c10-8e9d-87f2aeaae8d5",
"metadata": {},
"source": [
"Task: Create a new cell that reads \"Hi!\", then delete this cell!"
"> Create a new cell that reads \"Hi!\", then delete this cell!"
]
},
{
"cell_type": "markdown",
"id": "139fcdec-3e99-47af-8a49-bbbb2c786e88",
"metadata": {},
"source": [
"Task: Create a new Jupyter Notebook!"
"> Create a new Jupyter Notebook!"
]
},
{
Expand All @@ -92,23 +92,30 @@
"id": "9210defe-4352-4790-89c6-db1a148c5449",
"metadata": {},
"source": [
"# Python"
"# Python\n",
"\n",
"> *\"Python is the \"most powerful language you can still read\".*\n",
">\n",
"> Paul Dubois "
]
},
{
"cell_type": "markdown",
"id": "a08d6422-e6c6-405f-ab6c-3a0483e63d1e",
"metadata": {},
"source": [
"[Python](https://en.wikipedia.org/wiki/Python_(programming_language)) is a programming language that was developed in 1991 by Guido van Rossum.\n",
"[Python](https://en.wikipedia.org/wiki/Python_(programming_language)) is a programming language that was developed in 1991 by \"Benevolent dictator for life\" Guido van Rossum.\n",
"\n",
"Python is:\n",
"\n",
"- **Interpreted**:\n",
"- **Object-Oriented**: Most things in Python are Objects.\n",
"- **Interpreted**: Programs are executed line by line by an interpreter instead of being compiled into machine code first.\n",
"- **multi-paradigm**: programmers can choose their favorite way to conceptualize and structure programs\n",
" - **Object-Oriented**: Programs are implemented via interacting objects. Most things in Python are objects, including functions.\n",
" - **Procedural**: Programs are implemented via interacting functions.\n",
" - **functional**: \n",
"- **dynamically typed**: type-safety of operations is checked at runtime. This allows programmers to write very flexible code, but eventually, the program will fail during runtime due to operations on unsupperted types.\n",
"\n",
"- **Grabage Collected**: Dead variables are automatically identified and released. Programmers don't have to worry about memory management, but running the garbage collector takes time."
"- **Grabage Collected**: Dead variables are automatically identified and released. Programmers don't have to worry about memory management, but running the garbage collector takes time.\n",
"- etc."
]
},
{
Expand Down Expand Up @@ -139,6 +146,61 @@
" Namespaces are one honking great idea – let's do more of those!"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d0f745bf-8293-48fa-a33a-b3b8a36154a6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World!\n"
]
}
],
"source": [
"print(\"Hello World!\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8da08c56-274f-49da-862e-b6cb5499e0d1",
"metadata": {},
"outputs": [],
"source": [
"# TODO: Add Python tasks"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "ac17c77c-49d1-453b-ba25-05d039e04671",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# import packages\n",
"import random\n",
"\n",
"def throw_dice():\n",
" return random.randint(1,6)\n",
"\n",
"throw_dice()"
]
},
{
"cell_type": "markdown",
"id": "ccbea933-9e85-43d7-af07-b458874fee77",
Expand All @@ -147,18 +209,219 @@
"# Package Management in Python"
]
},
{
"cell_type": "markdown",
"id": "5b9422bf-84e3-4c60-bd22-90badd0521f1",
"metadata": {},
"source": [
"While Python's standard library is already pretty powerful, there are many more great packages for data science.\n",
"Existing Data Science projects will probably depend on some of them.\n",
"Next, let's have a look how to install and manage packages in Python."
]
},
{
"cell_type": "markdown",
"id": "6e7e6447-0dd9-4b72-8920-5acfc014931d",
"metadata": {},
"source": [
"## Pip"
"## pip\n",
"\n",
"pip is Python's package-management tool for installing new packages.\n",
"Python packages are provided by an online repository called the **Python Package Index**, or short [PyPI](https://pypi.org/)."
]
},
{
"cell_type": "markdown",
"id": "254e4992-81b6-4676-9cea-65429c0094da",
"metadata": {},
"source": [
"```sh\n",
"pip install {PACKAGE NAME}\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "0d65e168-f265-46a7-8ece-ddb006a20207",
"metadata": {},
"source": [
"Often projects come with a `requirements.txt` file that specifies their requirements. It can be installed with pip:\n",
"\n",
"```sh\n",
"pip install -r requirements.txt\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "4ba3d734-4570-4883-b69c-1db012431ffd",
"metadata": {},
"source": [
"> install the package pyjokes and run the next cell"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "c539f499-e744-43b6-b6fc-eedc5c793f5b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting pyjokes\n",
" Downloading pyjokes-0.8.3-py3-none-any.whl.metadata (3.4 kB)\n",
"Downloading pyjokes-0.8.3-py3-none-any.whl (47 kB)\n",
"Installing collected packages: pyjokes\n",
"Successfully installed pyjokes-0.8.3\n"
]
}
],
"source": [
"!pip install pyjokes"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "7aa1feaa-e9db-4085-984d-93038671b76f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"There are 10 types of people: those who understand binary and those who don't.\""
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pyjokes\n",
"\n",
"pyjokes.get_joke()"
]
},
{
"cell_type": "markdown",
"id": "8d8fd3e0-74e2-43b6-974c-e3f86dc6ccc0",
"metadata": {},
"source": [
"## Virtual Environments"
]
},
{
"cell_type": "markdown",
"id": "6f921af2-652f-45a9-855c-e146cb8e48da",
"metadata": {},
"source": [
"pip is great! But things start to get messy as soon as you have multiple projects, each requiring their own dependencies.\n",
"Fortunately, there is one solution: [Virtual Environments](https://docs.python.org/3/library/venv.html)!"
]
},
{
"cell_type": "markdown",
"id": "a1082271-20c8-433b-8d7d-5aac760823d2",
"metadata": {},
"source": [
"```sh\n",
"# create a new virtual environment\n",
"python -m venv myproject\n",
"\n",
"# don't forget to activate it!\n",
"source myenv/bin/activate\n",
"\n",
"# install your packages\n",
"pip install jupyter\n",
"\n",
"# try to start a new jupyter notebook\n",
"jupyter notebook\n",
"\n",
"# deactivate the environment\n",
"deactivate\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "0b5e65d4-3995-4b8b-bc5c-f6fda9b3567e",
"metadata": {},
"source": [
"## Conda"
]
},
{
"cell_type": "markdown",
"id": "adf69db9-7594-4b10-ade4-e3d05b4257e9",
"metadata": {},
"source": [
"- https://docs.conda.io\n",
"- Miniconda: https://docs.anaconda.com/miniconda/"
]
},
{
"cell_type": "markdown",
"id": "c069f3b6-fe16-4836-abab-16337903076c",
"metadata": {},
"source": [
"```sh\n",
"conda create -n myenv\n",
"conda activate myenv\n",
"conda install python=3.12 numpy jupyter\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "720d22f6-ed29-4385-ae9f-b0afbbe15841",
"metadata": {},
"source": [
"Quick Reference:\n",
"\n",
"```sh\n",
"# create a new conda environment with a name\n",
"conda create -n myenv\n",
"# create a conda environment from a yml file\n",
"conda env create -f environment.yml\n",
"# list available conda environments\n",
"conda env list\n",
"# activate a conda environment\n",
"conda activate myenv\n",
"# install dependencies in active environment\n",
"conda install numpy \n",
"# export your environment to a yml file\n",
"conda env export -f environment.yml\n",
"conda env export > environment.yml\n",
"# deactivate an environment\n",
"conda deactivate\n",
"# remove an environment\n",
"conda remove --name myenv --all\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "91adae1a-892b-40f3-908f-0cf99801d981",
"metadata": {},
"source": [
"## Pointers"
]
},
{
"cell_type": "markdown",
"id": "5ff781fc-3d42-4415-ae02-c97576161939",
"metadata": {},
"source": [
"- https://ipython.readthedocs.io/en/stable/interactive/magics.html"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6bce9a93-e7db-4a4f-bf45-bf9b787fec2a",
"id": "9a2be204-a8d8-4b84-a454-1982b858076b",
"metadata": {},
"outputs": [],
"source": []
Expand Down
5 changes: 2 additions & 3 deletions dsc_tutorials/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
format: jb-book
root: intro
chapters:
- file: markdown
- file: notebooks
- file: markdown-notebooks
- file: 01_python-intro
- file: bookmarks
5 changes: 5 additions & 0 deletions dsc_tutorials/bookmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Bookmarks

> Good reads
WIP
12 changes: 5 additions & 7 deletions dsc_tutorials/intro.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Welcome to your Jupyter Book
# Welcome to the Data Science Club!

This is a small sample book to give you a feel for how book content is
structured.
It shows off a few of the major file types, as well as some sample content.
It does not go in-depth into any particular topic - check out [the Jupyter Book documentation](https://jupyterbook.org) for more information.
> A common misconception: you actually CAN talk about Data Science Club.
Data Science Tutorials

Check out the content pages bundled with this sample book to see more.

```{tableofcontents}
```
```
Loading

0 comments on commit 8b5d664

Please sign in to comment.