Prerequisites
NOTE: underneath, anthing within curly brances is something you yourself
fill in
e.g.
{pick name of environment}
could be my-py-env
NOTE: all commands below are to be run in a "terminal" (not python) unless otherwise specified
NOTE: the participants get the instructions in course_preparation.md
Get code
Download the zipped folder from the course page.
The code is ml_code.py
, and the dataset is in data/countdata_large_normed.csv
Place the contents somewhere you can easily find from python.
Install VS Code (optional)
Install VS Code (version after 2021) for your OS (Windows, Mac, Linux)
https://code.visualstudio.com/download
You can use any other IDE you like (e.g. Spyder, PyCharm, Juptyer Notebook, JupyterLab, etc), but
the setup for using Jupyter (interactively) is based on VS Code
Conda (optional)
This is optional, but recommended that you use some kind of virtual environment,
such as pipenv or poetry
Install full conda:
https://docs.anaconda.com/free/anaconda/install/index.html
Alternatively, install miniconda
https://docs.anaconda.com/free/miniconda/#quick-command-line-install
NOTE: should test this out myself
Make conda environment
conda create --name {pick name of environment} python={version 3.9 or higher}
for instance
conda create --name py-env-course python=3.9
To use the conda environment, in terminal window (e.g. in VS code), run
conda activate {pick name for environment}
Extra for Windows (conda + VS Code)
If you want to use VSCode with (mini)conda you cannot open VSCode by itself.
you have to open the (mini)conda prompt, activate your environment (see previous command),
and then enter:
code
This will open up VS Code with the correct conda environment.
see first answer [here](https://stackoverflow.com/questions/61986052/visual-studio-code-terminal-doesnt-activate-conda-environment) for more details
Install packages (mandatory)
Note: if you are not using conda, activate virtual environment
with whatever environment manager you have (not required, but recommended)
Mandatory install packages by doing
pip install -r requirements.txt
Settings in VS Code including Jupyter (Optional)
In VS Code
Manage (cog wheel)-> Command Palette -> "> "Python: Select Interpreter" -> {choose conda environment from previous step}
Or with keyboard shortcut.
Ctrl + shift + P -> "> "Python: Select Interpreter" -> {choose conda environment from previous step}
Install Jupyter module for python Note: only do this if not in requirements.txt
pip install jupyter
pip install nbconvert
Install Jupyter extension for VS Code
Extensions (Ctrl + Shift + X) -> look up jupyter and install
Install kernel to run "jupyter" code two options
- when first tring to run a cell, will be asked by VScode to isntall
ipykernel
or - In terminal, do
pip install ipykernel
During course
In whatever IDE you are using (or REPL), set the working directory to the folder
that contains the code and dataset.
In VS Code, you would do:
File -> Open Folder -> {pick folder that containas the files}
Jupyter shortcuts (from)
NOTE: In VSCode, works for Juptyer (code cells) in Python interactive mode
- ctrl + enter = run current cell
- shift + enter = run current cell and jump to next cell
- [ctrl + shift + ,] A = insert cell above
- [ctrl + shift + ,] B = insert cell below
- [ctrl + shift + ,] S = insert cell below cursoin vscode
- r position
- [ctrl + shift + ,] X = delete selected cell(s)
- [ctrl + shift + ,] C = change (markdown) cell to code
- [ctrl + shift + ,] U = move selected cell(s) up
- [ctrl + shift + ,] D = move selected cell(s) down