Skip to content

Commit 8b5d664

Browse files
committed
add first tutorial and remove build
1 parent 2aad526 commit 8b5d664

File tree

8 files changed

+343
-68
lines changed

8 files changed

+343
-68
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
dsc_tutorials/_builds/
2+
13
# Created by https://www.toptal.com/developers/gitignore/api/jupyternotebooks
24
# Edit at https://www.toptal.com/developers/gitignore?templates=jupyternotebooks
35

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/bckrlab/dsc-tutorials/HEAD)
2+
13
# DSC Tutorials
24

35
> Machine Learning Tutorials for the Data Science Club.

dsc_tutorials/01_python-intro.ipynb

Lines changed: 274 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,23 @@
6060
"id": "e71f1f45-a62c-4e71-acdc-636706992f9e",
6161
"metadata": {},
6262
"source": [
63-
"Task: Change the text of this cell!"
63+
"> Change the text of this cell!"
6464
]
6565
},
6666
{
6767
"cell_type": "markdown",
6868
"id": "ce251bdc-3b8a-4c10-8e9d-87f2aeaae8d5",
6969
"metadata": {},
7070
"source": [
71-
"Task: Create a new cell that reads \"Hi!\", then delete this cell!"
71+
"> Create a new cell that reads \"Hi!\", then delete this cell!"
7272
]
7373
},
7474
{
7575
"cell_type": "markdown",
7676
"id": "139fcdec-3e99-47af-8a49-bbbb2c786e88",
7777
"metadata": {},
7878
"source": [
79-
"Task: Create a new Jupyter Notebook!"
79+
"> Create a new Jupyter Notebook!"
8080
]
8181
},
8282
{
@@ -92,23 +92,30 @@
9292
"id": "9210defe-4352-4790-89c6-db1a148c5449",
9393
"metadata": {},
9494
"source": [
95-
"# Python"
95+
"# Python\n",
96+
"\n",
97+
"> *\"Python is the \"most powerful language you can still read\".*\n",
98+
">\n",
99+
"> Paul Dubois "
96100
]
97101
},
98102
{
99103
"cell_type": "markdown",
100104
"id": "a08d6422-e6c6-405f-ab6c-3a0483e63d1e",
101105
"metadata": {},
102106
"source": [
103-
"[Python](https://en.wikipedia.org/wiki/Python_(programming_language)) is a programming language that was developed in 1991 by Guido van Rossum.\n",
107+
"[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",
104108
"\n",
105109
"Python is:\n",
106110
"\n",
107-
"- **Interpreted**:\n",
108-
"- **Object-Oriented**: Most things in Python are Objects.\n",
111+
"- **Interpreted**: Programs are executed line by line by an interpreter instead of being compiled into machine code first.\n",
112+
"- **multi-paradigm**: programmers can choose their favorite way to conceptualize and structure programs\n",
113+
" - **Object-Oriented**: Programs are implemented via interacting objects. Most things in Python are objects, including functions.\n",
114+
" - **Procedural**: Programs are implemented via interacting functions.\n",
115+
" - **functional**: \n",
109116
"- **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",
110-
"\n",
111-
"- **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."
117+
"- **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",
118+
"- etc."
112119
]
113120
},
114121
{
@@ -139,6 +146,61 @@
139146
" Namespaces are one honking great idea – let's do more of those!"
140147
]
141148
},
149+
{
150+
"cell_type": "code",
151+
"execution_count": 5,
152+
"id": "d0f745bf-8293-48fa-a33a-b3b8a36154a6",
153+
"metadata": {},
154+
"outputs": [
155+
{
156+
"name": "stdout",
157+
"output_type": "stream",
158+
"text": [
159+
"Hello World!\n"
160+
]
161+
}
162+
],
163+
"source": [
164+
"print(\"Hello World!\")"
165+
]
166+
},
167+
{
168+
"cell_type": "code",
169+
"execution_count": null,
170+
"id": "8da08c56-274f-49da-862e-b6cb5499e0d1",
171+
"metadata": {},
172+
"outputs": [],
173+
"source": [
174+
"# TODO: Add Python tasks"
175+
]
176+
},
177+
{
178+
"cell_type": "code",
179+
"execution_count": 20,
180+
"id": "ac17c77c-49d1-453b-ba25-05d039e04671",
181+
"metadata": {},
182+
"outputs": [
183+
{
184+
"data": {
185+
"text/plain": [
186+
"6"
187+
]
188+
},
189+
"execution_count": 20,
190+
"metadata": {},
191+
"output_type": "execute_result"
192+
}
193+
],
194+
"source": [
195+
"# import packages\n",
196+
"import random\n",
197+
"\n",
198+
"def throw_dice():\n",
199+
" return random.randint(1,6)\n",
200+
"\n",
201+
"throw_dice()"
202+
]
203+
},
142204
{
143205
"cell_type": "markdown",
144206
"id": "ccbea933-9e85-43d7-af07-b458874fee77",
@@ -147,18 +209,219 @@
147209
"# Package Management in Python"
148210
]
149211
},
212+
{
213+
"cell_type": "markdown",
214+
"id": "5b9422bf-84e3-4c60-bd22-90badd0521f1",
215+
"metadata": {},
216+
"source": [
217+
"While Python's standard library is already pretty powerful, there are many more great packages for data science.\n",
218+
"Existing Data Science projects will probably depend on some of them.\n",
219+
"Next, let's have a look how to install and manage packages in Python."
220+
]
221+
},
150222
{
151223
"cell_type": "markdown",
152224
"id": "6e7e6447-0dd9-4b72-8920-5acfc014931d",
153225
"metadata": {},
154226
"source": [
155-
"## Pip"
227+
"## pip\n",
228+
"\n",
229+
"pip is Python's package-management tool for installing new packages.\n",
230+
"Python packages are provided by an online repository called the **Python Package Index**, or short [PyPI](https://pypi.org/)."
231+
]
232+
},
233+
{
234+
"cell_type": "markdown",
235+
"id": "254e4992-81b6-4676-9cea-65429c0094da",
236+
"metadata": {},
237+
"source": [
238+
"```sh\n",
239+
"pip install {PACKAGE NAME}\n",
240+
"```"
241+
]
242+
},
243+
{
244+
"cell_type": "markdown",
245+
"id": "0d65e168-f265-46a7-8ece-ddb006a20207",
246+
"metadata": {},
247+
"source": [
248+
"Often projects come with a `requirements.txt` file that specifies their requirements. It can be installed with pip:\n",
249+
"\n",
250+
"```sh\n",
251+
"pip install -r requirements.txt\n",
252+
"```"
253+
]
254+
},
255+
{
256+
"cell_type": "markdown",
257+
"id": "4ba3d734-4570-4883-b69c-1db012431ffd",
258+
"metadata": {},
259+
"source": [
260+
"> install the package pyjokes and run the next cell"
261+
]
262+
},
263+
{
264+
"cell_type": "code",
265+
"execution_count": 21,
266+
"id": "c539f499-e744-43b6-b6fc-eedc5c793f5b",
267+
"metadata": {},
268+
"outputs": [
269+
{
270+
"name": "stdout",
271+
"output_type": "stream",
272+
"text": [
273+
"Collecting pyjokes\n",
274+
" Downloading pyjokes-0.8.3-py3-none-any.whl.metadata (3.4 kB)\n",
275+
"Downloading pyjokes-0.8.3-py3-none-any.whl (47 kB)\n",
276+
"Installing collected packages: pyjokes\n",
277+
"Successfully installed pyjokes-0.8.3\n"
278+
]
279+
}
280+
],
281+
"source": [
282+
"!pip install pyjokes"
283+
]
284+
},
285+
{
286+
"cell_type": "code",
287+
"execution_count": 22,
288+
"id": "7aa1feaa-e9db-4085-984d-93038671b76f",
289+
"metadata": {},
290+
"outputs": [
291+
{
292+
"data": {
293+
"text/plain": [
294+
"\"There are 10 types of people: those who understand binary and those who don't.\""
295+
]
296+
},
297+
"execution_count": 22,
298+
"metadata": {},
299+
"output_type": "execute_result"
300+
}
301+
],
302+
"source": [
303+
"import pyjokes\n",
304+
"\n",
305+
"pyjokes.get_joke()"
306+
]
307+
},
308+
{
309+
"cell_type": "markdown",
310+
"id": "8d8fd3e0-74e2-43b6-974c-e3f86dc6ccc0",
311+
"metadata": {},
312+
"source": [
313+
"## Virtual Environments"
314+
]
315+
},
316+
{
317+
"cell_type": "markdown",
318+
"id": "6f921af2-652f-45a9-855c-e146cb8e48da",
319+
"metadata": {},
320+
"source": [
321+
"pip is great! But things start to get messy as soon as you have multiple projects, each requiring their own dependencies.\n",
322+
"Fortunately, there is one solution: [Virtual Environments](https://docs.python.org/3/library/venv.html)!"
323+
]
324+
},
325+
{
326+
"cell_type": "markdown",
327+
"id": "a1082271-20c8-433b-8d7d-5aac760823d2",
328+
"metadata": {},
329+
"source": [
330+
"```sh\n",
331+
"# create a new virtual environment\n",
332+
"python -m venv myproject\n",
333+
"\n",
334+
"# don't forget to activate it!\n",
335+
"source myenv/bin/activate\n",
336+
"\n",
337+
"# install your packages\n",
338+
"pip install jupyter\n",
339+
"\n",
340+
"# try to start a new jupyter notebook\n",
341+
"jupyter notebook\n",
342+
"\n",
343+
"# deactivate the environment\n",
344+
"deactivate\n",
345+
"```"
346+
]
347+
},
348+
{
349+
"cell_type": "markdown",
350+
"id": "0b5e65d4-3995-4b8b-bc5c-f6fda9b3567e",
351+
"metadata": {},
352+
"source": [
353+
"## Conda"
354+
]
355+
},
356+
{
357+
"cell_type": "markdown",
358+
"id": "adf69db9-7594-4b10-ade4-e3d05b4257e9",
359+
"metadata": {},
360+
"source": [
361+
"- https://docs.conda.io\n",
362+
"- Miniconda: https://docs.anaconda.com/miniconda/"
363+
]
364+
},
365+
{
366+
"cell_type": "markdown",
367+
"id": "c069f3b6-fe16-4836-abab-16337903076c",
368+
"metadata": {},
369+
"source": [
370+
"```sh\n",
371+
"conda create -n myenv\n",
372+
"conda activate myenv\n",
373+
"conda install python=3.12 numpy jupyter\n",
374+
"```"
375+
]
376+
},
377+
{
378+
"cell_type": "markdown",
379+
"id": "720d22f6-ed29-4385-ae9f-b0afbbe15841",
380+
"metadata": {},
381+
"source": [
382+
"Quick Reference:\n",
383+
"\n",
384+
"```sh\n",
385+
"# create a new conda environment with a name\n",
386+
"conda create -n myenv\n",
387+
"# create a conda environment from a yml file\n",
388+
"conda env create -f environment.yml\n",
389+
"# list available conda environments\n",
390+
"conda env list\n",
391+
"# activate a conda environment\n",
392+
"conda activate myenv\n",
393+
"# install dependencies in active environment\n",
394+
"conda install numpy \n",
395+
"# export your environment to a yml file\n",
396+
"conda env export -f environment.yml\n",
397+
"conda env export > environment.yml\n",
398+
"# deactivate an environment\n",
399+
"conda deactivate\n",
400+
"# remove an environment\n",
401+
"conda remove --name myenv --all\n",
402+
"```"
403+
]
404+
},
405+
{
406+
"cell_type": "markdown",
407+
"id": "91adae1a-892b-40f3-908f-0cf99801d981",
408+
"metadata": {},
409+
"source": [
410+
"## Pointers"
411+
]
412+
},
413+
{
414+
"cell_type": "markdown",
415+
"id": "5ff781fc-3d42-4415-ae02-c97576161939",
416+
"metadata": {},
417+
"source": [
418+
"- https://ipython.readthedocs.io/en/stable/interactive/magics.html"
156419
]
157420
},
158421
{
159422
"cell_type": "code",
160423
"execution_count": null,
161-
"id": "6bce9a93-e7db-4a4f-bf45-bf9b787fec2a",
424+
"id": "9a2be204-a8d8-4b84-a454-1982b858076b",
162425
"metadata": {},
163426
"outputs": [],
164427
"source": []

dsc_tutorials/_toc.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
format: jb-book
55
root: intro
66
chapters:
7-
- file: markdown
8-
- file: notebooks
9-
- file: markdown-notebooks
7+
- file: 01_python-intro
8+
- file: bookmarks

dsc_tutorials/bookmarks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Bookmarks
2+
3+
> Good reads
4+
5+
WIP

dsc_tutorials/intro.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# Welcome to your Jupyter Book
1+
# Welcome to the Data Science Club!
22

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

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

108
```{tableofcontents}
11-
```
9+
```

0 commit comments

Comments
 (0)