This lab is due Tuesday, September 2, 2025 at 11:59PM.
Note: Unlike other labs, this should be done individually to ensure your setup is working properly.
The following guides you through installing python packages in an environment and the basic of running jupyter notebooks.
Lab0.ipynb
environment.yml
: A yaml file with the packages for the
courseProgramming in lab will make use of Python notebooks (also called Jupyter notebooks). Python notebooks are a cell-based Python environment, meaning that your code is divided into cells that can be run in any order. The notebooks are backed by a Python kernel that maintains state between cell executions. This means after executing a cell, the variables and other similar things remain active throughout the duration of your interaction with the notebook. Python notebooks are a very common programming environment for machine learning and data science. The cell-based execution and in-place plotting makes data exploration particularly convenient.
You will need Python 3 and a bunch of Python libraries. In particular, download and install Miniforge for your OS.
ml
EnvironmentNext, make sure you’re in the lab00
directory using
Terminal (or Miniforge Prompt
if you are on Windows) and
run the following command. It will create a new conda
environment containing libraries you will need for this class:
$ conda env create -f environment.yml
Next, activate the new environment:
$ conda activate ml
You’re almost there! You just need to register the ml
conda environment to Jupyter. From the Terminal (or
Miniforge Prompt
):
$ python3 -m ipykernel install --user --name=ml
If you do not do this, you must select the kernel in the “Kernel > Change kernel…” menu in Jupyter every time you open a notebook, so that the correct packages are loaded.
That’s it! You can now start Jupyter from Terminal (or
Miniforge Prompt
) using:
$ jupyter lab
This should open up your browser to Jupyter lab with the contents of the current directory. If your browser does not open automatically, visit localhost:8888.
You should be able to open Lab0.ipynb
from within your
browser Jupyter window. Please read it and run the code cells to ensure
everything is working.
Every time you want to work on materials for this class, you will need to open a Terminal, and run:
$ cd PATH # Navigate to your project folder
$ conda activate ml
$ jupyter lab
There exists some way to integrate this with VS Code. I don’t know how to do this. Please ask your classmates on discord if you are taking this route.
Upload the following files to Gradescope (with the output of your code cells saved):
Lab0.ipynb
with the code block at the end runThe instructions for setting up a local environment and accompanying
environment specification (environment.yml
) are adapted
from the github repo (link) for Hands-on Machine Learning with
Scikit-Learn, Keras and TensorFlow (3rd edition).